diff options
author | Eduardo Julian | 2017-11-09 14:19:54 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-09 14:19:54 -0400 |
commit | 63624fd6b7f9f2563898655472025020483d398f (patch) | |
tree | 8c3f2f3db00203621c86c07699ade7011918705c /new-luxc/source/luxc/lang/translation/procedure | |
parent | 0cb55507c100f6817225e644c2d19e73940edad6 (diff) |
- Fixed the tests.
- Fixed a few bugs.
- Can now translate recursion.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux index 7c049a99f..77ce7f6fa 100644 --- a/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux @@ -18,7 +18,8 @@ (lang ["la" analysis] ["ls" synthesis] (translation [";T" runtime] - [";T" case])))) + [";T" case] + [";T" function])))) (host;import java.lang.Long (#static MIN_VALUE Long) @@ -32,11 +33,11 @@ (#static NEGATIVE_INFINITY Double)) ## [Types] -(type: #export Generator +(type: #export Translator (-> ls;Synthesis (Meta $;Inst))) (type: #export Proc - (-> Generator (List ls;Synthesis) (Meta $;Inst))) + (-> Translator (List ls;Synthesis) (Meta $;Inst))) (type: #export Bundle (Dict Text Proc)) @@ -48,6 +49,7 @@ (type: #export Unary (-> (Vector +1 $;Inst) $;Inst)) (type: #export Binary (-> (Vector +2 $;Inst) $;Inst)) (type: #export Trinary (-> (Vector +3 $;Inst) $;Inst)) +(type: #export Variadic (-> (List $;Inst) $;Inst)) ## [Utils] (def: $Object $;Type ($t;class "java.lang.Object" (list))) @@ -100,6 +102,14 @@ (arity: binary +2) (arity: trinary +3) +(def: #export (variadic proc) + (-> Variadic (-> Text Proc)) + (function [proc-name] + (function [translate inputsS] + (do meta;Monad<Meta> + [inputsI (monad;map @ translate inputsS)] + (wrap (proc inputsI)))))) + ## [Instructions] (def: lux-intI $;Inst (|>. $i;I2L ($i;wrap #$;Long))) (def: jvm-intI $;Inst (|>. ($i;unwrap #$;Long) $i;L2I)) @@ -150,6 +160,12 @@ Unary valueI) +(def: lux//recur + (-> Text Proc) + (function [proc-name] + (function [translate inputsS] + (functionT;translate-recur translate inputsS)))) + ## [[Bits]] (do-template [<name> <op>] [(def: (<name> [inputI maskI]) @@ -363,7 +379,7 @@ [text//lt ($i;CHECKCAST "java.lang.String") ($i;CHECKCAST "java.lang.String") ($i;INVOKEVIRTUAL "java.lang.String" "compareTo" ($t;method (list $String) (#;Some $t;int) (list)) false) (predicateI $i;IF_ICMPEQ)] - [text//append ($i;CHECKCAST "java.lang.String") ($i;CHECKCAST "java.lang.String") + [text//concat ($i;CHECKCAST "java.lang.String") ($i;CHECKCAST "java.lang.String") ($i;INVOKEVIRTUAL "java.lang.String" "concat" ($t;method (list $String) (#;Some $String) (list)) false) id] [text//contains? ($i;CHECKCAST "java.lang.String") ($i;CHECKCAST "java.lang.String") @@ -544,6 +560,7 @@ (install "is" (binary lux//is)) (install "try" (unary lux//try)) (install "if" (trinary lux//if)) + (install "recur" lux//recur) )) (def: bit-procs @@ -630,7 +647,7 @@ (|> (dict;new text;Hash<Text>) (install "text =" (binary text//eq)) (install "text <" (binary text//lt)) - (install "text append" (binary text//append)) + (install "text concat" (binary text//concat)) (install "text index" (trinary text//index)) (install "text size" (unary text//size)) (install "text hash" (unary text//hash)) |