From 2df8e4bc8c53a831f3cd8605707ca08d66cecb02 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 25 May 2021 01:55:09 -0400 Subject: Updates for Common-Lisp compiler. --- lux-scheme/source/program.lux | 70 +++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 36 deletions(-) (limited to 'lux-scheme') diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux index e318c6abd..24d26945d 100644 --- a/lux-scheme/source/program.lux +++ b/lux-scheme/source/program.lux @@ -1,7 +1,7 @@ (.module: [lux #* [program (#+ program:)] - ["." host] + ["." ffi] ["." debug] [abstract ["." monad (#+ do)]] @@ -63,82 +63,82 @@ ["#." cli] ["#." static]]]) -(host.import: java/lang/Boolean) -(host.import: java/lang/String) +(ffi.import: java/lang/Boolean) +(ffi.import: java/lang/String) -(host.import: (java/lang/Class a)) +(ffi.import: (java/lang/Class a)) -(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/Long +(ffi.import: java/lang/Long ["#::." (intValue [] java/lang/Integer)]) -(host.import: java/lang/Integer +(ffi.import: java/lang/Integer ["#::." (longValue [] java/lang/Long)]) -(host.import: gnu/math/IntNum +(ffi.import: gnu/math/IntNum ["#::." (new #manual [int]) (longValue [] long)]) -(host.import: gnu/math/DFloNum +(ffi.import: gnu/math/DFloNum ["#::." (doubleValue [] double)]) -(host.import: gnu/lists/FString +(ffi.import: gnu/lists/FString ["#::." (toString [] String)]) -(host.import: gnu/lists/IString +(ffi.import: gnu/lists/IString ["#::." (toString [] String)]) -(host.import: gnu/lists/Pair +(ffi.import: gnu/lists/Pair ["#::." (getCar [] java/lang/Object) (getCdr [] java/lang/Object)]) -(host.import: gnu/lists/EmptyList +(ffi.import: gnu/lists/EmptyList ["#::." (#static emptyList gnu/lists/EmptyList)]) -(host.import: (gnu/lists/FVector E) +(ffi.import: (gnu/lists/FVector E) ["#::." (getBufferLength [] int) (getRaw [int] E)]) -(host.import: gnu/lists/U8Vector) +(ffi.import: gnu/lists/U8Vector) -(host.import: gnu/mapping/Procedure +(ffi.import: gnu/mapping/Procedure ["#::." (apply2 [java/lang/Object java/lang/Object] #try java/lang/Object) (applyN [[java/lang/Object]] #try java/lang/Object)]) -(host.import: gnu/mapping/Environment) +(ffi.import: gnu/mapping/Environment) -(host.import: gnu/expr/Language +(ffi.import: gnu/expr/Language ["#::." (eval [java/lang/String] #try java/lang/Object)]) -(host.import: kawa/standard/Scheme +(ffi.import: kawa/standard/Scheme ["#::." (#static getR7rsInstance [] kawa/standard/Scheme)]) (def: (variant? value) (-> Any Bit) - (case (host.check [java/lang/Object] (:coerce java/lang/Object value)) + (case (ffi.check [java/lang/Object] (:coerce java/lang/Object value)) (#.Some array) ## TODO: Get rid of this coercion ASAP. (let [array (:coerce (Array java/lang/Object) array)] (and (n.= 3 (array.size array)) (case (array.read 0 array) (#.Some tag) - (case (host.check java/lang/Integer tag) + (case (ffi.check java/lang/Integer tag) (#.Some _) true @@ -152,10 +152,10 @@ false)) (template [] - [(host.interface: + [(ffi.interface: (getValue [] java/lang/Object)) - (`` (host.import: (~~ (template.identifier ["program/" ])) + (`` (ffi.import: (~~ (template.identifier ["program/" ])) ["#::." (getValue [] java/lang/Object)]))] @@ -165,7 +165,7 @@ (def: (variant_value lux_value cdr? value) (-> (-> java/lang/Object java/lang/Object) Bit (Array java/lang/Object) gnu/lists/Pair) - (host.object [] gnu/lists/Pair [program/VariantValue] + (ffi.object [] gnu/lists/Pair [program/VariantValue] [] ## Methods (program/VariantValue @@ -196,7 +196,7 @@ (def: (tuple_value lux_value value) (-> (-> java/lang/Object java/lang/Object) (Array java/lang/Object) gnu/lists/FVector) - (host.object [] gnu/lists/SimpleVector [program/TupleValue gnu/lists/GVector] + (ffi.object [] gnu/lists/SimpleVector [program/TupleValue gnu/lists/GVector] [] ## Methods (program/TupleValue @@ -204,7 +204,7 @@ (:coerce java/lang/Object value)) (gnu/lists/SimpleVector [] (getBufferLength self) int - (host.long_to_int (array.size value))) + (ffi.long_to_int (array.size value))) (gnu/lists/SimpleVector [] (getRaw self {idx int}) java/lang/Object (|> value @@ -240,7 +240,7 @@ (def: (lux_value value) (-> java/lang/Object java/lang/Object) - (<| (case (host.check [java/lang/Object] value) + (<| (case (ffi.check [java/lang/Object] value) (#.Some value) ## TODO: Get rid of the coercions below. (if (variant? value) @@ -258,7 +258,7 @@ (: Any (if flag synthesis.unit - (host.null))) + (ffi.null))) value]) (def: (read_variant read host_object) @@ -266,7 +266,7 @@ (do try.monad [tag (read (gnu/lists/Pair::getCar host_object)) #let [host_object (:coerce gnu/lists/Pair (gnu/lists/Pair::getCdr host_object)) - flag (case (host.check java/lang/Boolean (gnu/lists/Pair::getCar host_object)) + flag (case (ffi.check java/lang/Boolean (gnu/lists/Pair::getCar host_object)) (#.Some flag) (:coerce Bit flag) @@ -293,7 +293,7 @@ (def: (read host_object) (Reader java/lang/Object) (`` (<| (~~ (template [] - [(case (host.check host_object) + [(case (ffi.check host_object) (#.Some host_object) (#try.Success host_object) #.None)] @@ -302,7 +302,7 @@ [gnu/mapping/Procedure] [gnu/lists/U8Vector] )) (~~ (template [ ] - [(case (host.check host_object) + [(case (ffi.check host_object) (#.Some host_object) (#try.Success (<| host_object)) #.None)] @@ -318,11 +318,11 @@ [program/VariantValue program/VariantValue::getValue] [program/TupleValue program/TupleValue::getValue] )) - (case (host.check gnu/lists/Pair host_object) + (case (ffi.check gnu/lists/Pair host_object) (#.Some host_object) (read_variant read host_object) #.None) - (case (host.check gnu/lists/FVector host_object) + (case (ffi.check gnu/lists/FVector host_object) (#.Some host_object) (read_tuple read (:coerce (gnu/lists/FVector java/lang/Object) host_object)) #.None) @@ -331,7 +331,7 @@ (def: ensure_macro (-> Macro (Maybe gnu/mapping/Procedure)) - (|>> (:coerce java/lang/Object) (host.check gnu/mapping/Procedure))) + (|>> (:coerce java/lang/Object) (ffi.check gnu/mapping/Procedure))) (def: (expander macro inputs lux) Expander @@ -352,8 +352,6 @@ (exception.throw ..cannot_apply_a_non_function (:coerce java/lang/Object macro))) ) -(def: separator "$") - (def: host (IO (Host _.Expression _.Expression)) (io (let [interpreter (kawa/standard/Scheme::getR7rsInstance) -- cgit v1.2.3