diff options
author | Eduardo Julian | 2019-04-07 17:49:35 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-04-07 17:49:35 -0400 |
commit | a4e0eb58480a05e4c23a07d33965022125c539f2 (patch) | |
tree | 751b2dd5f6154b5940df39a3cb16c49868cd6551 /new-luxc/source/luxc/lang/translation/jvm.lux | |
parent | a61c3f2e7bc29c3224264317b14254fe93d503fe (diff) |
Updated the JVM compiler to the latest changes.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/jvm.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm.lux | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/new-luxc/source/luxc/lang/translation/jvm.lux b/new-luxc/source/luxc/lang/translation/jvm.lux index d1d1a9f4c..4d2031d12 100644 --- a/new-luxc/source/luxc/lang/translation/jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm.lux @@ -1,12 +1,15 @@ (.module: [lux (#- Definition) + [abstract + [monad (#+ do)]] [control pipe - [monad (#+ do)] ["ex" exception (#+ exception:)] + ["." io (#+ IO io)] [concurrency ["." atom (#+ Atom atom)]]] [data + ["." product] ["." error (#+ Error)] ["." text ("#/." hash) format] @@ -17,14 +20,11 @@ ["." host (#+ import: do-to object) [jvm ["." loader (#+ Library)]]] - ["." io (#+ IO io)] [world [binary (#+ Binary)]] [tool [compiler - ["." name] - [phase - ["." translation]]]]] + ["." name]]]] [/// [host ["." jvm (#+ Inst Definition Host State) @@ -85,7 +85,7 @@ (def: class-path-separator ".") (def: (evaluate! library loader eval-class valueI) - (-> Library ClassLoader Text Inst (Error Any)) + (-> Library ClassLoader Text Inst (Error [Any Definition])) (let [bytecode-name (text.replace-all class-path-separator .module-separator eval-class) bytecode (def.class #jvm.V1_6 #jvm.Public jvm.noneC @@ -102,23 +102,31 @@ inst.RETURN))))] (io.run (do (error.with io.monad) [_ (loader.store eval-class bytecode library) - class (loader.load eval-class loader)] - (:: io.monad wrap (class-value eval-class class)))))) + class (loader.load eval-class loader) + value (:: io.monad wrap (class-value eval-class class))] + (wrap [value + [eval-class bytecode]]))))) (def: (execute! library loader temp-label [class-name class-bytecode]) (-> Library ClassLoader Text Definition (Error Any)) (io.run (do (error.with io.monad) - [_ (loader.store class-name class-bytecode library)] + [existing-class? (|> (atom.read library) + (:: io.monad map (dictionary.contains? class-name)) + (error.lift io.monad) + (: (IO (Error Bit)))) + _ (if ?existing-class + (wrap []) + (loader.store class-name class-bytecode library))] (loader.load class-name loader)))) (def: (define! library loader [module name] valueI) - (-> Library ClassLoader Name Inst (Error [Text Any])) + (-> Library ClassLoader Name Inst (Error [Text Any Definition])) (let [class-name (format (text.replace-all .module-separator class-path-separator module) class-path-separator (name.normalize name) "___" (%n (text/hash name)))] (do error.monad - [value (evaluate! library loader class-name valueI)] - (wrap [class-name value])))) + [[value definition] (evaluate! library loader class-name valueI)] + (wrap [class-name value definition])))) (def: #export host (IO Host) @@ -128,9 +136,14 @@ (structure (def: (evaluate! temp-label valueI) (let [eval-class (|> temp-label name.normalize (text.replace-all " " "$"))] - (..evaluate! library loader eval-class valueI))) - (def: execute! (..execute! library loader)) - (def: define! (..define! library loader))))))) + (:: error.monad map product.left + (..evaluate! library loader eval-class valueI)))) + + (def: execute! + (..execute! library loader)) + + (def: define! + (..define! library loader))))))) (def: #export runtime-class "LuxRuntime") (def: #export function-class "LuxFunction") |