diff options
author | Eduardo Julian | 2017-11-06 22:03:42 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-06 22:03:42 -0400 |
commit | 0cb55507c100f6817225e644c2d19e73940edad6 (patch) | |
tree | 8e99d826fc51f052b086f0398b257176dcac11cc /new-luxc/source/luxc/lang/translation/procedure | |
parent | 69d3bdf98a5be8dd7aacc0b37bdbfcbf226faf62 (diff) |
- Fixed some bugs.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/procedure.jvm.lux | 7 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux | 51 |
2 files changed, 34 insertions, 24 deletions
diff --git a/new-luxc/source/luxc/lang/translation/procedure.jvm.lux b/new-luxc/source/luxc/lang/translation/procedure.jvm.lux index d74b559cf..82b7c5d44 100644 --- a/new-luxc/source/luxc/lang/translation/procedure.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/procedure.jvm.lux @@ -1,6 +1,7 @@ (;module: lux - (lux (control [monad #+ do]) + (lux (control [monad #+ do] + ["ex" exception #+ exception:]) (data [maybe] text/format (coll [dict]))) @@ -10,6 +11,8 @@ (. ["./;" common] ["./;" host])) +(exception: #export Unknown-Procedure) + (def: procedures ./common;Bundle (|> ./common;procedures @@ -18,7 +21,7 @@ (def: #export (translate-procedure translate name args) (-> (-> ls;Synthesis (Meta $;Inst)) Text (List ls;Synthesis) (Meta $;Inst)) - (<| (maybe;default (&;fail (format "Unknown procedure: " (%t name)))) + (<| (maybe;default (&;throw Unknown-Procedure name)) (do maybe;Monad<Maybe> [proc (dict;get name procedures)] (wrap (proc translate args))))) 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 8c7668383..7c049a99f 100644 --- a/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux @@ -17,7 +17,8 @@ ["$i" inst])) (lang ["la" analysis] ["ls" synthesis] - (translation [";T" runtime])))) + (translation [";T" runtime] + [";T" case])))) (host;import java.lang.Long (#static MIN_VALUE Long) @@ -133,14 +134,17 @@ rightI (predicateI $i;IF_ACMPEQ))) -(def: try-method - $;Method - ($t;method (list $Function) (#;Some $Object-Array) (list))) +(def: (lux//if [testI thenI elseI]) + Trinary + (caseT;translate-if testI thenI elseI)) + (def: (lux//try riskyI) Unary (|>. riskyI ($i;CHECKCAST hostL;function-class) - ($i;INVOKESTATIC hostL;runtime-class "try" try-method false))) + ($i;INVOKESTATIC hostL;runtime-class "try" + ($t;method (list $Function) (#;Some $Object-Array) (list)) + false))) (def: (lux//noop valueI) Unary @@ -536,9 +540,11 @@ (def: lux-procs Bundle (|> (dict;new text;Hash<Text>) - (install "lux noop" (unary lux//noop)) - (install "lux is" (binary lux//is)) - (install "lux try" (unary lux//try)))) + (install "noop" (unary lux//noop)) + (install "is" (binary lux//is)) + (install "try" (unary lux//try)) + (install "if" (trinary lux//if)) + )) (def: bit-procs Bundle @@ -691,17 +697,18 @@ (def: #export procedures Bundle - (|> (dict;new text;Hash<Text>) - (dict;merge lux-procs) - (dict;merge bit-procs) - (dict;merge nat-procs) - (dict;merge int-procs) - (dict;merge deg-procs) - (dict;merge frac-procs) - (dict;merge text-procs) - (dict;merge array-procs) - (dict;merge math-procs) - (dict;merge io-procs) - (dict;merge atom-procs) - (dict;merge process-procs) - )) + (<| (prefix "lux") + (|> (dict;new text;Hash<Text>) + (dict;merge lux-procs) + (dict;merge bit-procs) + (dict;merge nat-procs) + (dict;merge int-procs) + (dict;merge deg-procs) + (dict;merge frac-procs) + (dict;merge text-procs) + (dict;merge array-procs) + (dict;merge math-procs) + (dict;merge io-procs) + (dict;merge atom-procs) + (dict;merge process-procs) + ))) |