aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation
diff options
context:
space:
mode:
authorEduardo Julian2020-04-18 04:10:45 -0400
committerEduardo Julian2020-04-18 04:10:45 -0400
commit4955cfe6f248a039e95b404f26abfae04204740f (patch)
treec86f33b80a6fe944e4aff78641f91bb66103bd91 /new-luxc/source/luxc/lang/translation
parentae72864af3e95e46a042277873d38c3006361c79 (diff)
Generating module IDs in a similar way to artifact IDs.
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm.lux20
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/expression.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/extension/host.lux6
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/function.lux27
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/reference.lux16
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/runtime.lux4
6 files changed, 37 insertions, 38 deletions
diff --git a/new-luxc/source/luxc/lang/translation/jvm.lux b/new-luxc/source/luxc/lang/translation/jvm.lux
index 390b1497d..569da0bd9 100644
--- a/new-luxc/source/luxc/lang/translation/jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/jvm.lux
@@ -25,6 +25,9 @@
["." descriptor]]]]
[tool
[compiler
+ [language
+ [lux
+ ["." generation]]]
[meta
[archive
[descriptor (#+ Module)]
@@ -98,14 +101,9 @@
## It should be cleaned up ASAP.
(def: prefix "lux.")
-(def: #export class-name'
- (-> Text Text)
- (|>> (text.replace-all .module-separator ..class-path-separator)
- (format ..prefix)))
-
-(def: #export (class-name module id)
- (-> Module artifact.ID Text)
- (format (..class-name' module) ..class-path-separator (%.nat id)))
+(def: #export (class-name [module-id artifact-id])
+ (-> generation.Context Text)
+ (format ..prefix (%.nat module-id) ..class-path-separator (%.nat artifact-id)))
(def: (evaluate! library loader eval-class valueI)
(-> Library ClassLoader Text Inst (Try [Any Definition]))
@@ -142,9 +140,9 @@
(loader.store class-name class-bytecode library))]
(loader.load class-name loader))))
-(def: (define! library loader module id valueI)
- (-> Library ClassLoader Module artifact.ID Inst (Try [Text Any Definition]))
- (let [class-name (..class-name module id)]
+(def: (define! library loader context valueI)
+ (-> Library ClassLoader generation.Context Inst (Try [Text Any Definition]))
+ (let [class-name (..class-name context)]
(do try.monad
[[value definition] (evaluate! library loader class-name valueI)]
(wrap [class-name value definition]))))
diff --git a/new-luxc/source/luxc/lang/translation/jvm/expression.lux b/new-luxc/source/luxc/lang/translation/jvm/expression.lux
index 441758fec..144e35f9b 100644
--- a/new-luxc/source/luxc/lang/translation/jvm/expression.lux
+++ b/new-luxc/source/luxc/lang/translation/jvm/expression.lux
@@ -42,7 +42,7 @@
(structure.tuple translate archive members)
(^ (synthesis.variable variable))
- (reference.variable variable)
+ (reference.variable archive variable)
(^ (synthesis.constant constant))
(reference.constant archive constant)
diff --git a/new-luxc/source/luxc/lang/translation/jvm/extension/host.lux b/new-luxc/source/luxc/lang/translation/jvm/extension/host.lux
index cf039db68..408b2a389 100644
--- a/new-luxc/source/luxc/lang/translation/jvm/extension/host.lux
+++ b/new-luxc/source/luxc/lang/translation/jvm/extension/host.lux
@@ -908,10 +908,10 @@
store-capturedI
_.RETURN))))
-(def: (anonymous-instance class env)
- (-> (Type Class) Environment (Operation Inst))
+(def: (anonymous-instance archive class env)
+ (-> Archive (Type Class) Environment (Operation Inst))
(do phase.monad
- [captureI+ (monad.map @ ///reference.variable env)]
+ [captureI+ (monad.map @ (///reference.variable archive) env)]
(wrap (|>> (_.NEW class)
_.DUP
(_.fuse captureI+)
diff --git a/new-luxc/source/luxc/lang/translation/jvm/function.lux b/new-luxc/source/luxc/lang/translation/jvm/function.lux
index 449855aca..fa91b41df 100644
--- a/new-luxc/source/luxc/lang/translation/jvm/function.lux
+++ b/new-luxc/source/luxc/lang/translation/jvm/function.lux
@@ -6,6 +6,9 @@
[pipe (#+ when> new>)]
["." function]]
[data
+ ["." product]
+ [text
+ ["%" format (#+ format)]]
[number
["n" nat]
["i" int]]
@@ -24,7 +27,9 @@
[lux
[analysis (#+ Environment)]
[synthesis (#+ Synthesis Abstraction Apply)]
- ["." generation]]]]]]
+ ["." generation]]]
+ [meta
+ [archive (#+ Archive)]]]]]
[luxc
[lang
[host
@@ -96,10 +101,10 @@
(list.repeat amount)
_.fuse))
-(def: (instance class arity env)
- (-> (Type Class) Arity Environment (Operation Inst))
+(def: (instance archive class arity env)
+ (-> Archive (Type Class) Arity Environment (Operation Inst))
(do phase.monad
- [captureI+ (monad.map @ reference.variable env)
+ [captureI+ (monad.map @ (reference.variable archive) env)
#let [argsI (if (poly-arg? arity)
(|> (nullsI (dec arity))
(list (_.int +0))
@@ -266,8 +271,8 @@
def.fuse)
function.identity))
-(def: #export (with-function @begin class env arity bodyI)
- (-> Label Text Environment Arity Inst
+(def: #export (with-function archive @begin class env arity bodyI)
+ (-> Archive Label Text Environment Arity Inst
(Operation [Def Inst]))
(let [classD (type.class class (list))
applyD (: Def
@@ -290,19 +295,19 @@
applyD
))]
(do phase.monad
- [instanceI (instance classD arity env)]
+ [instanceI (instance archive classD arity env)]
(wrap [functionD instanceI]))))
(def: #export (function generate archive [env arity bodyS])
(Generator Abstraction)
(do phase.monad
[@begin _.make-label
- [function-context bodyI] (generation.with-new-context
+ [function-context bodyI] (generation.with-new-context archive
(generation.with-anchor [@begin 1]
(generate archive bodyS)))
- #let [function-class (//runtime.class-name function-context)]
- [functionD instanceI] (with-function @begin function-class env arity bodyI)
- _ (generation.save! true ["" function-class]
+ #let [function-class (//.class-name function-context)]
+ [functionD instanceI] (with-function archive @begin function-class env arity bodyI)
+ _ (generation.save! true ["" (%.nat (product.right function-context))]
[function-class
(def.class #$.V1_6 #$.Public $.finalC
function-class (list)
diff --git a/new-luxc/source/luxc/lang/translation/jvm/reference.lux b/new-luxc/source/luxc/lang/translation/jvm/reference.lux
index ff5d7a96c..4eafecec0 100644
--- a/new-luxc/source/luxc/lang/translation/jvm/reference.lux
+++ b/new-luxc/source/luxc/lang/translation/jvm/reference.lux
@@ -34,11 +34,11 @@
[partial-name "p"]
)
-(def: (foreign variable)
- (-> Register (Operation Inst))
+(def: (foreign archive variable)
+ (-> Archive Register (Operation Inst))
(do phase.monad
- [class-name (:: @ map //runtime.class-name
- generation.context)]
+ [class-name (:: @ map //.class-name
+ (generation.context archive))]
(wrap (|>> (_.ALOAD 0)
(_.GETFIELD (type.class class-name (list))
(|> variable .nat foreign-name)
@@ -48,18 +48,18 @@
(-> Register Inst)
(|>> _.ALOAD))
-(def: #export (variable variable)
- (-> Variable (Operation Inst))
+(def: #export (variable archive variable)
+ (-> Archive Variable (Operation Inst))
(case variable
(#reference.Local variable)
(operation@wrap (local variable))
(#reference.Foreign variable)
- (foreign variable)))
+ (foreign archive variable)))
(def: #export (constant archive name)
(-> Archive Name (Operation Inst))
(do phase.monad
- [class-name (:: @ map //runtime.class-name
+ [class-name (:: @ map //.class-name
(generation.remember archive name))]
(wrap (_.GETSTATIC (type.class class-name (list)) //.value-field //.$Value))))
diff --git a/new-luxc/source/luxc/lang/translation/jvm/runtime.lux b/new-luxc/source/luxc/lang/translation/jvm/runtime.lux
index 7d6c5427e..55c0aaab1 100644
--- a/new-luxc/source/luxc/lang/translation/jvm/runtime.lux
+++ b/new-luxc/source/luxc/lang/translation/jvm/runtime.lux
@@ -29,10 +29,6 @@
["_" inst]]]]]
["." // (#+ ByteCode)])
-(def: #export (class-name [module id])
- (-> generation.Context Text)
- (//.class-name module id))
-
(def: $Text (type.class "java.lang.String" (list)))
(def: #export $Tag type.int)
(def: #export $Flag (type.class "java.lang.Object" (list)))