diff options
author | Eduardo Julian | 2018-07-18 23:44:29 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-07-18 23:44:29 -0400 |
commit | 8b4f0ded7bddaa42cf432f74523bfd6aa1e76fed (patch) | |
tree | 27840fac3765bf9f3411ca65dc1ef5d8de0b044b /new-luxc/source/luxc/lang/translation/jvm/reference.jvm.lux | |
parent | c99909d6f03d9968cdd81c8a5c7e254372a3afcd (diff) |
WIP: Fix new-luxc's JVM back-end.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/jvm/reference.jvm.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm/reference.jvm.lux | 78 |
1 files changed, 42 insertions, 36 deletions
diff --git a/new-luxc/source/luxc/lang/translation/jvm/reference.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/reference.jvm.lux index 9271efe8f..f82a674e3 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/reference.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/reference.jvm.lux @@ -1,49 +1,55 @@ (.module: - lux - (lux (control [monad #+ do]) - (data [text "text/" Hash<Text>] - text/format) - [macro "macro/" Monad<Meta>]) - (luxc ["&" lang] - (lang [".L" host] - (host ["$" jvm] - (jvm ["$t" type] - ["$i" inst])) - ["ls" synthesis] - [".L" variable #+ Variable])) - (// [".T" common])) + [lux #* + [control + [monad (#+ do)]] + [data + [text ("text/" Hash<Text>) + format]] + [language + ["." name] + ["." reference (#+ Register Variable)] + ["." compiler ("operation/" Monad<Operation>) + ["." translation]]]] + [luxc + [lang + [host + [jvm (#+ Inst Operation) + ["$t" type] + ["$i" inst]]]]] + ["." //]) (do-template [<name> <prefix>] - [(def: #export (<name> idx) + [(def: (<name> idx) (-> Nat Text) (|> idx .int %i (format <prefix>)))] - [captured "c"] - [partial "p"] + [foreign-name "f"] + [partial-name "p"] ) -(def: #export (translate-captured variable) - (-> Variable (Meta $.Inst)) - (do macro.Monad<Meta> - [this-module macro.current-module-name - function-class hostL.context - #let [function-class (format (text.replace-all "/" "." this-module) "." function-class)]] +(def: (foreign variable) + (-> Register (Operation Inst)) + (do compiler.Monad<Operation> + [function-class translation.context] (wrap (|>> ($i.ALOAD +0) ($i.GETFIELD function-class - (|> variable inc (i/* -1) .nat captured) - commonT.$Object))))) + (|> variable .nat foreign-name) + //.$Object))))) -(def: #export (translate-local variable) - (-> Variable (Meta $.Inst)) - (macro/wrap ($i.ALOAD (.nat variable)))) +(def: local + (-> Register (Operation Inst)) + (|>> $i.ALOAD operation/wrap)) -(def: #export (translate-variable variable) - (-> Variable (Meta $.Inst)) - (if (variableL.captured? variable) - (translate-captured variable) - (translate-local variable))) +(def: #export (variable variable) + (-> Variable (Operation Inst)) + (case variable + (#reference.Local variable) + (local variable) + + (#reference.Foreign variable) + (foreign variable))) -(def: #export (translate-definition [def-module def-name]) - (-> Ident (Meta $.Inst)) - (let [bytecode-name (format def-module "/" (&.normalize-name def-name) (%n (text/hash def-name)))] - (macro/wrap ($i.GETSTATIC bytecode-name commonT.value-field commonT.$Object)))) +(def: #export (constant [def-module def-name]) + (-> Ident (Operation Inst)) + (let [bytecode-name (format def-module "/" (name.normalize def-name) (%n (text/hash def-name)))] + (operation/wrap ($i.GETSTATIC bytecode-name //.value-field //.$Object)))) |