From c3cdaad1d13f38ec926e7113ae95a25611a04053 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 30 Jul 2018 21:27:26 -0400 Subject: Updating new-luxc to latest Lux changes [Part 1]. --- new-luxc/source/luxc/lang/translation/jvm.lux | 27 ++++++++++++++++------ .../source/luxc/lang/translation/jvm/case.jvm.lux | 2 +- .../luxc/lang/translation/jvm/primitive.jvm.lux | 9 ++++---- 3 files changed, 26 insertions(+), 12 deletions(-) (limited to 'new-luxc/source') 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) 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 - [#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 @@ "" (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))) 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 [ ] [(def: #export ( value) (-> (Operation Inst)) - (operation/wrap (|>> ( value) )))] + (let [loadI (|> value )] + (operation/wrap (|>> loadI ))))] - [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 (<|)] ) -- cgit v1.2.3