aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lux-bootstrapper/src/lux/analyser/lux.clj7
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm/lux.clj6
-rw-r--r--lux-jvm/source/program.lux40
-rw-r--r--lux-mode/lux-mode.el6
-rw-r--r--lux-php/source/program.lux119
-rw-r--r--stdlib/source/lux/control/concurrency/thread.lux14
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux8
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux10
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux5
9 files changed, 113 insertions, 102 deletions
diff --git a/lux-bootstrapper/src/lux/analyser/lux.clj b/lux-bootstrapper/src/lux/analyser/lux.clj
index b7d78aa23..63bc675de 100644
--- a/lux-bootstrapper/src/lux/analyser/lux.clj
+++ b/lux-bootstrapper/src/lux/analyser/lux.clj
@@ -562,8 +562,11 @@
=meta (&&/analyse-1 analyse &type/Code ?meta)
==meta (eval! (optimize =meta))
def-value (compile-def ?name (optimize =value) ==meta exported?)
- _ &type/reset-mappings]
- (return (&/T [module-name (&&/expr-type* =value) def-value]))))
+ _ &type/reset-mappings
+ :let [def-type (&&/expr-type* =value)
+ _ (println 'DEF (str module-name &/+name-separator+ ?name
+ " : " (&type/show-type def-type)))]]
+ (return (&/T [module-name def-type def-value]))))
(defn analyse-def [analyse optimize eval! compile-def ?name ?value ?meta exported?]
(|do [_ (analyse-def* analyse optimize eval! compile-def ?name ?value ?meta exported?)]
diff --git a/lux-bootstrapper/src/lux/compiler/jvm/lux.clj b/lux-bootstrapper/src/lux/compiler/jvm/lux.clj
index 043fc2273..515bd8db5 100644
--- a/lux-bootstrapper/src/lux/compiler/jvm/lux.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm/lux.clj
@@ -295,8 +295,7 @@
(return nil)))
:let [_ (.visitEnd =class)]
_ (&&/save-class! def-name (.toByteArray =class))
- def-value (install-def! class-loader current-class module-name ?name ?body ?meta exported?)
- :let [_ (println 'DEF (str module-name &/+name-separator+ ?name))]]
+ def-value (install-def! class-loader current-class module-name ?name ?body ?meta exported?)]
(return def-value)))
_
@@ -322,8 +321,7 @@
(return nil)))
:let [_ (.visitEnd =class)]
_ (&&/save-class! def-name (.toByteArray =class))
- def-value (install-def! class-loader current-class module-name ?name ?body ?meta exported?)
- :let [_ (println 'DEF (str module-name &/+name-separator+ ?name))]]
+ def-value (install-def! class-loader current-class module-name ?name ?body ?meta exported?)]
(return def-value))))))
(defn compile-program [compile ?program]
diff --git a/lux-jvm/source/program.lux b/lux-jvm/source/program.lux
index 65cff6d00..f6a921e86 100644
--- a/lux-jvm/source/program.lux
+++ b/lux-jvm/source/program.lux
@@ -2,7 +2,7 @@
[lux (#- Definition)
[program (#+ program:)]
["@" target]
- ["." host (#+ import:)]
+ ["." ffi (#+ import:)]
[abstract
[monad (#+ do)]]
[control
@@ -79,22 +79,22 @@
(def: _object_class
(java/lang/Class java/lang/Object)
- (host.class_for java/lang/Object))
+ (ffi.class_for java/lang/Object))
(def: _apply2_args
(Array (java/lang/Class java/lang/Object))
- (|> (host.array (java/lang/Class java/lang/Object) 2)
- (host.array_write 0 _object_class)
- (host.array_write 1 _object_class)))
+ (|> (ffi.array (java/lang/Class java/lang/Object) 2)
+ (ffi.array_write 0 _object_class)
+ (ffi.array_write 1 _object_class)))
(def: _apply5_args
(Array (java/lang/Class java/lang/Object))
- (|> (host.array (java/lang/Class java/lang/Object) 5)
- (host.array_write 0 _object_class)
- (host.array_write 1 _object_class)
- (host.array_write 2 _object_class)
- (host.array_write 3 _object_class)
- (host.array_write 4 _object_class)))
+ (|> (ffi.array (java/lang/Class java/lang/Object) 5)
+ (ffi.array_write 0 _object_class)
+ (ffi.array_write 1 _object_class)
+ (ffi.array_write 2 _object_class)
+ (ffi.array_write 3 _object_class)
+ (ffi.array_write 4 _object_class)))
(def: #export (expander macro inputs lux)
Expander
@@ -106,9 +106,9 @@
(:coerce (Try (Try [Lux (List Code)]))
(java/lang/reflect/Method::invoke
(:coerce java/lang/Object macro)
- (|> (host.array java/lang/Object 2)
- (host.array_write 0 (:coerce java/lang/Object inputs))
- (host.array_write 1 (:coerce java/lang/Object lux)))
+ (|> (ffi.array java/lang/Object 2)
+ (ffi.array_write 0 (:coerce java/lang/Object inputs))
+ (ffi.array_write 1 (:coerce java/lang/Object lux)))
apply_method))))
(def: #export platform
@@ -146,12 +146,12 @@
(java/lang/Class::getMethod "apply" _apply5_args))]
(java/lang/reflect/Method::invoke
(:coerce java/lang/Object handler)
- (|> (host.array java/lang/Object 5)
- (host.array_write 0 (:coerce java/lang/Object name))
- (host.array_write 1 (:coerce java/lang/Object phase))
- (host.array_write 2 (:coerce java/lang/Object archive))
- (host.array_write 3 (:coerce java/lang/Object parameters))
- (host.array_write 4 (:coerce java/lang/Object state)))
+ (|> (ffi.array java/lang/Object 5)
+ (ffi.array_write 0 (:coerce java/lang/Object name))
+ (ffi.array_write 1 (:coerce java/lang/Object phase))
+ (ffi.array_write 2 (:coerce java/lang/Object archive))
+ (ffi.array_write 3 (:coerce java/lang/Object parameters))
+ (ffi.array_write 4 (:coerce java/lang/Object state)))
method))))
(def: (declare_success! _)
diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el
index 33bc0d736..530a5be4e 100644
--- a/lux-mode/lux-mode.el
+++ b/lux-mode/lux-mode.el
@@ -538,12 +538,12 @@ This function also returns nil meaning don't specify the indentation."
(Rec 'defun)
(synchronized 'defun)
(object 'defun)
- (do-to 'defun)
+ (do_to 'defun)
(comment 'defun)
(^template 'defun)
(remember 'defun)
- (to-do 'defun)
- (fix-me 'defun)
+ (to_do 'defun)
+ (fix_me 'defun)
)
;;;###autoload
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 [<name>]
- [(host.interface: <name>
+ [(ffi.interface: <name>
(getValue [] java/lang/Object))
- (`` (host.import: (~~ (template.identifier ["program/" <name>]))
+ (`` (ffi.import: (~~ (template.identifier ["program/" <name>]))
["#::."
(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 [<class> <method> <extractor>]
- [(case (host.check <class> index)
+ [(case (ffi.check <class> index)
(#.Some index)
(<method> trace (<extractor> 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 [<class> <constant>]
- [(case (host.check <class> host_object)
+ [(case (ffi.check <class> host_object)
(#.Some _)
(#try.Success <constant>)
@@ -387,7 +388,7 @@
[php/runtime/memory/TrueMemory true]
))
(~~ (template [<class> <post>]
- [(case (host.check <class> host_object)
+ [(case (ffi.check <class> host_object)
(#.Some value)
(`` (|> value (~~ (template.splice <post>))))
@@ -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))))
diff --git a/stdlib/source/lux/control/concurrency/thread.lux b/stdlib/source/lux/control/concurrency/thread.lux
index 4afa4dde3..daeb38a63 100644
--- a/stdlib/source/lux/control/concurrency/thread.lux
+++ b/stdlib/source/lux/control/concurrency/thread.lux
@@ -13,7 +13,9 @@
[math
[number
["n" nat]
- ["f" frac]]]]
+ ["f" frac]]]
+ [time
+ ["." instant]]]
[//
["." atom (#+ Atom)]])
@@ -117,7 +119,10 @@
## Default
(do io.monad
- [_ (atom.update (|>> (#.Cons {#creation (.nat ("lux io current-time"))
+ [_ (atom.update (|>> (#.Cons {#creation (|> instant.now
+ io.run
+ instant.to_millis
+ .nat)
#delay milli_seconds
#action action}))
..runner)]
@@ -143,7 +148,10 @@
_
(do !
- [#let [now (.nat ("lux io current-time"))
+ [#let [now (|> instant.now
+ io.run
+ instant.to_millis
+ .nat)
[ready pending] (list.partition (function (_ thread)
(|> (get@ #creation thread)
(n.+ (get@ #delay thread))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux
index 603abc6ec..19aea38fa 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux
@@ -1,6 +1,6 @@
(.module:
[lux #*
- ["." host]
+ ["." ffi]
[abstract
["." monad (#+ do)]]
[control
@@ -107,15 +107,15 @@
)))
(def: Null
- (for {@.php host.Null}
+ (for {@.php ffi.Null}
Any))
(def: Object
- (for {@.php (type (host.Object Any))}
+ (for {@.php (type (ffi.Object Any))}
Any))
(def: Function
- (for {@.php host.Function}
+ (for {@.php ffi.Function}
Any))
(def: object::new
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
index 458b6bcd5..265b0aef5 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
@@ -209,11 +209,11 @@
[(///analysis.bundle eval host_analysis)]))
state)])))
-(def: (announce_definition! name)
+(def: (announce_definition! name type)
(All [anchor expression directive]
- (-> Name (Operation anchor expression directive Any)))
+ (-> Name Type (Operation anchor expression directive Any)))
(/////directive.lift_generation
- (/////generation.log! (format "Definition " (%.name name)))))
+ (/////generation.log! (format "Definition " (%.name name) " : " (%.type type)))))
(def: (lux::def expander host_analysis)
(-> Expander /////analysis.Bundle Handler)
@@ -229,7 +229,7 @@
_ (/////directive.lift_analysis
(module.define short_name (#.Right [exported? type (:coerce Code annotations) value])))
_ (..refresh expander host_analysis)
- _ (..announce_definition! full_name)]
+ _ (..announce_definition! full_name type)]
(wrap /////directive.no_requirements))
_
@@ -252,7 +252,7 @@
[_ (module.define short_name (#.Right [exported? type annotations value]))]
(module.declare_tags tags exported? (:coerce Type value))))
_ (..refresh expander host_analysis)
- _ (..announce_definition! full_name)]
+ _ (..announce_definition! full_name type)]
(wrap /////directive.no_requirements)))]))
(def: imports
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux
index d5e831e09..304b79bdb 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux
@@ -11,7 +11,8 @@
["." product]
["." text ("#\." hash)
["%" format (#+ format)]
- ["." encoding]]
+ [encoding
+ ["." utf8]]]
[collection
["." list ("#\." functor)]
["." row]]]
@@ -605,4 +606,4 @@
(row.row [(%.nat ..module_id)
(|> ..runtime
_.code
- (\ encoding.utf8 encode))])])))
+ (\ utf8.codec encode))])])))