diff options
Diffstat (limited to 'stdlib/source/lux/debug.lux')
-rw-r--r-- | stdlib/source/lux/debug.lux | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/stdlib/source/lux/debug.lux b/stdlib/source/lux/debug.lux index 47d62fd34..29919a588 100644 --- a/stdlib/source/lux/debug.lux +++ b/stdlib/source/lux/debug.lux @@ -85,7 +85,12 @@ (as_is (import: Class) (import: Object - (type [] Class)))})) + (type [] Class))) + + @.php + (as_is (import: (gettype [.Any] host.String)) + (import: (strval [.Any] host.String))) + })) (def: Inspector (-> Any Text)) @@ -195,7 +200,7 @@ (if (or ("python object none?" variant_tag) ("python object none?" variant_value)) (..str value) - (|> (format (|> variant_tag (:coerce .Int) %.int) + (|> (format (|> variant_tag (:coerce .Nat) %.nat) " " (|> variant_flag "python object none?" not %.bit) " " (inspect variant_value)) (text.enclose ["(" ")"])))) @@ -228,7 +233,7 @@ (if (not (or ("lua object nil?" variant_tag) ("lua object nil?" variant_flag) ("lua object nil?" variant_value))) - (|> (format (|> variant_tag (:coerce .Int) %.int) + (|> (format (|> variant_tag (:coerce .Nat) %.nat) " " (%.bit (not ("lua object nil?" variant_flag))) " " (inspect variant_value)) (text.enclose ["(" ")"])) @@ -260,7 +265,7 @@ (if (not (or ("ruby object nil?" variant_tag) ("ruby object nil?" variant_flag) ("ruby object nil?" variant_value))) - (|> (format (|> variant_tag (:coerce .Int) %.int) + (|> (format (|> variant_tag (:coerce .Nat) %.nat) " " (%.bit (not ("ruby object nil?" variant_flag))) " " (inspect variant_value)) (text.enclose ["(" ")"])) @@ -271,6 +276,34 @@ ## else (:coerce Text ("ruby object do" "to_s" value)))))) + + @.php + (case (..gettype value) + (^template [<type_of> <then>] + [<type_of> + (`` (|> value (~~ (template.splice <then>))))]) + (["boolean" [(:coerce .Bit) %.bit]] + ["integer" [(:coerce .Int) %.int]] + ["double" [(:coerce .Frac) %.frac]] + ["string" [(:coerce .Text) %.text]] + ["NULL" [(new> "null" [])]] + ["array" [(inspect_tuple inspect)]]) + + "object" + (let [variant_tag ("php object get" "_lux_tag" value) + variant_flag ("php object get" "_lux_flag" value) + variant_value ("php object get" "_lux_value" value)] + (if (not (or ("php object null?" variant_tag) + ("php object null?" variant_flag) + ("php object null?" variant_value))) + (|> (format (|> variant_tag (:coerce .Nat) %.nat) + " " (%.bit (not ("php object null?" variant_flag))) + " " (inspect variant_value)) + (text.enclose ["(" ")"])) + (..strval value))) + + _ + (..strval value)) }))) (exception: #export (cannot_represent_value {type Type}) |