aboutsummaryrefslogtreecommitdiff
path: root/lux-jvm
diff options
context:
space:
mode:
authorEduardo Julian2022-03-15 07:24:35 -0400
committerEduardo Julian2022-03-15 07:24:35 -0400
commitbc36487224f670c23002cc4575c0dba3e5dc1be1 (patch)
tree01601f7e5d992ace77a16cfa90240ffc4511a7af /lux-jvm
parent4ef1ac1dfe0edd1a11bb7f1fd13c8b6cb8f1bab4 (diff)
De-sigil-ification: ^
Diffstat (limited to 'lux-jvm')
-rw-r--r--lux-jvm/commands.md2
-rw-r--r--lux-jvm/source/luxc/lang/directive/jvm.lux40
-rw-r--r--lux-jvm/source/luxc/lang/synthesis/variable.lux100
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/case.lux18
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/expression.lux74
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux69
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/loop.lux56
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/primitive.lux12
8 files changed, 139 insertions, 232 deletions
diff --git a/lux-jvm/commands.md b/lux-jvm/commands.md
index aa3299ac9..d533fd351 100644
--- a/lux-jvm/commands.md
+++ b/lux-jvm/commands.md
@@ -40,7 +40,7 @@ cd ~/lux/stdlib/ \
```
cd ~/lux/lux-jvm/ \
-&& mvn install:install-file -Dfile=target/program.jar -DgroupId=com.github.luxlang -DartifactId=lux-jvm -Dversion=0.6.6 -Dpackaging=jar
+&& mvn install:install-file -Dfile=target/program.jar -DgroupId=com.github.luxlang -DartifactId=lux-jvm -Dversion=0.7.0-SNAPSHOT -Dpackaging=jar
cd ~/lux/lux-jvm/ && mvn deploy:deploy-file \
-Durl=https://USERNAME:PASSWORD@oss.sonatype.org/content/repositories/snapshots/ \
diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux
index 323c337d5..f125192f5 100644
--- a/lux-jvm/source/luxc/lang/directive/jvm.lux
+++ b/lux-jvm/source/luxc/lang/directive/jvm.lux
@@ -22,6 +22,8 @@
["[0]" dictionary {"+" Dictionary}]
["[0]" sequence {"+" Sequence} ("[1]#[0]" functor mix)]
["[0]" set {"+" Set}]]]
+ [macro
+ ["^" pattern]]
[math
[number
["[0]" nat]]]
@@ -254,7 +256,7 @@
(def: (object instruction)
(-> /.Object Inst)
(case instruction
- (^template [<tag> <inst>]
+ (^.template [<tag> <inst>]
[{<tag> class field_name field_type}
(<inst> class field_name field_type)])
([/.#GETSTATIC _.GETSTATIC]
@@ -267,7 +269,7 @@
{/.#INSTANCEOF type} (_.INSTANCEOF type)
{/.#CHECKCAST type} (_.CHECKCAST type)
- (^template [<tag> <inst>]
+ (^.template [<tag> <inst>]
[{<tag> class method_name method_type}
(<inst> class method_name method_type)])
([/.#INVOKEINTERFACE _.INVOKEINTERFACE]
@@ -434,7 +436,7 @@
(def: (relabel_branching [mapping instruction])
(Re_labeler /.Branching)
(case instruction
- (^template [<tag>]
+ (^.template [<tag>]
[{<tag> label}
(let [[mapping label] (..relabel [mapping label])]
[mapping {<tag> label}])])
@@ -476,7 +478,7 @@
(def: (relabel_control [mapping instruction])
(Re_labeler /.Control)
(case instruction
- (^template [<tag> <relabel>]
+ (^.template [<tag> <relabel>]
[{<tag> instruction}
(let [[mapping instruction] (<relabel> [mapping instruction])]
[mapping {<tag> instruction}])])
@@ -484,7 +486,7 @@
[/.#Branching ..relabel_branching]
[/.#Exception ..relabel_exception])
- (^template [<tag>]
+ (^.template [<tag>]
[{<tag> instruction}
[mapping {<tag> instruction}]])
([/.#Concurrency] [/.#Return])
@@ -499,7 +501,7 @@
{/.#NOP}
[mapping {/.#NOP}]
- (^template [<tag>]
+ (^.template [<tag>]
[{<tag> instruction}
[mapping {<tag> instruction}]])
([/.#Constant]
@@ -568,7 +570,7 @@
(-> jvm.Extender ..Handler)
(function (handler extension_name phase archive inputsC+)
(case inputsC+
- (^ (list nameC valueC))
+ (pattern (list nameC valueC))
(do phase.monad
[[_ _ name] (lux/.evaluate! archive Text nameC)
[_ handlerV] (lux/.generator archive (:as Text name) ..Handler' valueC)
@@ -740,15 +742,15 @@
(in (cache.all (list& body_dependencies all_super_ctor_dependencies))))
- (^or {#Override [[parent_name parent_variables] name strict_floating_point? annotations variables
+ (^.or {#Override [[parent_name parent_variables] name strict_floating_point? annotations variables
+ self arguments return exceptions
+ body]}
+ {#Virtual [name privacy final? strict_floating_point? annotations variables
self arguments return exceptions
body]}
- {#Virtual [name privacy final? strict_floating_point? annotations variables
- self arguments return exceptions
- body]}
- {#Static [name privacy strict_floating_point? annotations variables
- arguments return exceptions
- body]})
+ {#Static [name privacy strict_floating_point? annotations variables
+ arguments return exceptions
+ body]})
(cache.dependencies archive body)
{#Abstract _}
@@ -1204,7 +1206,7 @@
(in [privacy strict_floating_point? annotations method_tvars exceptions
self arguments constructor_argumentsS
(case bodyS
- (^ (method_body bodyS))
+ (pattern (method_body bodyS))
bodyS
_
@@ -1223,7 +1225,7 @@
(in [[super_name super_tvars] method_name strict_floating_point? annotations
method_tvars self arguments returnJ exceptionsJ
(case bodyS
- (^ (method_body bodyS))
+ (pattern (method_body bodyS))
bodyS
_
@@ -1242,7 +1244,7 @@
(in [name privacy final? strict_floating_point? annotations method_tvars
self arguments returnJ exceptionsJ
(case bodyS
- (^ (method_body bodyS))
+ (pattern (method_body bodyS))
bodyS
_
@@ -1261,7 +1263,7 @@
(in [name privacy strict_floating_point? annotations method_tvars
arguments returnJ exceptionsJ
(case bodyS
- (^ (method_body bodyS))
+ (pattern (method_body bodyS))
bodyS
_
@@ -1500,7 +1502,7 @@
(list#each ..constraint type_variables)
supers
(|> method_declarations
- (list#each (function (_ (^open "_[0]"))
+ (list#each (function (_ (open "_[0]"))
(def.abstract_method {jvm.#Public} jvm.noneM _#name
(/type.method [_#type_variables _#arguments _#return _#exceptions]))))
def.fuse))]]]
diff --git a/lux-jvm/source/luxc/lang/synthesis/variable.lux b/lux-jvm/source/luxc/lang/synthesis/variable.lux
deleted file mode 100644
index f1ea56e27..000000000
--- a/lux-jvm/source/luxc/lang/synthesis/variable.lux
+++ /dev/null
@@ -1,100 +0,0 @@
-(.using
- lux
- (lux (data [library
- [number]]
- (coll [list "list/" Mix<List> Monoid<List>]
- ["s" set])))
- (luxc (lang ["la" analysis]
- ["ls" synthesis]
- ["[0]L" variable {"+" Variable}])))
-
-(def: (bound-vars path)
- (-> ls.Path (List Variable))
- (case path
- {ls.#BindP register}
- (list (.int register))
-
- (^or {ls.#SeqP pre post}
- {ls.#AltP pre post})
- (list/composite (bound-vars pre) (bound-vars post))
-
- _
- (list)))
-
-(def: (path-bodies path)
- (-> ls.Path (List ls.Synthesis))
- (case path
- {ls.#ExecP body}
- (list body)
-
- {ls.#SeqP pre post}
- (path-bodies post)
-
- {ls.#AltP pre post}
- (list/composite (path-bodies pre) (path-bodies post))
-
- _
- (list)))
-
-(def: (non-arg? arity var)
- (-> ls.Arity Variable Bit)
- (and (variableL.local? var)
- (n/> arity (.nat var))))
-
-(type: Tracker (s.Set Variable))
-
-(def: init-tracker Tracker (s.new number.Hash<Int>))
-
-(def: (unused-vars current-arity bound exprS)
- (-> ls.Arity (List Variable) ls.Synthesis (List Variable))
- (let [tracker (loop [exprS exprS
- tracker (list/mix s.has init-tracker bound)]
- (case exprS
- {ls.#Variable var}
- (if (non-arg? current-arity var)
- (s.lacks var tracker)
- tracker)
-
- {ls.#Variant tag last? memberS}
- (again memberS tracker)
-
- {ls.#Tuple membersS}
- (list/mix again tracker membersS)
-
- {ls.#Call funcS argsS}
- (list/mix again (again funcS tracker) argsS)
-
- (^or {ls.#Again argsS}
- {ls.#Procedure name argsS})
- (list/mix again tracker argsS)
-
- {ls.#Let offset inputS outputS}
- (|> tracker (again inputS) (again outputS))
-
- {ls.#If testS thenS elseS}
- (|> tracker (again testS) (again thenS) (again elseS))
-
- {ls.#Loop offset initsS bodyS}
- (again bodyS (list/mix again tracker initsS))
-
- {ls.#Case inputS outputPS}
- (let [tracker' (list/mix s.has
- (again inputS tracker)
- (bound-vars outputPS))]
- (list/mix again tracker' (path-bodies outputPS)))
-
- {ls.#Function arity env bodyS}
- (list/mix s.lacks tracker env)
-
- _
- tracker
- ))]
- (s.to-list tracker)))
-
-... (def: (optimize-register-use current-arity [pathS bodyS])
-... (-> ls.Arity [ls.Path ls.Synthesis] [ls.Path ls.Synthesis])
-... (let [bound (bound-vars pathS)
-... unused (unused-vars current-arity bound bodyS)
-... adjusted (adjust-vars unused bound)]
-... [(|> pathS (clean-pattern adjusted) simplify-pattern)
-... (clean-expression adjusted bodyS)]))
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/case.lux b/lux-jvm/source/luxc/lang/translation/jvm/case.lux
index 9a5172966..8e90b4510 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/case.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/case.lux
@@ -9,6 +9,8 @@
[data
[collection
["[0]" list ("[1]@[0]" mix)]]]
+ [macro
+ ["^" pattern]]
[math
[number
["n" nat]]]
@@ -128,7 +130,7 @@
(_.label @else)
elseG))))
- (^template [<tag> <unwrap> <dup> <pop> <test> <comparison> <if>]
+ (^.template [<tag> <unwrap> <dup> <pop> <test> <comparison> <if>]
[{<tag> cons}
(do [@ phase.monad]
[forkG (: (Operation Inst)
@@ -163,8 +165,8 @@
bodyI
(_.GOTO @end))))
- (^template [<pattern> <right?>]
- [(^ (<pattern> lefts))
+ (^.template [<pattern> <right?>]
+ [(pattern (<pattern> lefts))
(operation@in (<| _.with_label (function (_ @success))
_.with_label (function (_ @fail))
(|>> peekI
@@ -184,15 +186,15 @@
[synthesis.side/right true])
... Extra optimization
- (^template [<path> <projection>]
- [(^ (<path> lefts))
+ (^.template [<path> <projection>]
+ [(pattern (<path> lefts))
(operation@in (|>> peekI
(<projection> lefts)
pushI))
- (^ (synthesis.path/seq
- (<path> lefts)
- (synthesis.!bind_top register thenP)))
+ (pattern (synthesis.path/seq
+ (<path> lefts)
+ (synthesis.!bind_top register thenP)))
(do phase.monad
[then! (path' stack_depth @else @end phase archive thenP)]
(in (|>> peekI
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/expression.lux b/lux-jvm/source/luxc/lang/translation/jvm/expression.lux
index 8749b2ef2..692835dc4 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/expression.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/expression.lux
@@ -1,77 +1,77 @@
(.using
- [library
- [lux "*"
- [tool
- [compiler
- [language
- [lux
- ["[0]" synthesis]
- [phase
- ["[0]" extension]]]]]]]]
- [luxc
- [lang
- [host
- [jvm {"+" Phase}]]]]
- [//
- ["[0]" primitive]
- ["[0]" structure]
- ["[0]" reference]
- ["[0]" case]
- ["[0]" loop]
- ["[0]" function]])
+ [library
+ [lux "*"
+ [tool
+ [compiler
+ [language
+ [lux
+ ["[0]" synthesis]
+ [phase
+ ["[0]" extension]]]]]]]]
+ [luxc
+ [lang
+ [host
+ [jvm {"+" Phase}]]]]
+ [//
+ ["[0]" primitive]
+ ["[0]" structure]
+ ["[0]" reference]
+ ["[0]" case]
+ ["[0]" loop]
+ ["[0]" function]])
(def: .public (translate archive synthesis)
Phase
(case synthesis
- (^ (synthesis.bit value))
+ (pattern (synthesis.bit value))
(primitive.bit value)
- (^ (synthesis.i64 value))
+ (pattern (synthesis.i64 value))
(primitive.i64 value)
- (^ (synthesis.f64 value))
+ (pattern (synthesis.f64 value))
(primitive.f64 value)
- (^ (synthesis.text value))
+ (pattern (synthesis.text value))
(primitive.text value)
- (^ (synthesis.variant data))
+ (pattern (synthesis.variant data))
(structure.variant translate archive data)
- (^ (synthesis.tuple members))
+ (pattern (synthesis.tuple members))
(structure.tuple translate archive members)
- (^ (synthesis.variable variable))
+ (pattern (synthesis.variable variable))
(reference.variable archive variable)
- (^ (synthesis.constant constant))
+ (pattern (synthesis.constant constant))
(reference.constant archive constant)
- (^ (synthesis.branch/exec it))
+ (pattern (synthesis.branch/exec it))
(case.exec translate archive it)
- (^ (synthesis.branch/let data))
+ (pattern (synthesis.branch/let data))
(case.let translate archive data)
- (^ (synthesis.branch/if data))
+ (pattern (synthesis.branch/if data))
(case.if translate archive data)
- (^ (synthesis.branch/get data))
+ (pattern (synthesis.branch/get data))
(case.get translate archive data)
- (^ (synthesis.branch/case data))
+ (pattern (synthesis.branch/case data))
(case.case translate archive data)
- (^ (synthesis.loop/again data))
+ (pattern (synthesis.loop/again data))
(loop.again translate archive data)
- (^ (synthesis.loop/scope data))
+ (pattern (synthesis.loop/scope data))
(loop.scope translate archive data)
- (^ (synthesis.function/apply data))
+ (pattern (synthesis.function/apply data))
(function.call translate archive data)
- (^ (synthesis.function/abstraction data))
+ (pattern (synthesis.function/abstraction data))
(function.function translate archive data)
{synthesis.#Extension extension}
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
index ee6f243f2..0ea499e92 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
@@ -20,6 +20,7 @@
["[0]" dictionary {"+" Dictionary}]
["[0]" set {"+" Set}]]]
[macro
+ ["^" pattern]
["[0]" template]]
[math
[number
@@ -389,7 +390,7 @@
(-> (Type Primitive) Handler)
(function (_ extension_name generate archive inputs)
(case inputs
- (^ (list lengthS))
+ (pattern (list lengthS))
(do phase.monad
[lengthI (generate archive lengthS)]
(in (|>> lengthI
@@ -412,7 +413,7 @@
(-> (Type Primitive) Inst Handler)
(function (_ extension_name generate archive inputs)
(case inputs
- (^ (list idxS arrayS))
+ (pattern (list idxS arrayS))
(do phase.monad
[arrayI (generate archive arrayS)
idxI (generate archive idxS)]
@@ -441,7 +442,7 @@
(-> (Type Primitive) Inst Handler)
(function (_ extension_name generate archive inputs)
(case inputs
- (^ (list idxS valueS arrayS))
+ (pattern (list idxS valueS arrayS))
(do phase.monad
[arrayI (generate archive arrayS)
idxI (generate archive idxS)
@@ -558,7 +559,7 @@
(def: (object::class extension_name generate archive inputs)
Handler
(case inputs
- (^ (list (synthesis.text class)))
+ (pattern (list (synthesis.text class)))
(do phase.monad
[]
(in (|>> (_.string class)
@@ -581,7 +582,7 @@
(def: (object::cast extension_name generate archive inputs)
Handler
(case inputs
- (^ (list (synthesis.text from) (synthesis.text to) valueS))
+ (pattern (list (synthesis.text from) (synthesis.text to) valueS))
(do phase.monad
[valueI (generate archive valueS)]
(`` (cond (~~ (template [<object> <primitive>]
@@ -835,14 +836,14 @@
[_ {synthesis.#Control {synthesis.#Branch {synthesis.#Case _ path}}}]
(loop [path (: synthesis.Path path)]
(case path
- (^or {synthesis.#Pop}
- {synthesis.#Access _}
- {synthesis.#Bind _}
- {synthesis.#Bit_Fork _}
- {synthesis.#I64_Fork _}
- {synthesis.#F64_Fork _}
- {synthesis.#Text_Fork _}
- {synthesis.#Alt _})
+ (^.or {synthesis.#Pop}
+ {synthesis.#Access _}
+ {synthesis.#Bind _}
+ {synthesis.#Bit_Fork _}
+ {synthesis.#I64_Fork _}
+ {synthesis.#F64_Fork _}
+ {synthesis.#Text_Fork _}
+ {synthesis.#Alt _})
body
{synthesis.#Seq _ next}
@@ -884,17 +885,17 @@
(-> Path Path))
(function (again path)
(case path
- (^ (synthesis.path/then bodyS))
+ (pattern (synthesis.path/then bodyS))
(synthesis.path/then (normalize bodyS))
- (^template [<tag>]
- [(^ {<tag> leftP rightP})
+ (^.template [<tag>]
+ [(pattern {<tag> leftP rightP})
{<tag> (again leftP) (again rightP)}])
([synthesis.#Alt]
[synthesis.#Seq])
- (^template [<tag>]
- [(^ {<tag> _})
+ (^.template [<tag>]
+ [(pattern {<tag> _})
path])
([synthesis.#Pop]
[synthesis.#Bind]
@@ -903,7 +904,7 @@
{synthesis.#Bit_Fork when then else}
{synthesis.#Bit_Fork when (again then) (maybe#each again else)}
- (^template [<tag>]
+ (^.template [<tag>]
[{<tag> [[test then] elses]}
{<tag> [[test (again then)]
(list#each (function (_ [else_test else_then])
@@ -939,49 +940,49 @@
(-> Mapping Synthesis Synthesis)
(function (again body)
(case body
- (^template [<tag>]
- [(^ <tag>)
+ (^.template [<tag>]
+ [(pattern <tag>)
body])
([{synthesis.#Primitive _}]
[(synthesis.constant _)])
- (^ (synthesis.variant [lefts right? sub]))
+ (pattern (synthesis.variant [lefts right? sub]))
(synthesis.variant [lefts right? (again sub)])
- (^ (synthesis.tuple members))
+ (pattern (synthesis.tuple members))
(synthesis.tuple (list#each again members))
- (^ (synthesis.variable var))
+ (pattern (synthesis.variable var))
(|> mapping
(dictionary.value body)
(maybe.else var)
synthesis.variable)
- (^ (synthesis.branch/case [inputS pathS]))
+ (pattern (synthesis.branch/case [inputS pathS]))
(synthesis.branch/case [(again inputS) (normalize_path again pathS)])
- (^ (synthesis.branch/exec [this that]))
+ (pattern (synthesis.branch/exec [this that]))
(synthesis.branch/exec [(again this) (again that)])
- (^ (synthesis.branch/let [inputS register outputS]))
+ (pattern (synthesis.branch/let [inputS register outputS]))
(synthesis.branch/let [(again inputS) register (again outputS)])
- (^ (synthesis.branch/if [testS thenS elseS]))
+ (pattern (synthesis.branch/if [testS thenS elseS]))
(synthesis.branch/if [(again testS) (again thenS) (again elseS)])
- (^ (synthesis.branch/get [path recordS]))
+ (pattern (synthesis.branch/get [path recordS]))
(synthesis.branch/get [path (again recordS)])
- (^ (synthesis.loop/scope [offset initsS+ bodyS]))
+ (pattern (synthesis.loop/scope [offset initsS+ bodyS]))
(synthesis.loop/scope [offset (list#each again initsS+) (again bodyS)])
- (^ (synthesis.loop/again updatesS+))
+ (pattern (synthesis.loop/again updatesS+))
(synthesis.loop/again (list#each again updatesS+))
- (^ (synthesis.function/abstraction [environment arity bodyS]))
+ (pattern (synthesis.function/abstraction [environment arity bodyS]))
(synthesis.function/abstraction [(list#each (function (_ captured)
(case captured
- (^ (synthesis.variable var))
+ (pattern (synthesis.variable var))
(|> mapping
(dictionary.value captured)
(maybe.else var)
@@ -993,7 +994,7 @@
arity
bodyS])
- (^ (synthesis.function/apply [functionS inputsS+]))
+ (pattern (synthesis.function/apply [functionS inputsS+]))
(synthesis.function/apply [(again functionS) (list#each again inputsS+)])
{synthesis.#Extension [name inputsS+]}
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/loop.lux b/lux-jvm/source/luxc/lang/translation/jvm/loop.lux
index 7c4c0fd36..92b8c0286 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/loop.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/loop.lux
@@ -1,36 +1,36 @@
(.using
- [library
- [lux "*"
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" function]]
- [data
- [collection
- ["[0]" list ("[1]@[0]" functor monoid)]]]
- [math
- [number
- ["n" nat]]]
- [tool
- [compiler
- ["[0]" phase]
- [reference
- [variable {"+" Register}]]
- [language
- [lux
- ["[0]" synthesis {"+" Synthesis}]
- ["[0]" generation]]]]]]]
- [luxc
- [lang
- [host
- [jvm {"+" Inst Operation Phase Generator}
- ["_" inst]]]]]
- ["[0]" //])
+ [library
+ [lux "*"
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" function]]
+ [data
+ [collection
+ ["[0]" list ("[1]@[0]" functor monoid)]]]
+ [math
+ [number
+ ["n" nat]]]
+ [tool
+ [compiler
+ ["[0]" phase]
+ [reference
+ [variable {"+" Register}]]
+ [language
+ [lux
+ ["[0]" synthesis {"+" Synthesis}]
+ ["[0]" generation]]]]]]]
+ [luxc
+ [lang
+ [host
+ [jvm {"+" Inst Operation Phase Generator}
+ ["_" inst]]]]]
+ ["[0]" //])
(def: (invariant? expected actual)
(-> Register Synthesis Bit)
(case actual
- (^ (synthesis.variable/local actual))
+ (pattern (synthesis.variable/local actual))
(n.= expected actual)
_
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
index 016639f2e..49bc10ff3 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
@@ -2,6 +2,8 @@
[library
[lux {"-" i64}
["[0]" ffi {"+" import:}]
+ [macro
+ ["^" pattern]]
[math
[number
["i" int]]]
@@ -36,13 +38,13 @@
(def: .public (i64 value)
(-> (I64 Any) (Operation Inst))
(case (.int value)
- (^template [<int> <instruction>]
+ (^.template [<int> <instruction>]
[<int>
(operation@in (|>> <instruction> (_.wrap type.long)))])
([+0 _.LCONST_0]
[+1 _.LCONST_1])
- (^template [<int> <instruction>]
+ (^.template [<int> <instruction>]
[<int>
(operation@in (|>> <instruction> _.I2L (_.wrap type.long)))])
([-1 _.ICONST_M1]
@@ -77,17 +79,17 @@
(def: .public (f64 value)
(-> Frac (Operation Inst))
(case value
- (^template [<int> <instruction>]
+ (^.template [<int> <instruction>]
[<int>
(operation@in (|>> <instruction> (_.wrap type.double)))])
([+1.0 _.DCONST_1])
- (^template [<int> <instruction>]
+ (^.template [<int> <instruction>]
[<int>
(operation@in (|>> <instruction> _.F2D (_.wrap type.double)))])
([+2.0 _.FCONST_2])
- (^template [<int> <instruction>]
+ (^.template [<int> <instruction>]
[<int>
(operation@in (|>> <instruction> _.I2D (_.wrap type.double)))])
([-1.0 _.ICONST_M1]