From 512d7feeb915376c090aedaf64e8209689becd2a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 8 Jun 2021 13:26:10 -0400 Subject: Added type information when logging compiled definitions. --- lux-php/source/program.lux | 119 +++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 59 deletions(-) (limited to 'lux-php') diff --git a/lux-php/source/program.lux b/lux-php/source/program.lux index 716405587..b97adb407 100644 --- a/lux-php/source/program.lux +++ b/lux-php/source/program.lux @@ -1,7 +1,7 @@ (.module: [lux #* [program (#+ program:)] - ["." host] + ["." ffi] ["." debug] [abstract ["." monad (#+ do)]] @@ -16,7 +16,8 @@ ["." maybe] ["." text ("#\." hash) ["%" format (#+ format)] - ["." encoding]] + [encoding + ["." utf8]]] [collection ["." array (#+ Array)]]] [macro @@ -63,108 +64,108 @@ ["#." cli] ["#." static]]]) -(host.import: java/lang/String) +(ffi.import: java/lang/String) -(host.import: java/lang/reflect/Field +(ffi.import: java/lang/reflect/Field ["#::." (get [java/lang/Object] java/lang/Object)]) -(host.import: java/lang/reflect/AccessibleObject +(ffi.import: java/lang/reflect/AccessibleObject ["#::." (setAccessible [boolean] void)]) -(host.import: (java/lang/Class a) +(ffi.import: (java/lang/Class a) ["#::." (getDeclaredField [java/lang/String] java/lang/reflect/Field)]) -(host.import: java/lang/Object +(ffi.import: java/lang/Object ["#::." (toString [] java/lang/String) (getClass [] (java/lang/Class java/lang/Object))]) -(host.import: java/lang/Integer) +(ffi.import: java/lang/Integer) -(host.import: java/lang/Long +(ffi.import: java/lang/Long ["#::." (intValue [] java/lang/Integer)]) -(host.import: php/runtime/Memory +(ffi.import: php/runtime/Memory ["#::." (valueOfIndex #as generic_valueOfIndex [php/runtime/env/TraceInfo php/runtime/Memory] php/runtime/Memory) (valueOfIndex #as long_valueOfIndex [php/runtime/env/TraceInfo long] php/runtime/Memory) (valueOfIndex #as string_valueOfIndex [php/runtime/env/TraceInfo java/lang/String] php/runtime/Memory)]) -(host.import: php/runtime/Memory$Type +(ffi.import: php/runtime/Memory$Type ["#::." (#enum ARRAY)]) -(host.import: php/runtime/memory/NullMemory +(ffi.import: php/runtime/memory/NullMemory ["#::." (#static INSTANCE php/runtime/memory/NullMemory)]) -(host.import: php/runtime/memory/FalseMemory +(ffi.import: php/runtime/memory/FalseMemory ["#::." (#static INSTANCE php/runtime/memory/FalseMemory)]) -(host.import: php/runtime/memory/TrueMemory +(ffi.import: php/runtime/memory/TrueMemory ["#::." (#static INSTANCE php/runtime/memory/TrueMemory)]) -(host.import: php/runtime/memory/LongMemory +(ffi.import: php/runtime/memory/LongMemory ["#::." (new [long]) (toLong [] long) (#static valueOf #manual [int] php/runtime/Memory)]) -(host.import: php/runtime/memory/DoubleMemory +(ffi.import: php/runtime/memory/DoubleMemory ["#::." (new [double]) (toDouble [] double)]) -(host.import: php/runtime/memory/StringMemory +(ffi.import: php/runtime/memory/StringMemory ["#::." (new [java/lang/String]) (toString [] java/lang/String)]) -(host.import: php/runtime/memory/ReferenceMemory +(ffi.import: php/runtime/memory/ReferenceMemory ["#::." (getValue [] php/runtime/Memory)]) -(host.import: php/runtime/memory/ArrayMemory +(ffi.import: php/runtime/memory/ArrayMemory ["#::." (new [[java/lang/Object]]) (size [] int) (isMap [] boolean) (get [php/runtime/Memory] #? php/runtime/Memory)]) -(host.import: php/runtime/lang/IObject) +(ffi.import: php/runtime/lang/IObject) -(host.import: php/runtime/memory/ObjectMemory +(ffi.import: php/runtime/memory/ObjectMemory ["#::." (value php/runtime/lang/IObject)]) -(host.import: php/runtime/env/Environment) +(ffi.import: php/runtime/env/Environment) -(host.import: php/runtime/env/TraceInfo +(ffi.import: php/runtime/env/TraceInfo ["#::." (new [java/lang/String int int])]) -(host.import: php/runtime/reflection/FunctionEntity) +(ffi.import: php/runtime/reflection/FunctionEntity) -(host.import: php/runtime/invoke/InvokeHelper +(ffi.import: php/runtime/invoke/InvokeHelper ["#::." (#static callAny [php/runtime/Memory [php/runtime/Memory] php/runtime/env/Environment php/runtime/env/TraceInfo] #try php/runtime/Memory)]) -(host.import: php/runtime/lang/Closure +(ffi.import: php/runtime/lang/Closure ["#::." (call [php/runtime/env/Environment [php/runtime/Memory]] #try php/runtime/Memory)]) (template [] - [(host.interface: + [(ffi.interface: (getValue [] java/lang/Object)) - (`` (host.import: (~~ (template.identifier ["program/" ])) + (`` (ffi.import: (~~ (template.identifier ["program/" ])) ["#::." (getValue [] java/lang/Object)]))] @@ -181,36 +182,36 @@ (def: (value_wrapper lux_structure value) (-> (-> (Array java/lang/Object) php/runtime/Memory) java/lang/Object php/runtime/Memory) - (<| (if (host.null? value) + (<| (if (ffi.null? value) (php/runtime/memory/NullMemory::INSTANCE)) - (case (host.check java/lang/Boolean value) + (case (ffi.check java/lang/Boolean value) (#.Some value) (if (:coerce Bit value) (php/runtime/memory/TrueMemory::INSTANCE) (php/runtime/memory/FalseMemory::INSTANCE)) #.None) - (case (host.check java/lang/Long value) + (case (ffi.check java/lang/Long value) (#.Some value) (php/runtime/memory/LongMemory::new value) #.None) - (case (host.check java/lang/Double value) + (case (ffi.check java/lang/Double value) (#.Some value) (php/runtime/memory/DoubleMemory::new value) #.None) - (case (host.check java/lang/String value) + (case (ffi.check java/lang/String value) (#.Some value) (php/runtime/memory/StringMemory::new value) #.None) - (case (host.check [java/lang/Object] value) + (case (ffi.check [java/lang/Object] value) (#.Some value) (lux_structure (:coerce (Array java/lang/Object) value)) #.None) - (case (host.check php/runtime/memory/ObjectMemory value) + (case (ffi.check php/runtime/memory/ObjectMemory value) (#.Some value) value @@ -223,7 +224,7 @@ (def: (lux_structure value) (-> (Array java/lang/Object) php/runtime/Memory) - (`` (host.object [] php/runtime/Memory + (`` (ffi.object [] php/runtime/Memory [program/StructureValue] [{php/runtime/Memory$Type php/runtime/Memory$Type::ARRAY}] ## Methods @@ -242,7 +243,7 @@ {index php/runtime/Memory}) php/runtime/Memory (`` (<| (~~ (template [ ] - [(case (host.check index) + [(case (ffi.check index) (#.Some index) ( trace ( index) self) @@ -318,7 +319,7 @@ maybe.assume (:coerce php/runtime/memory/ReferenceMemory) php/runtime/memory/ReferenceMemory::getValue)] - (case (host.check php/runtime/memory/NullMemory value) + (case (ffi.check php/runtime/memory/NullMemory value) (#.Some _) (recur (inc idx) output) @@ -358,9 +359,9 @@ maybe.assume (:coerce php/runtime/memory/ReferenceMemory) php/runtime/memory/ReferenceMemory::getValue - (host.check php/runtime/memory/NullMemory)) + (ffi.check php/runtime/memory/NullMemory)) (#.Some _) - (host.null) + (ffi.null) #.None synthesis.unit)) @@ -377,7 +378,7 @@ (def: (read host_object) Reader (`` (<| (~~ (template [ ] - [(case (host.check host_object) + [(case (ffi.check host_object) (#.Some _) (#try.Success ) @@ -387,7 +388,7 @@ [php/runtime/memory/TrueMemory true] )) (~~ (template [ ] - [(case (host.check host_object) + [(case (ffi.check host_object) (#.Some value) (`` (|> value (~~ (template.splice )))) @@ -400,7 +401,7 @@ [php/runtime/memory/ReferenceMemory [php/runtime/memory/ReferenceMemory::getValue read]] [php/runtime/memory/ObjectMemory [#try.Success]] )) - (case (host.check php/runtime/memory/ArrayMemory host_object) + (case (ffi.check php/runtime/memory/ArrayMemory host_object) (#.Some value) (if (|> value (php/runtime/memory/ArrayMemory::get ..tuple_size_field) @@ -417,11 +418,11 @@ ["Class" (java/lang/Object::toString (java/lang/Object::getClass object))] ["Non-function" (java/lang/Object::toString object)])) -(host.import: javax/script/ScriptEngine +(ffi.import: javax/script/ScriptEngine ["#::." (eval [java/lang/String] #try Object)]) -(host.import: org/develnext/jphp/scripting/JPHPScriptEngine +(ffi.import: org/develnext/jphp/scripting/JPHPScriptEngine ["#::." (new [])]) @@ -429,7 +430,7 @@ (-> Macro (Maybe php/runtime/memory/ObjectMemory)) (|> macro (:coerce java/lang/Object) - (host.check php/runtime/memory/ObjectMemory))) + (ffi.check php/runtime/memory/ObjectMemory))) (def: interpreter (org/develnext/jphp/scripting/JPHPScriptEngine::new)) @@ -448,10 +449,10 @@ (<| :assume (do try.monad [output (php/runtime/lang/Closure::call ..default_environment - (|> (host.array php/runtime/Memory 3) - (host.array_write 0 macro) - (host.array_write 1 (lux_structure (:coerce (Array java/lang/Object) inputs))) - (host.array_write 2 (lux_structure (:coerce (Array java/lang/Object) lux)))) + (|> (ffi.array php/runtime/Memory 3) + (ffi.array_write 0 macro) + (ffi.array_write 1 (lux_structure (:coerce (Array java/lang/Object) inputs))) + (ffi.array_write 2 (lux_structure (:coerce (Array java/lang/Object) lux)))) (:coerce php/runtime/lang/Closure (php/runtime/memory/ObjectMemory::value macro)))] (..read (:coerce java/lang/Object output))))) @@ -489,7 +490,7 @@ (wrap [global value definition])))) (def: (ingest context content) - (|> content (\ encoding.utf8 decode) try.assume (:coerce _.Statement))) + (|> content (\ utf8.codec decode) try.assume (:coerce _.Statement))) (def: (re_learn context content) (run! content)) @@ -507,7 +508,7 @@ #platform.host host #platform.phase php.generate #platform.runtime runtime.generate - #platform.write (|>> _.code (\ encoding.utf8 encode))}))) + #platform.write (|>> _.code (\ utf8.codec encode))}))) (def: (program context program) (Program _.Expression _.Statement) @@ -535,13 +536,13 @@ #let [to_php (: (-> Any php/runtime/Memory) (|>> (:coerce (Array java/lang/Object)) lux_structure (:coerce php/runtime/Memory)))] output (php/runtime/lang/Closure::call ..default_environment - (|> (host.array php/runtime/Memory 6) - (host.array_write 0 handler) - (host.array_write 1 (php/runtime/memory/StringMemory::new name)) - (host.array_write 2 (to_php phase)) - (host.array_write 3 (to_php archive)) - (host.array_write 4 (to_php parameters)) - (host.array_write 5 (to_php state))) + (|> (ffi.array php/runtime/Memory 6) + (ffi.array_write 0 handler) + (ffi.array_write 1 (php/runtime/memory/StringMemory::new name)) + (ffi.array_write 2 (to_php phase)) + (ffi.array_write 3 (to_php archive)) + (ffi.array_write 4 (to_php parameters)) + (ffi.array_write 5 (to_php state))) (:coerce php/runtime/lang/Closure (php/runtime/memory/ObjectMemory::value handler)))] (..read output)))) -- cgit v1.2.3