diff options
Diffstat (limited to 'new-luxc/source/luxc/lang/translation')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm.lux | 27 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux | 2 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm/primitive.jvm.lux | 9 |
3 files changed, 26 insertions, 12 deletions
diff --git a/new-luxc/source/luxc/lang/translation/jvm.lux b/new-luxc/source/luxc/lang/translation/jvm.lux index 8f4af43c6..3fd3d389b 100644 --- a/new-luxc/source/luxc/lang/translation/jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm.lux @@ -8,7 +8,7 @@ ["." atom (#+ Atom atom)]] [data ["." error (#+ Error)] - ["." text + ["." text ("text/." Hash<Text>) format] [collection ["." array] @@ -160,13 +160,16 @@ (#error.Error error) (ex.throw invalid-field [class-name ..value-field]))) -(def: (evaluate! store loader temp-label valueI) +(def: module-separator "/") +(def: class-path-separator ".") + +(def: (evaluate! store loader eval-class valueI) (-> Store ClassLoader Text Inst (Error Any)) (do error.Monad<Error> - [#let [eval-class (|> temp-label name.normalize (text.replace-all " " "$")) + [#let [bytecode-name (text.replace-all class-path-separator module-separator eval-class) bytecode (def.class #jvm.V1_6 #jvm.Public jvm.noneC - eval-class + bytecode-name (list) ["java.lang.Object" (list)] (list) (|>> (def.field #jvm.Public ($_ jvm.++F jvm.finalF jvm.staticF) @@ -175,7 +178,7 @@ "<clinit>" (type.method (list) #.None (list)) (|>> valueI - (inst.PUTSTATIC eval-class ..value-field ..$Object) + (inst.PUTSTATIC bytecode-name ..value-field ..$Object) inst.RETURN))))] _ (..store! eval-class bytecode store) class (..load! eval-class loader)] @@ -187,14 +190,24 @@ [_ (..store! class-name class-bytecode store)] (..load! class-name loader))) +(def: (define! store loader [module name] valueI) + (-> Store ClassLoader Name Inst (Error Any)) + (let [class-name (format (text.replace-all module-separator class-path-separator module) + class-path-separator (name.normalize name) + "___" (%n (text/hash name)))] + (evaluate! store loader class-name valueI))) + (def: #export init (IO Host) (io (let [store (: Store (atom (dictionary.new text.Hash<Text>))) loader (memory-class-loader store)] (: Host (structure - (def: evaluate! (..evaluate! store loader)) - (def: execute! (..execute! store loader))))))) + (def: (evaluate! temp-label valueI) + (let [eval-class (|> temp-label name.normalize (text.replace-all " " "$"))] + (..evaluate! store loader eval-class valueI))) + (def: execute! (..execute! store loader)) + (def: define! (..define! store loader))))))) (def: #export runtime-class "LuxRuntime") (def: #export function-class "LuxFunction") diff --git a/new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux index 0eb815458..4f3193bbf 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux @@ -77,7 +77,7 @@ (^ (synthesis.path/i64 value)) (operation/wrap (|>> peekI (_.unwrap #$.Long) - (_.long value) + (_.long (.int value)) _.LCMP (_.IFNE @else))) diff --git a/new-luxc/source/luxc/lang/translation/jvm/primitive.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/primitive.jvm.lux index c32e80d56..c46d4d495 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/primitive.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/primitive.jvm.lux @@ -24,9 +24,10 @@ (do-template [<name> <type> <load> <wrap>] [(def: #export (<name> value) (-> <type> (Operation Inst)) - (operation/wrap (|>> (<load> value) <wrap>)))] + (let [loadI (|> value <load>)] + (operation/wrap (|>> loadI <wrap>))))] - [i64 Int _.long (_.wrap #jvm.Long)] - [f64 Frac _.double (_.wrap #jvm.Double)] - [text Text _.string (<|)] + [i64 (I64 Any) (<| _.long .int) (_.wrap #jvm.Long)] + [f64 Frac _.double (_.wrap #jvm.Double)] + [text Text _.string (<|)] ) |