diff options
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/eval.lux | 12 | ||||
-rw-r--r-- | new-luxc/source/luxc/host.jvm.lux | 25 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/expression.lux | 8 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation.lux (renamed from new-luxc/source/luxc/generator.lux) | 30 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/case.jvm.lux (renamed from new-luxc/source/luxc/generator/case.jvm.lux) | 0 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/common.jvm.lux (renamed from new-luxc/source/luxc/generator/common.jvm.lux) | 0 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/eval.jvm.lux (renamed from new-luxc/source/luxc/generator/eval.jvm.lux) | 23 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/expression.jvm.lux (renamed from new-luxc/source/luxc/generator/expression.jvm.lux) | 52 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/function.jvm.lux (renamed from new-luxc/source/luxc/generator/function.jvm.lux) | 30 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/primitive.jvm.lux (renamed from new-luxc/source/luxc/generator/primitive.jvm.lux) | 4 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/procedure.jvm.lux (renamed from new-luxc/source/luxc/generator/procedure.jvm.lux) | 0 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux (renamed from new-luxc/source/luxc/generator/procedure/common.jvm.lux) | 13 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux (renamed from new-luxc/source/luxc/generator/procedure/host.jvm.lux) | 4 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/reference.jvm.lux (renamed from new-luxc/source/luxc/generator/reference.jvm.lux) | 14 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/runtime.jvm.lux (renamed from new-luxc/source/luxc/generator/runtime.jvm.lux) | 14 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/statement.jvm.lux (renamed from new-luxc/source/luxc/generator/statement.jvm.lux) | 16 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/structure.jvm.lux (renamed from new-luxc/source/luxc/generator/structure.jvm.lux) | 4 | ||||
-rw-r--r-- | new-luxc/source/program.lux | 4 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/common.lux | 4 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/analysis/procedure/host.jvm.lux | 4 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/analysis/type.lux | 4 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/case.lux (renamed from new-luxc/test/test/luxc/generator/case.lux) | 24 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/function.lux (renamed from new-luxc/test/test/luxc/generator/function.lux) | 28 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/primitive.lux (renamed from new-luxc/test/test/luxc/generator/primitive.lux) | 22 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/procedure/common.jvm.lux (renamed from new-luxc/test/test/luxc/generator/procedure/common.jvm.lux) | 112 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/procedure/host.jvm.lux (renamed from new-luxc/test/test/luxc/generator/procedure/host.jvm.lux) | 158 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/reference.lux (renamed from new-luxc/test/test/luxc/generator/reference.lux) | 38 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/structure.lux (renamed from new-luxc/test/test/luxc/generator/structure.lux) | 34 | ||||
-rw-r--r-- | new-luxc/test/tests.lux | 16 |
29 files changed, 347 insertions, 350 deletions
diff --git a/new-luxc/source/luxc/eval.lux b/new-luxc/source/luxc/eval.lux index baac56c64..82c355151 100644 --- a/new-luxc/source/luxc/eval.lux +++ b/new-luxc/source/luxc/eval.lux @@ -3,10 +3,10 @@ (lux (control [monad #+ do]) [meta]) (luxc (lang (analysis [";A" expression]) - (synthesis [";S" expression]))) - [../base] - (.. (generator [";G" expression] - [eval]))) + (synthesis [";S" expression]) + (translation [";T" expression] + [";T" eval]))) + [../base]) (def: #export (eval type exprC) ../base;Eval @@ -14,5 +14,5 @@ [exprA (../base;with-expected-type type (expressionA;analyser eval exprC)) #let [exprS (expressionS;synthesize exprA)] - exprI (expressionG;generate exprS)] - (eval;eval exprI))) + exprI (expressionT;generate exprS)] + (evalT;eval exprI))) diff --git a/new-luxc/source/luxc/host.jvm.lux b/new-luxc/source/luxc/host.jvm.lux index b74c9748c..2cbdf5883 100644 --- a/new-luxc/source/luxc/host.jvm.lux +++ b/new-luxc/source/luxc/host.jvm.lux @@ -11,8 +11,7 @@ [host #+ do-to object] [io]) (luxc ["&" base] - (generator ["&&;" common]) - )) + (lang (translation [";T" common])))) (host;import java.lang.reflect.AccessibleObject (setAccessible [boolean] void)) @@ -48,7 +47,7 @@ (error! error))) (def: (define-class class-name byte-code loader) - (-> Text &&common;Bytecode ClassLoader (e;Error Object)) + (-> Text commonT;Bytecode ClassLoader (e;Error Object)) (Method.invoke [loader (array;from-list (list (:! Object class-name) (:! Object byte-code) @@ -57,11 +56,11 @@ ClassLoader::defineClass)) (def: (fetch-byte-code class-name store) - (-> Text &&common;Class-Store (Maybe &&common;Bytecode)) + (-> Text commonT;Class-Store (Maybe commonT;Bytecode)) (|> store A;get io;run (dict;get class-name))) (def: (memory-class-loader store) - (-> &&common;Class-Store ClassLoader) + (-> commonT;Class-Store ClassLoader) (object ClassLoader [] [] (ClassLoader (findClass [class-name String]) Class @@ -79,13 +78,13 @@ (error! (format "Class not found: " class-name)))))) (def: #export init-host - (io;IO &&common;Host) - (io;io (let [store (: &&common;Class-Store + (io;IO commonT;Host) + (io;io (let [store (: commonT;Class-Store (A;atom (dict;new text;Hash<Text>)))] - {#&&common;loader (memory-class-loader store) - #&&common;store store - #&&common;function-class #;None - #&&common;artifacts (dict;new text;Hash<Text>)}))) + {#commonT;loader (memory-class-loader store) + #commonT;store store + #commonT;function-class #;None + #commonT;artifacts (dict;new text;Hash<Text>)}))) (def: #export class-loader (Meta ClassLoader) @@ -93,8 +92,8 @@ (#e;Success [compiler (|> compiler (get@ #;host) - (:! &&common;Host) - (get@ #&&common;loader))]))) + (:! commonT;Host) + (get@ #commonT;loader))]))) (def: #export runtime-class Text "LuxRuntime") (def: #export function-class Text "LuxFunction") diff --git a/new-luxc/source/luxc/lang/analysis/expression.lux b/new-luxc/source/luxc/lang/analysis/expression.lux index e3a623089..de0e49dbc 100644 --- a/new-luxc/source/luxc/lang/analysis/expression.lux +++ b/new-luxc/source/luxc/lang/analysis/expression.lux @@ -11,9 +11,9 @@ [host]) (luxc ["&" base] [";L" host] - (lang ["la" analysis]) - ["&;" module] - (generator [";G" common])) + (lang ["la" analysis] + (translation [";T" common])) + ["&;" module]) (.. [";A" common] [";A" function] [";A" primitive] @@ -37,7 +37,7 @@ (def: (call-macro macro inputs) (-> Macro (List Code) (Meta (List Code))) (do meta;Monad<Meta> - [class (commonG;load-class hostL;function-class)] + [class (commonT;load-class hostL;function-class)] (function [compiler] (do e;Monad<Error> [apply-method (Class.getMethod ["apply" _apply-args] class) diff --git a/new-luxc/source/luxc/generator.lux b/new-luxc/source/luxc/lang/translation.lux index e9b6c4d3f..4fcc3ccb2 100644 --- a/new-luxc/source/luxc/generator.lux +++ b/new-luxc/source/luxc/lang/translation.lux @@ -18,12 +18,12 @@ (lang ["&;" syntax] (analysis [";A" expression] [";A" common]) - (synthesis [";S" expression])) - (generator ["&&;" runtime] - ["&&;" statement] - ["&&;" common] - [";G" expression] - ["&&;" eval]) + (synthesis [";S" expression]) + (translation [";T" runtime] + [";T" statement] + [";T" common] + [";T" expression] + [";T" eval])) )) (def: analyse @@ -41,8 +41,8 @@ [[_ metaA] (&;with-scope (&;with-expected-type Code (analyse metaC))) - metaI (expressionG;generate (expressionS;synthesize metaA)) - metaV (&&eval;eval metaI) + metaI (expressionT;generate (expressionS;synthesize metaA)) + metaV (evalT;eval metaI) [_ valueT valueA] (&;with-scope (if (meta;type? (:! Code metaV)) (&;with-expected-type Type @@ -51,9 +51,9 @@ (wrap [Type valueA]))) (commonA;with-unknown-type (analyse valueC)))) - valueI (expressionG;generate (expressionS;synthesize valueA)) + valueI (expressionT;generate (expressionS;synthesize valueA)) _ (&;with-scope - (&&statement;generate-def def-name valueT valueI metaI (:! Code metaV)))] + (statementT;generate-def def-name valueT valueI metaI (:! Code metaV)))] (wrap [])) (^ [_ (#;Form (list [_ (#;Text "lux program")] @@ -63,8 +63,8 @@ [[_ programA] (&;with-scope (&;with-expected-type (type (io;IO Unit)) (analyse programC))) - programI (expressionG;generate (expressionS;synthesize programA))] - (&&statement;generate-program program-args programI)) + programI (expressionT;generate (expressionS;synthesize programA))] + (statementT;generate-program program-args programI)) _ (&;fail (format "Unrecognized statement: " (%code code))))) @@ -106,7 +106,7 @@ (case (meta;run' compiler (do meta;Monad<Meta> [[_ artifacts _] (&module;with-module module-hash module-name - (&&common;with-artifacts + (commonT;with-artifacts (with-active-compilation [module-name file-name file-content] @@ -146,7 +146,7 @@ #;mode #;Build}) (def: #export (init-compiler host) - (-> &&common;Host Compiler) + (-> commonT;Host Compiler) {#;info init-info #;source [init-cursor +0 ""] #;cursor init-cursor @@ -162,7 +162,7 @@ (def: #export (generate-program program target sources) (-> Text File (List File) (T;Task Unit)) (do T;Monad<Task> - [compiler (|> (case (&&runtime;generate (init-compiler (io;run hostL;init-host))) + [compiler (|> (case (runtimeT;generate (init-compiler (io;run hostL;init-host))) (#e;Error error) (T;fail error) diff --git a/new-luxc/source/luxc/generator/case.jvm.lux b/new-luxc/source/luxc/lang/translation/case.jvm.lux index a9ea4482a..a9ea4482a 100644 --- a/new-luxc/source/luxc/generator/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/case.jvm.lux diff --git a/new-luxc/source/luxc/generator/common.jvm.lux b/new-luxc/source/luxc/lang/translation/common.jvm.lux index 1870530c2..1870530c2 100644 --- a/new-luxc/source/luxc/generator/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/common.jvm.lux diff --git a/new-luxc/source/luxc/generator/eval.jvm.lux b/new-luxc/source/luxc/lang/translation/eval.jvm.lux index 2f0ce1c24..9514741f8 100644 --- a/new-luxc/source/luxc/generator/eval.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/eval.jvm.lux @@ -1,9 +1,8 @@ (;module: lux (lux (control monad) - (data ["R" error] - text/format) - [meta #+ Monad<Meta> "Meta/" Monad<Meta>] + (data text/format) + [meta] [host #+ do-to]) (luxc ["&" base] (host ["$" jvm] @@ -11,8 +10,8 @@ ["$d" def] ["$i" inst])) (lang ["la" analysis] - ["ls" synthesis]) - (generator ["&;" common]) + ["ls" synthesis] + (translation [";T" common])) )) (host;import java.lang.Object) @@ -56,26 +55,26 @@ (def: #export (eval valueI) (-> $;Inst (Meta Top)) - (do Monad<Meta> + (do meta;Monad<Meta> [class-name (:: @ map %code (meta;gensym "eval")) #let [writer (|> (do-to (ClassWriter.new ClassWriter.COMPUTE_MAXS) - (ClassWriter.visit [&common;bytecode-version + (ClassWriter.visit [commonT;bytecode-version (i.+ Opcodes.ACC_PUBLIC Opcodes.ACC_SUPER) class-name (host;null) "java/lang/Object" (host;null)])) ($d;field #$;Public ($_ $;++F $;finalF $;staticF) - &common;value-field &common;$Object) + commonT;value-field commonT;$Object) ($d;method #$;Public ($_ $;++M $;staticM $;strictM) "<clinit>" ($t;method (list) #;None (list)) (|>. valueI - ($i;PUTSTATIC class-name &common;value-field &common;$Object) + ($i;PUTSTATIC class-name commonT;value-field commonT;$Object) $i;RETURN))) bytecode (ClassWriter.toByteArray [] (do-to writer (ClassWriter.visitEnd [])))] - _ (&common;store-class class-name bytecode) - class (&common;load-class class-name)] + _ (commonT;store-class class-name bytecode) + class (commonT;load-class class-name)] (wrap (|> class - (Class.getField [&common;value-field]) + (Class.getField [commonT;value-field]) (Field.get (host;null)))))) diff --git a/new-luxc/source/luxc/generator/expression.jvm.lux b/new-luxc/source/luxc/lang/translation/expression.jvm.lux index 798998510..af66d4994 100644 --- a/new-luxc/source/luxc/generator/expression.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/expression.jvm.lux @@ -10,15 +10,15 @@ (luxc ["&" base] (host ["$" jvm]) (lang ["ls" synthesis] - [";L" variable #+ Variable Register]) - (generator ["&;" common] - ["&;" primitive] - ["&;" structure] - ["&;" eval] - ["&;" procedure] - ["&;" function] - ["&;" reference] - [";G" case]))) + (translation [";T" common] + [";T" primitive] + [";T" structure] + [";T" eval] + [";T" procedure] + [";T" function] + [";T" reference] + [";T" case]) + [";L" variable #+ Variable Register]))) (exception: #export Unrecognized-Synthesis) @@ -26,7 +26,7 @@ (-> ls;Synthesis (Meta $;Inst)) (case synthesis (^code []) - &primitive;generate-unit + primitiveT;generate-unit (^code [(~ singleton)]) (generate singleton) @@ -34,42 +34,42 @@ (^template [<tag> <generator>] [_ (<tag> value)] (<generator> value)) - ([#;Bool &primitive;generate-bool] - [#;Nat &primitive;generate-nat] - [#;Int &primitive;generate-int] - [#;Deg &primitive;generate-deg] - [#;Frac &primitive;generate-frac] - [#;Text &primitive;generate-text]) + ([#;Bool primitiveT;generate-bool] + [#;Nat primitiveT;generate-nat] + [#;Int primitiveT;generate-int] + [#;Deg primitiveT;generate-deg] + [#;Frac primitiveT;generate-frac] + [#;Text primitiveT;generate-text]) (^code ((~ [_ (#;Nat tag)]) (~ [_ (#;Bool last?)]) (~ valueS))) - (&structure;generate-variant generate tag last? valueS) + (structureT;generate-variant generate tag last? valueS) (^code [(~@ members)]) - (&structure;generate-tuple generate members) + (structureT;generate-tuple generate members) (^ [_ (#;Form (list [_ (#;Int var)]))]) (if (variableL;captured? var) - (&reference;generate-captured var) - (&reference;generate-variable var)) + (referenceT;generate-captured var) + (referenceT;generate-variable var)) [_ (#;Symbol definition)] - (&reference;generate-definition definition) + (referenceT;generate-definition definition) (^code ("lux let" (~ [_ (#;Nat register)]) (~ inputS) (~ exprS))) - (caseG;generate-let generate register inputS exprS) + (caseT;generate-let generate register inputS exprS) (^code ("lux case" (~ inputS) (~ pathPS))) - (caseG;generate-case generate inputS pathPS) + (caseT;generate-case generate inputS pathPS) (^multi (^code ("lux function" (~ [_ (#;Nat arity)]) [(~@ environment)] (~ bodyS))) [(s;run environment (p;some s;int)) (#e;Success environment)]) - (&function;generate-function generate environment arity bodyS) + (functionT;generate-function generate environment arity bodyS) (^code ("lux call" (~ functionS) (~@ argsS))) - (&function;generate-call generate functionS argsS) + (functionT;generate-call generate functionS argsS) (^code ((~ [_ (#;Text procedure)]) (~@ argsS))) - (&procedure;generate-procedure generate procedure argsS) + (procedureT;generate-procedure generate procedure argsS) _ (&;throw Unrecognized-Synthesis (%code synthesis)) diff --git a/new-luxc/source/luxc/generator/function.jvm.lux b/new-luxc/source/luxc/lang/translation/function.jvm.lux index 310f4d7a0..35c88e4ed 100644 --- a/new-luxc/source/luxc/generator/function.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/function.jvm.lux @@ -12,9 +12,9 @@ ["$i" inst])) (lang ["la" analysis] ["ls" synthesis] - [";L" variable #+ Variable]) - (generator ["&;" common] - ["&;" runtime]))) + (translation [";T" common] + [";T" runtime]) + [";L" variable #+ Variable]))) (def: arity-field Text "arity") @@ -57,7 +57,7 @@ (def: get-amount-of-partialsI $;Inst (|>. ($i;ALOAD +0) - ($i;GETFIELD hostL;function-class &runtime;partials-field $t;int))) + ($i;GETFIELD hostL;function-class runtimeT;partials-field $t;int))) (def: (load-fieldI class field) (-> Text Text $;Inst) @@ -72,13 +72,13 @@ (def: (applysI start amount) (-> $;Register Nat $;Inst) - (let [max-args (n.min amount &runtime;num-apply-variants) - later-applysI (if (n.> &runtime;num-apply-variants amount) - (applysI (n.+ &runtime;num-apply-variants start) (n.- &runtime;num-apply-variants amount)) + (let [max-args (n.min amount runtimeT;num-apply-variants) + later-applysI (if (n.> runtimeT;num-apply-variants amount) + (applysI (n.+ runtimeT;num-apply-variants start) (n.- runtimeT;num-apply-variants amount)) id)] (|>. ($i;CHECKCAST hostL;function-class) (inputsI start max-args) - ($i;INVOKEVIRTUAL hostL;function-class &runtime;apply-method (&runtime;apply-signature max-args) false) + ($i;INVOKEVIRTUAL hostL;function-class runtimeT;apply-method (runtimeT;apply-signature max-args) false) later-applysI))) (def: (inc-intI by) @@ -256,7 +256,7 @@ $i;ARETURN)) )))) $i;fuse)] - ($d;method #$;Public $;noneM &runtime;apply-method (&runtime;apply-signature apply-arity) + ($d;method #$;Public $;noneM runtimeT;apply-method (runtimeT;apply-signature apply-arity) (|>. get-amount-of-partialsI ($i;TABLESWITCH 0 (|> num-partials n.dec nat-to-int) @default @labels) @@ -272,16 +272,16 @@ (Meta [$;Def $;Inst])) (do meta;Monad<Meta> [@begin $i;make-label - bodyI (&common;with-function class (generate body)) + bodyI (commonT;with-function class (generate body)) #let [env-size (list;size env) applyD (: $;Def (if (poly-arg? arity) - (|> (n.min arity &runtime;num-apply-variants) + (|> (n.min arity runtimeT;num-apply-variants) (list;n.range +1) (list/map (with-apply class env arity @begin bodyI)) (list& (with-implementation arity @begin bodyI)) $d;fuse) - ($d;method #$;Public $;strictM &runtime;apply-method (&runtime;apply-signature +1) + ($d;method #$;Public $;strictM runtimeT;apply-method (runtimeT;apply-signature +1) (|>. ($i;label @begin) bodyI $i;ARETURN)))) @@ -302,7 +302,7 @@ (do meta;Monad<Meta> [function-class (:: @ map %code (meta;gensym "function")) [functionD instanceI] (with-function generate function-class env arity body) - _ (&common;store-class function-class + _ (commonT;store-class function-class ($d;class #$;V1.6 #$;Public $;finalC function-class (list) ($;simple-class hostL;function-class) (list) @@ -323,11 +323,11 @@ (do meta;Monad<Meta> [functionI (generate functionS) argsI (monad;map @ generate argsS) - #let [applyI (|> (segment &runtime;num-apply-variants argsI) + #let [applyI (|> (segment runtimeT;num-apply-variants argsI) (list/map (function [chunkI+] (|>. ($i;CHECKCAST hostL;function-class) ($i;fuse chunkI+) - ($i;INVOKEVIRTUAL hostL;function-class &runtime;apply-method (&runtime;apply-signature (list;size chunkI+)) false)))) + ($i;INVOKEVIRTUAL hostL;function-class runtimeT;apply-method (runtimeT;apply-signature (list;size chunkI+)) false)))) $i;fuse)]] (wrap (|>. functionI applyI)))) diff --git a/new-luxc/source/luxc/generator/primitive.jvm.lux b/new-luxc/source/luxc/lang/translation/primitive.jvm.lux index 637f46a85..72b5f4e9d 100644 --- a/new-luxc/source/luxc/generator/primitive.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/primitive.jvm.lux @@ -9,8 +9,8 @@ (jvm ["$i" inst] ["$t" type])) (lang ["la" analysis] - ["ls" synthesis]) - (generator ["&;" common])) + ["ls" synthesis] + (translation [";T" common]))) [../runtime]) (def: #export generate-unit diff --git a/new-luxc/source/luxc/generator/procedure.jvm.lux b/new-luxc/source/luxc/lang/translation/procedure.jvm.lux index 973f0e968..973f0e968 100644 --- a/new-luxc/source/luxc/generator/procedure.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/procedure.jvm.lux diff --git a/new-luxc/source/luxc/generator/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux index dffbcb64e..80becb058 100644 --- a/new-luxc/source/luxc/generator/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux @@ -16,9 +16,8 @@ ["$d" def] ["$i" inst])) (lang ["la" analysis] - ["ls" synthesis]) - (generator ["&;" common] - ["&;" runtime]))) + ["ls" synthesis] + (translation [";T" runtime])))) (host;import java.lang.Long (#static MIN_VALUE Long) @@ -193,11 +192,11 @@ $i;AALOAD $i;DUP ($i;IFNULL @is-null) - &runtime;someI + runtimeT;someI ($i;GOTO @end) ($i;label @is-null) $i;POP - &runtime;noneI + runtimeT;noneI ($i;label @end)))) (def: (array//put [arrayI idxI elemI]) @@ -400,11 +399,11 @@ ($i;int -1) ($i;IF_ICMPEQ @not-found) lux-intI - &runtime;someI + runtimeT;someI ($i;GOTO @end) ($i;label @not-found) $i;POP - &runtime;noneI + runtimeT;noneI ($i;label @end))))] [text//index "indexOf"] diff --git a/new-luxc/source/luxc/generator/procedure/host.jvm.lux b/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux index 9222b2e4a..c222e42cf 100644 --- a/new-luxc/source/luxc/generator/procedure/host.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux @@ -22,9 +22,7 @@ ["$i" inst])) (lang ["la" analysis] (analysis (procedure ["&;" host])) - ["ls" synthesis]) - (generator ["&;" common] - ["&;" runtime])) + ["ls" synthesis])) ["@" ../common]) (do-template [<name> <inst>] diff --git a/new-luxc/source/luxc/generator/reference.jvm.lux b/new-luxc/source/luxc/lang/translation/reference.jvm.lux index 9af511167..7c42f9f08 100644 --- a/new-luxc/source/luxc/generator/reference.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/reference.jvm.lux @@ -8,18 +8,18 @@ (jvm ["$t" type] ["$i" inst])) (lang ["ls" synthesis] - [";L" variable #+ Variable]) - (generator [";G" common] - [";G" function]))) + [";L" variable #+ Variable] + (translation [";T" common] + [";T" function])))) (def: #export (generate-captured variable) (-> Variable (Meta $;Inst)) (do meta;Monad<Meta> - [function-class commonG;function] + [function-class commonT;function] (wrap (|>. ($i;ALOAD +0) ($i;GETFIELD function-class - (|> variable i.inc (i.* -1) int-to-nat functionG;captured) - commonG;$Object))))) + (|> variable i.inc (i.* -1) int-to-nat functionT;captured) + commonT;$Object))))) (def: #export (generate-variable variable) (-> Variable (Meta $;Inst)) @@ -28,4 +28,4 @@ (def: #export (generate-definition [def-module def-name]) (-> Ident (Meta $;Inst)) (let [bytecode-name (format def-module "/" (&;normalize-name def-name))] - (meta/wrap ($i;GETSTATIC bytecode-name commonG;value-field commonG;$Object)))) + (meta/wrap ($i;GETSTATIC bytecode-name commonT;value-field commonT;$Object)))) diff --git a/new-luxc/source/luxc/generator/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/runtime.jvm.lux index 4b57e802e..e5d237fc7 100644 --- a/new-luxc/source/luxc/generator/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/runtime.jvm.lux @@ -13,8 +13,8 @@ ["$d" def] ["$i" inst])) (lang ["la" analysis] - ["ls" synthesis]) - (generator ["&;" common]))) + ["ls" synthesis] + (translation [";T" common])))) (host;import java.lang.Object) (host;import java.lang.String) @@ -556,7 +556,7 @@ ))) (def: generate-runtime - (Meta &common;Bytecode) + (Meta commonT;Bytecode) (do meta;Monad<Meta> [_ (wrap []) #let [bytecode ($d;class #$;V1.6 #$;Public $;finalC hostL;runtime-class (list) ["java.lang.Object" (list)] (list) @@ -566,11 +566,11 @@ deg-methods pm-methods io-methods))] - _ (&common;store-class hostL;runtime-class bytecode)] + _ (commonT;store-class hostL;runtime-class bytecode)] (wrap bytecode))) (def: generate-function - (Meta &common;Bytecode) + (Meta commonT;Bytecode) (do meta;Monad<Meta> [_ (wrap []) #let [applyI (|> (list;n.range +2 num-apply-variants) @@ -597,11 +597,11 @@ ($i;PUTFIELD hostL;function-class partials-field $t;int) $i;RETURN)) applyI))] - _ (&common;store-class hostL;function-class bytecode)] + _ (commonT;store-class hostL;function-class bytecode)] (wrap bytecode))) (def: #export generate - (Meta [&common;Bytecode &common;Bytecode]) + (Meta [commonT;Bytecode commonT;Bytecode]) (do meta;Monad<Meta> [runtime-bc generate-runtime function-bc generate-function] diff --git a/new-luxc/source/luxc/generator/statement.jvm.lux b/new-luxc/source/luxc/lang/translation/statement.jvm.lux index e91e99fc9..0234d738c 100644 --- a/new-luxc/source/luxc/generator/statement.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/statement.jvm.lux @@ -17,8 +17,8 @@ (jvm ["$t" type] ["$d" def] ["$i" inst])) - (generator ["&;" eval] - ["&;" common]))) + (lang (translation [";T" eval] + [";T" common])))) (exception: #export Invalid-Definition-Value) @@ -44,16 +44,16 @@ bytecode-name (list) ["java.lang.Object" (list)] (list) - (|>. ($d;field #$;Public ($;++F $;finalF $;staticF) &common;value-field &common;$Object) + (|>. ($d;field #$;Public ($;++F $;finalF $;staticF) commonT;value-field commonT;$Object) ($d;method #$;Public $;staticM "<clinit>" ($t;method (list) #;None (list)) (|>. valueI - ($i;PUTSTATIC bytecode-name &common;value-field &common;$Object) + ($i;PUTSTATIC bytecode-name commonT;value-field commonT;$Object) $i;RETURN))))] - _ (&common;store-class class-name bytecode) - class (&common;load-class class-name) + _ (commonT;store-class class-name bytecode) + class (commonT;load-class class-name) valueV (: (Meta Top) (case (do e;Monad<Error> - [field (Class.getField [&common;value-field] class)] + [field (Class.getField [commonT;value-field] class)] (Field.get [#;None] field)) (#e;Success #;None) (&;throw Invalid-Definition-Value (format current-module ";" def-name)) @@ -73,7 +73,7 @@ (&module;declare-tags tags (meta;export? metaV) (:! Type valueV))) (wrap [])) #let [_ (log! (format "DEF " current-module ";" def-name))]] - (&common;record-artifact bytecode-name bytecode))) + (commonT;record-artifact bytecode-name bytecode))) (def: #export (generate-program program-args programI) (-> Text $;Inst (Meta Unit)) diff --git a/new-luxc/source/luxc/generator/structure.jvm.lux b/new-luxc/source/luxc/lang/translation/structure.jvm.lux index 96d5767c6..c3e07fd55 100644 --- a/new-luxc/source/luxc/generator/structure.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/structure.jvm.lux @@ -12,8 +12,8 @@ ["$d" def] ["$i" inst])) (lang ["la" analysis] - ["ls" synthesis]) - (generator ["&;" common])) + ["ls" synthesis] + (translation [";T" common]))) [../runtime]) (def: $Object $;Type ($t;class "java.lang.Object" (list))) diff --git a/new-luxc/source/program.lux b/new-luxc/source/program.lux index e660b4158..142e8b566 100644 --- a/new-luxc/source/program.lux +++ b/new-luxc/source/program.lux @@ -8,7 +8,7 @@ text/format) [io #- run] [cli #+ program: CLI]) - (luxc ["&;" generator])) + (luxc (lang [";L" translation]))) ## (type: Compilation ## {#program &;Path @@ -53,3 +53,5 @@ (#e;Success output) (wrap output)))) + + diff --git a/new-luxc/test/test/luxc/common.lux b/new-luxc/test/test/luxc/common.lux index 5b6fed8ec..84d912145 100644 --- a/new-luxc/test/test/luxc/common.lux +++ b/new-luxc/test/test/luxc/common.lux @@ -2,8 +2,8 @@ lux (lux [io]) (luxc ["&;" host] - [";G" generator])) + (lang [";L" translation]))) (def: #export (init-compiler _) (-> Top Compiler) - (generatorG;init-compiler (io;run &host;init-host))) + (translationL;init-compiler (io;run &host;init-host))) diff --git a/new-luxc/test/test/luxc/lang/analysis/procedure/host.jvm.lux b/new-luxc/test/test/luxc/lang/analysis/procedure/host.jvm.lux index 333a60353..cda281e04 100644 --- a/new-luxc/test/test/luxc/lang/analysis/procedure/host.jvm.lux +++ b/new-luxc/test/test/luxc/lang/analysis/procedure/host.jvm.lux @@ -25,8 +25,8 @@ (analysis [";A" expression] ["@;" common] ["@" procedure] - (procedure ["@;" host]))) - (generator ["@;" runtime])) + (procedure ["@;" host])) + (translation ["@;" runtime]))) (../.. common) (test/luxc common)) diff --git a/new-luxc/test/test/luxc/lang/analysis/type.lux b/new-luxc/test/test/luxc/lang/analysis/type.lux index 649c33fef..78107ecb6 100644 --- a/new-luxc/test/test/luxc/lang/analysis/type.lux +++ b/new-luxc/test/test/luxc/lang/analysis/type.lux @@ -21,8 +21,8 @@ (lang ["~" analysis] (analysis [";A" expression] ["@" type] - ["@;" common])) - (generator ["@;" runtime]) + ["@;" common]) + (translation ["@;" runtime])) [eval]) (.. common) (test/luxc common)) diff --git a/new-luxc/test/test/luxc/generator/case.lux b/new-luxc/test/test/luxc/lang/translation/case.lux index e4201a30b..3a8608ea7 100644 --- a/new-luxc/test/test/luxc/generator/case.lux +++ b/new-luxc/test/test/luxc/lang/translation/case.lux @@ -10,12 +10,12 @@ [meta] (meta [code]) test) - (luxc (lang ["ls" synthesis]) - (generator ["@" case] - [";G" expression] - ["@;" eval] - ["@;" runtime] - ["@;" common])) + (luxc (lang ["ls" synthesis] + (translation ["@" case] + [";T" expression] + ["@;" eval] + ["@;" runtime] + ["@;" common]))) (test/luxc common)) (def: struct-limit Nat +10) @@ -71,7 +71,7 @@ (test "Can generate pattern-matching." (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (@;generate-case expressionG;generate + sampleI (@;generate-case expressionT;generate valueS (` ("lux case alt" ("lux case seq" (~ pathS) @@ -80,22 +80,22 @@ ("lux case exec" false)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (:! Bool valueG) + (case> (#e;Success valueT) + (:! Bool valueT) (#e;Error error) false))) (test "Can bind values." (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (@;generate-case expressionG;generate + sampleI (@;generate-case expressionT;generate (code;nat to-bind) (` ("lux case seq" ("lux case bind" +0) ("lux case exec" (0)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (n.= to-bind (:! Nat valueG)) + (case> (#e;Success valueT) + (n.= to-bind (:! Nat valueT)) _ false))))))) diff --git a/new-luxc/test/test/luxc/generator/function.lux b/new-luxc/test/test/luxc/lang/translation/function.lux index 2db2719b7..1896adff3 100644 --- a/new-luxc/test/test/luxc/generator/function.lux +++ b/new-luxc/test/test/luxc/lang/translation/function.lux @@ -13,11 +13,11 @@ (meta [code]) [host] test) - (luxc (lang ["ls" synthesis]) - (generator [";G" expression] - ["@;" eval] - ["@;" runtime] - ["@;" common])) + (luxc (lang ["ls" synthesis] + (translation [";T" expression] + ["@;" eval] + ["@;" runtime] + ["@;" common]))) (test/luxc common)) (def: arity-limit Nat +10) @@ -49,11 +49,11 @@ (test "Can read arguments." (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` ("lux call" (~ functionS) (~@ argsS))))] + sampleI (expressionT;generate (` ("lux call" (~ functionS) (~@ argsS))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (n.= arg-value (:! Nat valueG)) + (case> (#e;Success valueT) + (n.= arg-value (:! Nat valueT)) (#e;Error error) false))) @@ -64,13 +64,13 @@ preS (list;take partial-arity argsS) postS (list;drop partial-arity argsS)] runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` ("lux call" + sampleI (expressionT;generate (` ("lux call" ("lux call" (~ functionS) (~@ preS)) (~@ postS))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (n.= arg-value (:! Nat valueG)) + (case> (#e;Success valueT) + (n.= arg-value (:! Nat valueT)) (#e;Error error) false)))) @@ -88,11 +88,11 @@ ("lux function" (~ (code;nat sub-arity)) [(~@ (list/map code;int env))] ((~ (code;int arg-var))))))] runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` ("lux call" (~ functionS) (~@ argsS))))] + sampleI (expressionT;generate (` ("lux call" (~ functionS) (~@ argsS))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (n.= arg-value (:! Nat valueG)) + (case> (#e;Success valueT) + (n.= arg-value (:! Nat valueT)) (#e;Error error) false)))) diff --git a/new-luxc/test/test/luxc/generator/primitive.lux b/new-luxc/test/test/luxc/lang/translation/primitive.lux index 1ce93cee9..8604ed369 100644 --- a/new-luxc/test/test/luxc/generator/primitive.lux +++ b/new-luxc/test/test/luxc/lang/translation/primitive.lux @@ -12,11 +12,11 @@ (meta [code]) test) (luxc [";L" host] - (lang ["ls" synthesis]) - (generator [";G" expression] - ["@;" runtime] - ["@;" eval] - ["@;" common])) + (lang ["ls" synthesis] + (translation [";T" expression] + ["@;" runtime] + ["@;" eval] + ["@;" common]))) (test/luxc common)) (context: "Primitives." @@ -32,11 +32,11 @@ [<tests> (do-template [<desc> <type> <synthesis> <sample> <test>] [(test (format "Can generate " <desc> ".") (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (<synthesis> <sample>))] + [sampleI (expressionT;generate (<synthesis> <sample>))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<test> <sample> (:! <type> valueG)) + (case> (#e;Success valueT) + (<test> <sample> (:! <type> valueT)) _ false)))] @@ -50,11 +50,11 @@ ($_ seq (test "Can generate unit." (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (' []))] + [sampleI (expressionT;generate (' []))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (is hostL;unit (:! Text valueG)) + (case> (#e;Success valueT) + (is hostL;unit (:! Text valueT)) _ false))) diff --git a/new-luxc/test/test/luxc/generator/procedure/common.jvm.lux b/new-luxc/test/test/luxc/lang/translation/procedure/common.jvm.lux index 0c24a4020..8c44007d0 100644 --- a/new-luxc/test/test/luxc/generator/procedure/common.jvm.lux +++ b/new-luxc/test/test/luxc/lang/translation/procedure/common.jvm.lux @@ -16,11 +16,11 @@ (meta [code]) [host] test) - (luxc (lang ["ls" synthesis]) - (generator [";G" expression] - ["@;" eval] - ["@;" runtime] - ["@;" common])) + (luxc (lang ["ls" synthesis] + (translation [";T" expression] + ["@;" eval] + ["@;" runtime] + ["@;" common]))) (test/luxc common)) (context: "Bit procedures" @@ -31,12 +31,12 @@ (with-expansions [<binary> (do-template [<name> <reference>] [(test <name> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<name> (~ (code;nat subject)) + [sampleI (expressionT;generate (` (<name> (~ (code;nat subject)) (~ (code;nat param)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (n.= (<reference> param subject) (:! Nat valueG)) + (case> (#e;Success valueT) + (n.= (<reference> param subject) (:! Nat valueT)) _ false)))] @@ -50,11 +50,11 @@ ($_ seq (test "bit count" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("bit count" (~ (code;nat subject)))))] + [sampleI (expressionT;generate (` ("bit count" (~ (code;nat subject)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (n.= (bit;count subject) (:! Nat valueG)) + (case> (#e;Success valueT) + (n.= (bit;count subject) (:! Nat valueT)) _ false))) @@ -62,14 +62,14 @@ <binary> (test "bit shift-right" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("bit shift-right" + [sampleI (expressionT;generate (` ("bit shift-right" (~ (code;int (nat-to-int subject))) (~ (code;nat param)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) + (case> (#e;Success valueT) (i.= (bit;signed-shift-right param (nat-to-int subject)) - (:! Int valueG)) + (:! Int valueT)) _ false))) @@ -84,11 +84,11 @@ (~~ (do-template [<name> <reference>] [(test <name> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<name>)))] + [sampleI (expressionT;generate (` (<name>)))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (n.= <reference> (:! Nat valueG)) + (case> (#e;Success valueT) + (n.= <reference> (:! Nat valueT)) _ false)))] @@ -99,11 +99,11 @@ (~~ (do-template [<name> <type> <prepare> <comp>] [(test <name> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<name> (~ (code;nat subject)))))] + [sampleI (expressionT;generate (` (<name> (~ (code;nat subject)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<comp> (<prepare> subject) (:! <type> valueG)) + (case> (#e;Success valueT) + (<comp> (<prepare> subject) (:! <type> valueT)) _ false)))] @@ -115,11 +115,11 @@ [(test <name> (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` (<name> (~ (code;nat subject)) (~ (code;nat param)))))] + sampleI (expressionT;generate (` (<name> (~ (code;nat subject)) (~ (code;nat param)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<comp> (<reference> param subject) (:! <outputT> valueG)) + (case> (#e;Success valueT) + (<comp> (<reference> param subject) (:! <outputT> valueT)) _ false)))] @@ -142,11 +142,11 @@ (with-expansions [<nullary> (do-template [<name> <reference>] [(test <name> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<name>)))] + [sampleI (expressionT;generate (` (<name>)))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (i.= <reference> (:! Int valueG)) + (case> (#e;Success valueT) + (i.= <reference> (:! Int valueT)) _ false)))] @@ -157,11 +157,11 @@ <unary> (do-template [<name> <type> <prepare> <comp>] [(test <name> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<name> (~ (code;int subject)))))] + [sampleI (expressionT;generate (` (<name> (~ (code;int subject)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<comp> (<prepare> subject) (:! <type> valueG)) + (case> (#e;Success valueT) + (<comp> (<prepare> subject) (:! <type> valueT)) _ false)))] @@ -173,11 +173,11 @@ [(test <name> (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` (<name> (~ (code;int subject)) (~ (code;int param)))))] + sampleI (expressionT;generate (` (<name> (~ (code;int subject)) (~ (code;int param)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<comp> (<reference> param subject) (:! <outputT> valueG)) + (case> (#e;Success valueT) + (<comp> (<reference> param subject) (:! <outputT> valueT)) _ false)))] @@ -205,11 +205,11 @@ [(test <name> (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` (<name> (~ (code;frac subject)) (~ (code;frac param)))))] + sampleI (expressionT;generate (` (<name> (~ (code;frac subject)) (~ (code;frac param)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<comp> (<reference> param subject) (:! <outputT> valueG)) + (case> (#e;Success valueT) + (<comp> (<reference> param subject) (:! <outputT> valueT)) _ false)))] @@ -234,11 +234,11 @@ (with-expansions [<nullary> (do-template [<name> <test>] [(test <name> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<name>)))] + [sampleI (expressionT;generate (` (<name>)))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<test> (:! Frac valueG)) + (case> (#e;Success valueT) + (<test> (:! Frac valueT)) _ false)))] @@ -254,11 +254,11 @@ [(test <name> (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` (<name> (~ (code;frac subject)))))] + sampleI (expressionT;generate (` (<name> (~ (code;frac subject)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<comp> (<prepare> subject) (:! <type> valueG)) + (case> (#e;Success valueT) + (<comp> (<prepare> subject) (:! <type> valueT)) _ false)))] @@ -272,11 +272,11 @@ (test "frac encode|decode" (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` ("frac decode" ("frac encode" (~ (code;frac subject))))))] + sampleI (expressionT;generate (` ("frac decode" ("frac encode" (~ (code;frac subject))))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (^multi (#e;Success valueG) - [(:! (Maybe Frac) valueG) (#;Some value)]) + (case> (^multi (#e;Success valueT) + [(:! (Maybe Frac) valueT) (#;Some value)]) (f.= subject value) _ @@ -300,11 +300,11 @@ (~~ (do-template [<name> <reference>] [(test <name> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<name>)))] + [sampleI (expressionT;generate (` (<name>)))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (d.= <reference> (:! Deg valueG)) + (case> (#e;Success valueT) + (d.= <reference> (:! Deg valueT)) _ false)))] @@ -316,11 +316,11 @@ [(test <name> (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` (<name> (~ (code;deg subject)))))] + sampleI (expressionT;generate (` (<name> (~ (code;deg subject)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<comp> (<prepare> subject) (:! <type> valueG)) + (case> (#e;Success valueT) + (<comp> (<prepare> subject) (:! <type> valueT)) _ false)))] @@ -331,11 +331,11 @@ [(test <name> (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` (<name> (~ (code;deg subject)) (~ (code;deg param)))))] + sampleI (expressionT;generate (` (<name> (~ (code;deg subject)) (~ (code;deg param)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<comp> (<reference> param subject) (:! <outputT> valueG)) + (case> (#e;Success valueT) + (<comp> (<reference> param subject) (:! <outputT> valueT)) _ false)))] @@ -352,11 +352,11 @@ [(test <name> (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` (<name> (~ (code;deg subject)) (~ (code;nat special)))))] + sampleI (expressionT;generate (` (<name> (~ (code;deg subject)) (~ (code;nat special)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<comp> (<reference> special subject) (:! <outputT> valueG)) + (case> (#e;Success valueT) + (<comp> (<reference> special subject) (:! <outputT> valueT)) _ false)))] diff --git a/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux b/new-luxc/test/test/luxc/lang/translation/procedure/host.jvm.lux index 91b20d3d4..35453c44b 100644 --- a/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux +++ b/new-luxc/test/test/luxc/lang/translation/procedure/host.jvm.lux @@ -17,11 +17,11 @@ [host] test) (luxc [";L" host] - (lang ["ls" synthesis]) - (generator [";G" expression] - ["@;" eval] - ["@;" runtime] - ["@;" common])) + (lang ["ls" synthesis] + (translation [";T" expression] + ["@;" eval] + ["@;" runtime] + ["@;" common]))) (test/luxc common)) (context: "Conversions [Part 1]" @@ -32,11 +32,11 @@ (with-expansions [<2step> (do-template [<step1> <step2> <tag> <sample> <cast> <test>] [(test (format <step1> " / " <step2>) (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (|> (~ (<tag> <sample>)) <step1> <step2> (`)))] + [sampleI (expressionT;generate (|> (~ (<tag> <sample>)) <step1> <step2> (`)))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<test> <sample> (:! <cast> valueG)) + (case> (#e;Success valueT) + (<test> <sample> (:! <cast> valueT)) (#e;Error error) false)))] @@ -63,11 +63,11 @@ (~~ (do-template [<step1> <step2> <step3> <tag> <sample> <cast> <test>] [(test (format <step1> " / " <step2> " / " <step3>) (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (|> (~ (<tag> <sample>)) <step1> <step2> <step3> (`)))] + [sampleI (expressionT;generate (|> (~ (<tag> <sample>)) <step1> <step2> <step3> (`)))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<test> <sample> (:! <cast> valueG)) + (case> (#e;Success valueT) + (<test> <sample> (:! <cast> valueT)) (#e;Error error) false)))] @@ -89,11 +89,11 @@ (~~ (do-template [<step1> <step2> <step3> <step4> <tag> <sample> <cast> <test>] [(test (format <step1> " / " <step2> " / " <step3>) (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (|> (~ (<tag> <sample>)) <step1> <step2> <step3> <step4> (`)))] + [sampleI (expressionT;generate (|> (~ (<tag> <sample>)) <step1> <step2> <step3> <step4> (`)))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (<test> <sample> (:! <cast> valueG)) + (case> (#e;Success valueT) + (<test> <sample> (:! <cast> valueT)) (#e;Error error) false)))] @@ -127,14 +127,14 @@ (with-expansions [<tests> (do-template [<procedure> <reference>] [(test <procedure> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<post> ((~ (code;text <procedure>)) + [sampleI (expressionT;generate (` (<post> ((~ (code;text <procedure>)) (<pre> (~ (<tag> subject))) (<pre> (~ (<tag> param)))))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) + (case> (#e;Success valueT) (<test> (<reference> param subject) - (:! <type> valueG)) + (:! <type> valueT)) (#e;Error error) false)))] @@ -165,14 +165,14 @@ (~~ (do-template [<procedure> <reference>] [(test <procedure> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<post> ((~ (code;text <procedure>)) + [sampleI (expressionT;generate (` (<post> ((~ (code;text <procedure>)) (<convert> (~ (code;nat subject))) (<convert> (~ (code;nat param)))))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) + (case> (#e;Success valueT) (n.= (<reference> param subject) - (:! Nat valueG)) + (:! Nat valueT)) (#e;Error error) false)))] @@ -198,14 +198,14 @@ (~~ (do-template [<procedure> <reference> <type> <test> <pre-subject> <pre>] [(test <procedure> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` (<post> ((~ (code;text <procedure>)) + [sampleI (expressionT;generate (` (<post> ((~ (code;text <procedure>)) (<convert> (~ (<pre> subject))) ("jvm convert long-to-int" (~ (code;nat shift)))))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) + (case> (#e;Success valueT) (<test> (<reference> shift (<pre-subject> subject)) - (:! <type> valueG)) + (:! <type> valueT)) (#e;Error error) false)))] @@ -229,14 +229,14 @@ (with-expansions [<tests> (do-template [<procedure> <reference>] [(test <procedure> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ((~ (code;text <procedure>)) + [sampleI (expressionT;generate (` ((~ (code;text <procedure>)) (<pre> (~ (<tag> subject))) (<pre> (~ (<tag> param))))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) + (case> (#e;Success valueT) (bool/= (<reference> param subject) - (:! Bool valueG)) + (:! Bool valueT)) (#e;Error error) false)))] @@ -283,7 +283,7 @@ (with-expansions [<array> (do-template [<class> <type> <value> <test> <input> <post>] [(test <class> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (|> (jvm//array//new +0 <class> size) + [sampleI (expressionT;generate (|> (jvm//array//new +0 <class> size) (jvm//array//write <class> idx <input>) (jvm//array//read <class> idx) (~) @@ -332,7 +332,7 @@ (with-expansions [<array> (do-template [<class> <type> <value> <test> <input> <post>] [(test <class> (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (|> (jvm//array//new +0 <class> size) + [sampleI (expressionT;generate (|> (jvm//array//new +0 <class> size) (jvm//array//write <class> idx <input>) (jvm//array//read <class> idx) (~) @@ -340,8 +340,8 @@ (`)))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (<test> <value> (:! <type> outputG)) + (case> (#e;Success outputT) + (<test> <value> (:! <type> outputT)) (#e;Error error) false)))] @@ -360,25 +360,25 @@ [#let [inner (|> ("jvm array new" +0 "java.lang.Double" (~ (code;nat size))) ("jvm array write" "java.lang.Double" (~ (code;nat idx)) (~ (code;frac valueD))) (`))] - sampleI (expressionG;generate (|> ("jvm array new" +1 "java.lang.Double" (~ (code;nat size))) + sampleI (expressionT;generate (|> ("jvm array new" +1 "java.lang.Double" (~ (code;nat size))) ("jvm array write" "#Array" (~ (code;nat idx)) (~ inner)) ("jvm array read" "#Array" (~ (code;nat idx))) ("jvm array read" "java.lang.Double" (~ (code;nat idx))) (`)))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (f.= valueD (:! Frac outputG)) + (case> (#e;Success outputT) + (f.= valueD (:! Frac outputT)) (#e;Error error) false))) (test "jvm array length" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm array length" ("jvm array new" +0 "java.lang.Object" (~ (code;nat size))))))] + [sampleI (expressionT;generate (` ("jvm array length" ("jvm array new" +0 "java.lang.Object" (~ (code;nat size))))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (n.= size (:! Nat outputG)) + (case> (#e;Success outputT) + (n.= size (:! Nat outputT)) (#e;Error error) false))) @@ -424,70 +424,70 @@ ($_ seq (test "jvm object null" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm object null?" ("jvm object null"))))] + [sampleI (expressionT;generate (` ("jvm object null?" ("jvm object null"))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (:! Bool outputG) + (case> (#e;Success outputT) + (:! Bool outputT) (#e;Error error) false))) (test "jvm object null?" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm object null?" (~ (code;int sample)))))] + [sampleI (expressionT;generate (` ("jvm object null?" (~ (code;int sample)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (not (:! Bool outputG)) + (case> (#e;Success outputT) + (not (:! Bool outputT)) (#e;Error error) false))) (test "jvm object synchronized" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm object synchronized" (~ (code;int monitor)) (~ (code;int sample)))))] + [sampleI (expressionT;generate (` ("jvm object synchronized" (~ (code;int monitor)) (~ (code;int sample)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (i.= sample (:! Int outputG)) + (case> (#e;Success outputT) + (i.= sample (:! Int outputT)) (#e;Error error) false))) (test "jvm object throw" (|> (do meta;Monad<Meta> [_ @runtime;generate - sampleI (expressionG;generate (` ("lux try" ("lux function" +1 [] + sampleI (expressionT;generate (` ("lux try" ("lux function" +1 [] ("jvm object throw" ("jvm member invoke constructor" "java.lang.Throwable" (~ exception-message$)))))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (case (:! (e;Error Top) outputG) + (case> (#e;Success outputT) + (case (:! (e;Error Top) outputT) (#e;Error error) (text;contains? exception-message error) - (#e;Success outputG) + (#e;Success outputT) false) (#e;Error error) false))) (test "jvm object class" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm object class" (~ (code;text class)))))] + [sampleI (expressionT;generate (` ("jvm object class" (~ (code;text class)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (|> outputG (:! Class) (Class.getName []) (text/= class)) + (case> (#e;Success outputT) + (|> outputT (:! Class) (Class.getName []) (text/= class)) (#e;Error error) false))) (test "jvm object instance?" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm object instance?" (~ (code;text instance-class)) (~ instance))))] + [sampleI (expressionT;generate (` ("jvm object instance?" (~ (code;text instance-class)) (~ instance))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (:! Bool outputG) + (case> (#e;Success outputT) + (:! Bool outputT) (#e;Error error) false))) @@ -513,44 +513,44 @@ ($_ seq (test "jvm member static get" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm convert int-to-long" ("jvm member static get" "java.util.GregorianCalendar" "AD" "int"))))] + [sampleI (expressionT;generate (` ("jvm convert int-to-long" ("jvm member static get" "java.util.GregorianCalendar" "AD" "int"))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (i.= GregorianCalendar.AD (:! Int outputG)) + (case> (#e;Success outputT) + (i.= GregorianCalendar.AD (:! Int outputT)) (#e;Error error) false))) (test "jvm member static put" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm member static put" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor" + [sampleI (expressionT;generate (` ("jvm member static put" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor" ("jvm member static get" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor"))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (is hostL;unit (:! Text outputG)) + (case> (#e;Success outputT) + (is hostL;unit (:! Text outputT)) (#e;Error error) false))) (test "jvm member virtual get" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String" (~ value-memberS))))] + [sampleI (expressionT;generate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String" (~ value-memberS))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (text/= sample-string (:! Text outputG)) + (case> (#e;Success outputT) + (text/= sample-string (:! Text outputT)) (#e;Error error) false))) (test "jvm member virtual put" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String" + [sampleI (expressionT;generate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String" ("jvm member virtual put" "org.omg.CORBA.ValueMember" "name" "java.lang.String" (~ (code;text other-sample-string)) (~ value-memberS)))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (text/= other-sample-string (:! Text outputG)) + (case> (#e;Success outputT) + (text/= other-sample-string (:! Text outputT)) (#e;Error error) false))) @@ -571,43 +571,43 @@ ($_ seq (test "jvm member invoke static" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm member invoke static" "java.lang.Long" "decode" "java.lang.Long" (~ coded-intS))))] + [sampleI (expressionT;generate (` ("jvm member invoke static" "java.lang.Long" "decode" "java.lang.Long" (~ coded-intS))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (i.= sample (:! Int outputG)) + (case> (#e;Success outputT) + (i.= sample (:! Int outputT)) (#e;Error error) false))) (test "jvm member invoke virtual" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm member invoke virtual" "java.lang.Object" "equals" "boolean" + [sampleI (expressionT;generate (` ("jvm member invoke virtual" "java.lang.Object" "equals" "boolean" (~ (code;int sample)) (~ object-longS))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (:! Bool outputG) + (case> (#e;Success outputT) + (:! Bool outputT) (#e;Error error) false))) (test "jvm member invoke interface" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (` ("jvm member invoke interface" "java.util.Collection" "add" "boolean" + [sampleI (expressionT;generate (` ("jvm member invoke interface" "java.util.Collection" "add" "boolean" (~ array-listS) (~ object-longS))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (:! Bool outputG) + (case> (#e;Success outputT) + (:! Bool outputT) (#e;Error error) false))) (test "jvm member invoke constructor" (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate array-listS)] + [sampleI (expressionT;generate array-listS)] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (host;instance? ArrayList (:! Object outputG)) + (case> (#e;Success outputT) + (host;instance? ArrayList (:! Object outputT)) (#e;Error error) false))) diff --git a/new-luxc/test/test/luxc/generator/reference.lux b/new-luxc/test/test/luxc/lang/translation/reference.lux index dd522839b..0bc2bb325 100644 --- a/new-luxc/test/test/luxc/generator/reference.lux +++ b/new-luxc/test/test/luxc/lang/translation/reference.lux @@ -11,28 +11,28 @@ test) (luxc (host ["$" jvm] (jvm ["$i" inst])) - (lang ["ls" synthesis]) - ["_;" module] - (generator [";G" statement] - [";G" eval] - [";G" expression] - [";G" case] - [";G" runtime])) + (lang ["ls" synthesis] + (translation [";T" statement] + [";T" eval] + [";T" expression] + [";T" case] + [";T" runtime])) + ["_;" module]) (test/luxc common)) -(def: nilI $;Inst runtimeG;noneI) +(def: nilI $;Inst runtimeT;noneI) (def: cursorI $;Inst (|>. ($i;int 3) - ($i;array runtimeG;$Tuple) + ($i;array runtimeT;$Tuple) $i;DUP ($i;int 0) ($i;string "") $i;AASTORE $i;DUP ($i;int 1) ($i;long 0) ($i;wrap #$;Long) $i;AASTORE $i;DUP ($i;int 2) ($i;long 0) ($i;wrap #$;Long) $i;AASTORE)) (def: empty-metaI (|>. ($i;int 2) - ($i;array runtimeG;$Tuple) + ($i;array runtimeT;$Tuple) $i;DUP ($i;int 0) cursorI $i;AASTORE $i;DUP ($i;int 1) nilI $i;AASTORE)) @@ -47,12 +47,12 @@ (test "Can refer to definitions." (|> (do meta;Monad<Meta> [_ (_module;with-module +0 module-name - (statementG;generate-def def-name Int valueI empty-metaI (' {}))) - sampleI (expressionG;generate (code;symbol [module-name def-name]))] - (evalG;eval sampleI)) + (statementT;generate-def def-name Int valueI empty-metaI (' {}))) + sampleI (expressionT;generate (code;symbol [module-name def-name]))] + (evalT;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (i.= def-value (:! Int valueG)) + (case> (#e;Success valueT) + (i.= def-value (:! Int valueT)) (#e;Error error) false))) @@ -66,14 +66,14 @@ ($_ seq (test "Can refer to local variables/registers." (|> (do meta;Monad<Meta> - [sampleI (caseG;generate-let expressionG;generate + [sampleI (caseT;generate-let expressionT;generate register (code;int value) (` ((~ (code;int (nat-to-int register))))))] - (evalG;eval sampleI)) + (evalT;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success outputG) - (i.= value (:! Int outputG)) + (case> (#e;Success outputT) + (i.= value (:! Int outputT)) (#e;Error error) false))) diff --git a/new-luxc/test/test/luxc/generator/structure.lux b/new-luxc/test/test/luxc/lang/translation/structure.lux index 7c342dbc4..a8f74ec6a 100644 --- a/new-luxc/test/test/luxc/generator/structure.lux +++ b/new-luxc/test/test/luxc/lang/translation/structure.lux @@ -16,11 +16,11 @@ [host] test) (luxc [";L" host] - (lang ["ls" synthesis]) - (generator [";G" expression] - ["@;" eval] - ["@;" runtime] - ["@;" common])) + (lang ["ls" synthesis] + (translation [";T" expression] + ["@;" eval] + ["@;" runtime] + ["@;" common]))) (test/luxc common)) (host;import java.lang.Integer) @@ -67,13 +67,13 @@ members (r;list size gen-primitive)] (test "Can generate tuple." (|> (do meta;Monad<Meta> - [sampleI (expressionG;generate (code;tuple members))] + [sampleI (expressionT;generate (code;tuple members))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (let [valueG (:! (Array Top) valueG)] - (and (n.= size (array;size valueG)) - (list;every? corresponds? (list;zip2 members (array;to-list valueG))))) + (case> (#e;Success valueT) + (let [valueT (:! (Array Top) valueT)] + (and (n.= size (array;size valueT)) + (list;every? corresponds? (list;zip2 members (array;to-list valueT))))) _ false)))))) @@ -88,15 +88,15 @@ (test "Can generate variant." (|> (do meta;Monad<Meta> [runtime-bytecode @runtime;generate - sampleI (expressionG;generate (` ((~ (code;nat tag)) (~ (code;bool last?)) (~ member))))] + sampleI (expressionT;generate (` ((~ (code;nat tag)) (~ (code;bool last?)) (~ member))))] (@eval;eval sampleI)) (meta;run (init-compiler [])) - (case> (#e;Success valueG) - (let [valueG (:! (Array Top) valueG)] - (and (n.= +3 (array;size valueG)) - (let [_tag (:! Integer (maybe;assume (array;read +0 valueG))) - _last? (array;read +1 valueG) - _value (:! Top (maybe;assume (array;read +2 valueG)))] + (case> (#e;Success valueT) + (let [valueT (:! (Array Top) valueT)] + (and (n.= +3 (array;size valueT)) + (let [_tag (:! Integer (maybe;assume (array;read +0 valueT))) + _last? (array;read +1 valueT) + _value (:! Top (maybe;assume (array;read +2 valueT)))] (and (n.= tag (|> _tag host;i2l int-to-nat)) (case _last? (#;Some _last?') diff --git a/new-luxc/test/tests.lux b/new-luxc/test/tests.lux index 5ec79d1e5..88d89ad90 100644 --- a/new-luxc/test/tests.lux +++ b/new-luxc/test/tests.lux @@ -19,14 +19,14 @@ (case ["_;S" special]) ["_;S" function] ["_;S" procedure] - ["_;S" loop])) - (generator ["_;G" primitive] - ["_;G" structure] - ["_;G" case] - ["_;G" function] - ["_;G" reference] - (procedure ["_;G" common] - ["_;G" host])) + ["_;S" loop]) + (translation ["_;T" primitive] + ["_;T" structure] + ["_;T" case] + ["_;T" function] + ["_;T" reference] + (procedure ["_;T" common] + ["_;T" host]))) ))) (program: args |