aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase')
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/common-lisp/function.lux3
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/js/function.lux3
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/jvm/primitive.lux6
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/jvm/reference.lux61
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/jvm/structure.lux4
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/jvm/value.lux9
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/lua/function.lux3
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/php/function.lux3
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/python/function.lux3
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/ruby/function.lux3
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/scheme/function.lux3
-rw-r--r--stdlib/source/lux/tool/compiler/phase/synthesis/function.lux3
12 files changed, 91 insertions, 13 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/common-lisp/function.lux b/stdlib/source/lux/tool/compiler/phase/generation/common-lisp/function.lux
index c8edd4e46..3dcc24448 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/common-lisp/function.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/common-lisp/function.lux
@@ -19,7 +19,8 @@
["#/" //
["." // #_
[reference (#+ Register Variable)]
- [analysis (#+ Variant Tuple Environment Arity Abstraction Application Analysis)]
+ [arity (#+ Arity)]
+ [analysis (#+ Variant Tuple Environment Abstraction Application Analysis)]
[synthesis (#+ Synthesis)]]]]])
(def: #export (apply generate [functionS argsS+])
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/js/function.lux b/stdlib/source/lux/tool/compiler/phase/generation/js/function.lux
index a0418b839..ec48162c5 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/js/function.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/js/function.lux
@@ -19,7 +19,8 @@
["#/" // ("#@." monad)
["." // #_
[reference (#+ Register Variable)]
- [analysis (#+ Variant Tuple Environment Arity Abstraction Application Analysis)]
+ [arity (#+ Arity)]
+ [analysis (#+ Variant Tuple Environment Abstraction Application Analysis)]
[synthesis (#+ Synthesis)]]]]])
(def: #export (apply generate [functionS argsS+])
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/primitive.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/primitive.lux
index 2807487ae..27a02d7b4 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/primitive.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/primitive.lux
@@ -24,11 +24,11 @@
(do _.monad
[_ (`` (|> value (~~ (template.splice <ldc>))))]
(_.invokestatic <class> "valueOf"
- (list <inputD>)
- (|.object <class>))))]
+ [(list <inputD>)
+ (|.object <class>)])))]
[i64 (I64 Any) [.int constant.long _.ldc/long] "java.lang.Long" |.long]
- [f64 Frac [constant.double _.ldc/double] "java.lang.Double" |.double]
+ [f64 Frac [constant.double _.ldc/double] "java.lang.Double" |.double]
)
(def: #export text _.ldc/string)
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/reference.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/reference.lux
new file mode 100644
index 000000000..3e6738df0
--- /dev/null
+++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/reference.lux
@@ -0,0 +1,61 @@
+(.module:
+ [lux #*
+ [abstract
+ [monad (#+ do)]]
+ [data
+ [text
+ ["%" format (#+ format)]]]
+ [tool
+ [compiler
+ ["." reference (#+ Register Variable)]
+ ["." phase ("operation@." monad)
+ ["." generation]]]]
+ [target
+ [jvm
+ ["_" instruction (#+ Instruction)]
+ [encoding
+ ["." unsigned]]]]]
+ ["." // #_
+ [runtime (#+ Operation)]
+ ["#." value]])
+
+(def: #export this
+ (Instruction Any)
+ (_.aload (unsigned.u1 0)))
+
+(template [<name> <prefix>]
+ [(def: #export <name>
+ (-> Register Text)
+ (|>> %.nat (format <prefix>)))]
+
+ [foreign-name "f"]
+ [partial-name "p"]
+ )
+
+(def: (foreign variable)
+ (-> Register (Operation (Instruction Any)))
+ (do phase.monad
+ [function-class generation.context]
+ (wrap ($_ _.compose
+ ..this
+ (_.getfield function-class (..foreign-name variable)
+ //value.type)))))
+
+(def: local
+ (-> Register (Instruction Any))
+ (|>> unsigned.u1 _.aload))
+
+(def: #export (variable variable)
+ (-> Variable (Operation (Instruction Any)))
+ (case variable
+ (#reference.Local variable)
+ (operation@wrap (..local variable))
+
+ (#reference.Foreign variable)
+ (..foreign variable)))
+
+(def: #export (constant name)
+ (-> Name (Operation (Instruction Any)))
+ (do phase.monad
+ [bytecode-name (generation.remember name)]
+ (wrap (_.getstatic bytecode-name //value.field //value.type))))
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/structure.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/structure.lux
index 1282ac245..8b2c6c270 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/structure.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/structure.lux
@@ -70,5 +70,5 @@
_ (flagG right?)
_ valueI]
(_.invokestatic //runtime.class "variant"
- (list |.int $Object $Object)
- (|.array $Object))))))
+ [(list |.int $Object $Object)
+ (|.array $Object)])))))
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/value.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/value.lux
new file mode 100644
index 000000000..a598b9997
--- /dev/null
+++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/value.lux
@@ -0,0 +1,9 @@
+(.module:
+ [lux (#- type)
+ [target
+ [jvm
+ ["." descriptor (#+ Descriptor Value)]]]])
+
+(def: #export field "_value")
+
+(def: #export type (Descriptor (Value Any)) (descriptor.object "java.lang.Object"))
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/lua/function.lux b/stdlib/source/lux/tool/compiler/phase/generation/lua/function.lux
index eb0a5e71b..7bac2e107 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/lua/function.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/lua/function.lux
@@ -19,7 +19,8 @@
["#/" //
["." // #_
[reference (#+ Register Variable)]
- [analysis (#+ Variant Tuple Environment Arity Abstraction Application Analysis)]
+ [arity (#+ Arity)]
+ [analysis (#+ Variant Tuple Environment Abstraction Application Analysis)]
[synthesis (#+ Synthesis)]]]]])
(def: #export (apply generate [functionS argsS+])
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/php/function.lux b/stdlib/source/lux/tool/compiler/phase/generation/php/function.lux
index 8dfb9668e..6e75f37bc 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/php/function.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/php/function.lux
@@ -20,7 +20,8 @@
["#/" //
["." // #_
[reference (#+ Register Variable)]
- [analysis (#+ Variant Tuple Environment Arity Abstraction Application Analysis)]
+ [arity (#+ Arity)]
+ [analysis (#+ Variant Tuple Environment Abstraction Application Analysis)]
[synthesis (#+ Synthesis)]]]]])
(def: #export (apply generate [functionS argsS+])
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/python/function.lux b/stdlib/source/lux/tool/compiler/phase/generation/python/function.lux
index c70ca9c37..ed6e53274 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/python/function.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/python/function.lux
@@ -19,7 +19,8 @@
["#/" //
["." // #_
[reference (#+ Register Variable)]
- [analysis (#+ Variant Tuple Environment Arity Abstraction Application Analysis)]
+ [arity (#+ Arity)]
+ [analysis (#+ Variant Tuple Environment Abstraction Application Analysis)]
[synthesis (#+ Synthesis)]]]]])
(def: #export (apply generate [functionS argsS+])
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/ruby/function.lux b/stdlib/source/lux/tool/compiler/phase/generation/ruby/function.lux
index ef3920d23..02e221894 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/ruby/function.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/ruby/function.lux
@@ -19,7 +19,8 @@
["#/" //
["." // #_
[reference (#+ Register Variable)]
- [analysis (#+ Variant Tuple Environment Arity Abstraction Application Analysis)]
+ [arity (#+ Arity)]
+ [analysis (#+ Variant Tuple Environment Abstraction Application Analysis)]
[synthesis (#+ Synthesis)]]]]])
(def: #export (apply generate [functionS argsS+])
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/scheme/function.lux b/stdlib/source/lux/tool/compiler/phase/generation/scheme/function.lux
index 41a2e6b17..797e31e1d 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/scheme/function.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/scheme/function.lux
@@ -21,7 +21,8 @@
["#/" // ("#;." monad)
["#/" // #_
[reference (#+ Register Variable)]
- [analysis (#+ Variant Tuple Environment Arity Abstraction Application Analysis)]
+ [arity (#+ Arity)]
+ [analysis (#+ Variant Tuple Environment Abstraction Application Analysis)]
[synthesis (#+ Synthesis)]]]]])
(def: #export (apply generate [functionS argsS+])
diff --git a/stdlib/source/lux/tool/compiler/phase/synthesis/function.lux b/stdlib/source/lux/tool/compiler/phase/synthesis/function.lux
index dbcc56e38..4e09f08e9 100644
--- a/stdlib/source/lux/tool/compiler/phase/synthesis/function.lux
+++ b/stdlib/source/lux/tool/compiler/phase/synthesis/function.lux
@@ -15,8 +15,9 @@
["#." loop (#+ Transform)]
["#/" // ("#;." monad)
["#/" // #_
+ [arity (#+ Arity)]
["#." reference (#+ Register Variable)]
- ["#." analysis (#+ Environment Arity Analysis)]
+ ["#." analysis (#+ Environment Analysis)]
["/" synthesis (#+ Path Synthesis Operation Phase)]]]])
(exception: #export (cannot-find-foreign-variable-in-environment {foreign Register} {environment Environment})