aboutsummaryrefslogtreecommitdiff
path: root/lux-jvm/source
diff options
context:
space:
mode:
authorEduardo Julian2021-06-12 01:32:40 -0400
committerEduardo Julian2021-06-12 01:32:40 -0400
commitaf3e6e2cb011dc2ad9204440990731a2f272716d (patch)
tree3521c74b05fc5b3ddddbe901d32ace87dbb6c018 /lux-jvm/source
parent8f575da5095e3b259d4eb6b6f13d3e37ef1d38e4 (diff)
Constraining the year of the snapshot time in Aedifex.
Diffstat (limited to 'lux-jvm/source')
-rw-r--r--lux-jvm/source/luxc/lang/directive/jvm.lux2
-rw-r--r--lux-jvm/source/luxc/lang/host/jvm.lux14
-rw-r--r--lux-jvm/source/luxc/lang/host/jvm/def.lux22
-rw-r--r--lux-jvm/source/luxc/lang/host/jvm/inst.lux86
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm.lux2
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux4
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux4
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/function.lux2
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/primitive.lux2
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/runtime.lux22
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/structure.lux2
-rw-r--r--lux-jvm/source/program.lux42
12 files changed, 107 insertions, 97 deletions
diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux
index 0d258fd5a..4d5d88548 100644
--- a/lux-jvm/source/luxc/lang/directive/jvm.lux
+++ b/lux-jvm/source/luxc/lang/directive/jvm.lux
@@ -1,6 +1,6 @@
(.module:
[lux #*
- [host (#+ import:)]
+ [ffi (#+ import:)]
[type (#+ :share)]
[abstract
["." monad (#+ do)]]
diff --git a/lux-jvm/source/luxc/lang/host/jvm.lux b/lux-jvm/source/luxc/lang/host/jvm.lux
index c2a2a6f41..a50090c5d 100644
--- a/lux-jvm/source/luxc/lang/host/jvm.lux
+++ b/lux-jvm/source/luxc/lang/host/jvm.lux
@@ -1,11 +1,11 @@
(.module:
[lux (#- Definition Type)
- [host (#+ import:)]
+ [ffi (#+ import:)]
[abstract
monad]
[control
- ["p" parser
- ["s" code]]]
+ ["<>" parser
+ ["<.>" code]]]
[data
[binary (#+ Binary)]
[collection
@@ -84,10 +84,10 @@
(type: #export (Generator i)
(-> Phase Archive i (Operation Inst)))
-(syntax: (config: {type s.local_identifier}
- {none s.local_identifier}
- {++ s.local_identifier}
- {options (s.tuple (p.many s.local_identifier))})
+(syntax: (config: {type <code>.local_identifier}
+ {none <code>.local_identifier}
+ {++ <code>.local_identifier}
+ {options (<code>.tuple (<>.many <code>.local_identifier))})
(let [g!type (code.local_identifier type)
g!none (code.local_identifier none)
g!tags+ (list/map code.local_tag options)
diff --git a/lux-jvm/source/luxc/lang/host/jvm/def.lux b/lux-jvm/source/luxc/lang/host/jvm/def.lux
index 212d9d854..b2012006a 100644
--- a/lux-jvm/source/luxc/lang/host/jvm/def.lux
+++ b/lux-jvm/source/luxc/lang/host/jvm/def.lux
@@ -1,6 +1,6 @@
(.module:
[lux (#- Type)
- ["." host (#+ import: do_to)]
+ ["." ffi (#+ import: do_to)]
[control
["." function]]
[data
@@ -80,9 +80,9 @@
(def: (string_array values)
(-> (List Text) (Array Text))
- (let [output (host.array java/lang/String (list.size values))]
+ (let [output (ffi.array java/lang/String (list.size values))]
(exec (list@map (function (_ [idx value])
- (host.array_write idx value output))
+ (ffi.array_write idx value output))
(list.enumeration values))
output)))
@@ -168,7 +168,7 @@
[(def: #export (<name> version visibility config name constraints super interfaces
definitions)
(-> //.Version //.Visibility //.Class_Config Text (List Constraint) (Type Class) (List (Type Class)) //.Def
- (host.type [byte]))
+ (ffi.type [byte]))
(let [writer (|> (do_to (org/objectweb/asm/ClassWriter::new class_computes)
(org/objectweb/asm/ClassWriter::visit (version_flag version)
($_ i.+
@@ -197,7 +197,7 @@
(def: #export (interface version visibility config name constraints interfaces
definitions)
(-> //.Version //.Visibility //.Class_Config Text (List Constraint) (List (Type Class)) //.Def
- (host.type [byte]))
+ (ffi.type [byte]))
(let [writer (|> (do_to (org/objectweb/asm/ClassWriter::new class_computes)
(org/objectweb/asm/ClassWriter::visit (version_flag version)
($_ i.+
@@ -258,7 +258,7 @@
(..binary_name name)
(..descriptor type)
(..signature type)
- (host.null)
+ (ffi.null)
writer)
(org/objectweb/asm/FieldVisitor::visitEnd))]
writer)))
@@ -279,13 +279,13 @@
writer)))]
[boolean_field Bit type.boolean function.identity]
- [byte_field Int type.byte host.long_to_byte]
- [short_field Int type.short host.long_to_short]
- [int_field Int type.int host.long_to_int]
+ [byte_field Int type.byte ffi.long_to_byte]
+ [short_field Int type.short ffi.long_to_short]
+ [int_field Int type.int ffi.long_to_int]
[long_field Int type.long function.identity]
- [float_field Frac type.float host.double_to_float]
+ [float_field Frac type.float ffi.double_to_float]
[double_field Frac type.double function.identity]
- [char_field Nat type.char (|>> .int host.long_to_int host.int_to_char)]
+ [char_field Nat type.char (|>> .int ffi.long_to_int ffi.int_to_char)]
[string_field Text (type.class "java.lang.String" (list)) function.identity]
)
diff --git a/lux-jvm/source/luxc/lang/host/jvm/inst.lux b/lux-jvm/source/luxc/lang/host/jvm/inst.lux
index 1f9e93c71..efc4a0d0c 100644
--- a/lux-jvm/source/luxc/lang/host/jvm/inst.lux
+++ b/lux-jvm/source/luxc/lang/host/jvm/inst.lux
@@ -1,6 +1,6 @@
(.module:
[lux (#- Type int char)
- ["." host (#+ import: do_to)]
+ ["." ffi (#+ import: do_to)]
[abstract
[monad (#+ do)]]
[control
@@ -162,13 +162,13 @@
(-> <type> Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitLdcInsn (<prepare> value)))))]
+ (org/objectweb/asm/MethodVisitor::visitLdcInsn (<prepare> value)))))]
[boolean Bit function.identity]
- [int Int host.long_to_int]
+ [int Int ffi.long_to_int]
[long Int function.identity]
[double Frac function.identity]
- [char Nat (|>> .int host.long_to_int host.int_to_char)]
+ [char Nat (|>> .int ffi.long_to_int ffi.int_to_char)]
[string Text function.identity]
)
@@ -180,7 +180,7 @@
Inst
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitInsn (!prefix <constant>)))))]
+ (org/objectweb/asm/MethodVisitor::visitInsn (!prefix <constant>)))))]
[ICONST_M1] [ICONST_0] [ICONST_1] [ICONST_2] [ICONST_3] [ICONST_4] [ICONST_5]
[LCONST_0] [LCONST_1]
@@ -192,14 +192,14 @@
Inst
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitInsn (!prefix ACONST_NULL)))))
+ (org/objectweb/asm/MethodVisitor::visitInsn (!prefix ACONST_NULL)))))
(template [<constant>]
[(def: #export (<constant> constant)
(-> Int Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitIntInsn (!prefix <constant>) constant))))]
+ (org/objectweb/asm/MethodVisitor::visitIntInsn (!prefix <constant>) constant))))]
[BIPUSH]
[SIPUSH]
@@ -210,7 +210,7 @@
Inst
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitInsn (!prefix <name>)))))]
+ (org/objectweb/asm/MethodVisitor::visitInsn (!prefix <name>)))))]
[NOP]
@@ -273,7 +273,7 @@
(-> Register Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitVarInsn (!prefix <name>) (.int register)))))]
+ (org/objectweb/asm/MethodVisitor::visitVarInsn (!prefix <name>) (.int register)))))]
[IINC]
[ILOAD] [LLOAD] [FLOAD] [DLOAD] [ALOAD]
@@ -285,7 +285,7 @@
(-> (Type Class) Text (Type Value) Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitFieldInsn (<inst>) (..class_name class) field (..descriptor type)))))]
+ (org/objectweb/asm/MethodVisitor::visitFieldInsn (<inst>) (..class_name class) field (..descriptor type)))))]
[GETSTATIC org/objectweb/asm/Opcodes::GETSTATIC]
[PUTSTATIC org/objectweb/asm/Opcodes::PUTSTATIC]
@@ -300,7 +300,7 @@
(-> (Type <category>) Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitTypeInsn (<inst>) (..class_name class)))))]
+ (org/objectweb/asm/MethodVisitor::visitTypeInsn (<inst>) (..class_name class)))))]
(~~ (template.splice <instructions>+))))]
@@ -317,31 +317,31 @@
(-> (Type Primitive) Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitIntInsn (org/objectweb/asm/Opcodes::NEWARRAY)
- (`` (cond (~~ (template [<descriptor> <opcode>]
- [(type@= <descriptor> type) (<opcode>)]
-
- [type.boolean org/objectweb/asm/Opcodes::T_BOOLEAN]
- [type.byte org/objectweb/asm/Opcodes::T_BYTE]
- [type.short org/objectweb/asm/Opcodes::T_SHORT]
- [type.int org/objectweb/asm/Opcodes::T_INT]
- [type.long org/objectweb/asm/Opcodes::T_LONG]
- [type.float org/objectweb/asm/Opcodes::T_FLOAT]
- [type.double org/objectweb/asm/Opcodes::T_DOUBLE]
- [type.char org/objectweb/asm/Opcodes::T_CHAR]))
- ## else
- (undefined)))))))
+ (org/objectweb/asm/MethodVisitor::visitIntInsn (org/objectweb/asm/Opcodes::NEWARRAY)
+ (`` (cond (~~ (template [<descriptor> <opcode>]
+ [(type@= <descriptor> type) (<opcode>)]
+
+ [type.boolean org/objectweb/asm/Opcodes::T_BOOLEAN]
+ [type.byte org/objectweb/asm/Opcodes::T_BYTE]
+ [type.short org/objectweb/asm/Opcodes::T_SHORT]
+ [type.int org/objectweb/asm/Opcodes::T_INT]
+ [type.long org/objectweb/asm/Opcodes::T_LONG]
+ [type.float org/objectweb/asm/Opcodes::T_FLOAT]
+ [type.double org/objectweb/asm/Opcodes::T_DOUBLE]
+ [type.char org/objectweb/asm/Opcodes::T_CHAR]))
+ ## else
+ (undefined)))))))
(template [<name> <inst> <interface?>]
[(def: #export (<name> class method_name method)
(-> (Type Class) Text (Type Method) Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitMethodInsn (<inst>)
- (..class_name class)
- method_name
- (|> method type.descriptor descriptor.descriptor)
- <interface?>))))]
+ (org/objectweb/asm/MethodVisitor::visitMethodInsn (<inst>)
+ (..class_name class)
+ method_name
+ (|> method type.descriptor descriptor.descriptor)
+ <interface?>))))]
[INVOKESTATIC org/objectweb/asm/Opcodes::INVOKESTATIC false]
[INVOKEVIRTUAL org/objectweb/asm/Opcodes::INVOKEVIRTUAL false]
@@ -354,7 +354,7 @@
(-> //.Label Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitJumpInsn (!prefix <name>) @where))))]
+ (org/objectweb/asm/MethodVisitor::visitJumpInsn (!prefix <name>) @where))))]
[IF_ICMPEQ] [IF_ICMPGT] [IF_ICMPLT]
[IF_ICMPNE] [IF_ICMPGE] [IF_ICMPLE]
@@ -370,45 +370,45 @@
(i.< (product.left left) (product.left right)))
keys+labels)
array_size (list.size keys+labels)
- keys_array (host.array int array_size)
- labels_array (host.array org/objectweb/asm/Label array_size)
+ keys_array (ffi.array int array_size)
+ labels_array (ffi.array org/objectweb/asm/Label array_size)
_ (loop [idx 0]
(if (n.< array_size idx)
(let [[key label] (maybe.assume (list.nth idx keys+labels))]
(exec
- (host.array_write idx (host.long_to_int key) keys_array)
- (host.array_write idx label labels_array)
+ (ffi.array_write idx (ffi.long_to_int key) keys_array)
+ (ffi.array_write idx label labels_array)
(recur (inc idx))))
[]))]
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitLookupSwitchInsn default keys_array labels_array)))))
+ (org/objectweb/asm/MethodVisitor::visitLookupSwitchInsn default keys_array labels_array)))))
(def: #export (TABLESWITCH min max default labels)
(-> Int Int //.Label (List //.Label) Inst)
(function (_ visitor)
(let [num_labels (list.size labels)
- labels_array (host.array org/objectweb/asm/Label num_labels)
+ labels_array (ffi.array org/objectweb/asm/Label num_labels)
_ (loop [idx 0]
(if (n.< num_labels idx)
- (exec (host.array_write idx
- (maybe.assume (list.nth idx labels))
- labels_array)
+ (exec (ffi.array_write idx
+ (maybe.assume (list.nth idx labels))
+ labels_array)
(recur (inc idx)))
[]))]
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitTableSwitchInsn min max default labels_array)))))
+ (org/objectweb/asm/MethodVisitor::visitTableSwitchInsn min max default labels_array)))))
(def: #export (try @from @to @handler exception)
(-> //.Label //.Label //.Label (Type Class) Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitTryCatchBlock @from @to @handler (..class_name exception)))))
+ (org/objectweb/asm/MethodVisitor::visitTryCatchBlock @from @to @handler (..class_name exception)))))
(def: #export (label @label)
(-> //.Label Inst)
(function (_ visitor)
(do_to visitor
- (org/objectweb/asm/MethodVisitor::visitLabel @label))))
+ (org/objectweb/asm/MethodVisitor::visitLabel @label))))
(def: #export (array elementT)
(-> (Type Value) Inst)
diff --git a/lux-jvm/source/luxc/lang/translation/jvm.lux b/lux-jvm/source/luxc/lang/translation/jvm.lux
index 84eff942e..fe651adac 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm.lux
@@ -1,6 +1,6 @@
(.module:
[lux (#- Module Definition)
- ["." host (#+ import: do_to object)]
+ ["." ffi (#+ import: do_to object)]
[abstract
[monad (#+ do)]]
[control
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux
index c9eed9489..c15d1ffcf 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux
@@ -1,5 +1,6 @@
(.module:
[lux (#- Type)
+ [ffi (#+ import:)]
[abstract
["." monad (#+ do)]]
[control
@@ -30,8 +31,7 @@
[extension (#+ Nullary Unary Binary Trinary Variadic
nullary unary binary trinary variadic)]]
["." extension
- ["." bundle]]]]]]]
- [host (#+ import:)]]
+ ["." bundle]]]]]]]]
[luxc
[lang
[host
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
index c3c522bfa..dc579c970 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
@@ -1,6 +1,6 @@
(.module:
[lux (#- Type primitive int char type)
- [host (#+ import:)]
+ [ffi (#+ import:)]
[abstract
["." monad (#+ do)]]
[control
@@ -1048,7 +1048,7 @@
(..with_anonymous_init class total_environment super_class inputsTI)
method_definitions))]]
_ (generation.execute! directive)
- _ (generation.save! (%.nat artifact_id) directive)]
+ _ (generation.save! artifact_id directive)]
(..anonymous_instance generate archive class total_environment)))]))
(def: bundle::class
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
index 6c03bd482..0b441c92f 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
@@ -316,7 +316,7 @@
//.$Function (list)
functionD)]]
_ (generation.execute! directive)
- _ (generation.save! (%.nat (product.right function_context)) directive)]
+ _ (generation.save! (product.right function_context) directive)]
(wrap instanceI)))
(def: #export (call generate archive [functionS argsS])
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
index b42f63c4d..3383e3856 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux
@@ -1,6 +1,6 @@
(.module:
[lux (#- i64)
- ["." host (#+ import:)]
+ ["." ffi (#+ import:)]
[math
[number
["i" int]]]
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
index 782187339..95cfd9e5a 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
@@ -20,7 +20,7 @@
["." category (#+ Void Value' Value Return' Return Primitive Object Class Array Var Parameter Method)]
["." reflection]]]]
[tool
- [compiler (#+ Output)
+ [compiler
[arity (#+ Arity)]
["." phase]
[language
@@ -28,7 +28,7 @@
["." synthesis]
["." generation]]]
[meta
- [archive
+ [archive (#+ Output)
["." artifact (#+ Registry)]]]]]]
[luxc
[lang
@@ -334,8 +334,11 @@
(-> (Type (<| Return' Value' category)) Text))
(|>> type.reflection reflection.reflection))
+(def: runtime_id
+ 0)
+
(def: translate_runtime
- (Operation [Text Binary])
+ (Operation [artifact.ID Binary])
(let [runtime_class (..reflection //.$Runtime)
bytecode ($d.class #$.V1_6 #$.Public $.finalC runtime_class (list) (type.class "java.lang.Object" (list)) (list)
(|>> adt_methods
@@ -345,11 +348,14 @@
directive [runtime_class bytecode]]
(do phase.monad
[_ (generation.execute! directive)
- _ (generation.save! "0" directive)]
- (wrap ["0" bytecode]))))
+ _ (generation.save! ..runtime_id directive)]
+ (wrap [..runtime_id bytecode]))))
+
+(def: function_id
+ 1)
(def: translate_function
- (Operation [Text Binary])
+ (Operation [artifact.ID Binary])
(let [applyI (|> (enum.range n.enum 2 num_apply_variants)
(list@map (function (_ arity)
($d.method #$.Public $.noneM apply_method (apply_signature arity)
@@ -379,8 +385,8 @@
directive [function_class bytecode]]
(do phase.monad
[_ (generation.execute! directive)
- _ (generation.save! "1" directive)]
- (wrap ["1" bytecode]))))
+ _ (generation.save! ..function_id directive)]
+ (wrap [..function_id bytecode]))))
(def: #export translate
(Operation [Registry Output])
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/structure.lux b/lux-jvm/source/luxc/lang/translation/jvm/structure.lux
index b3daed102..100bce9d9 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/structure.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/structure.lux
@@ -1,6 +1,6 @@
(.module:
[lux (#- Type)
- ["." host (#+ import:)]
+ ["." ffi (#+ import:)]
[abstract
["." monad (#+ do)]]
[control
diff --git a/lux-jvm/source/program.lux b/lux-jvm/source/program.lux
index f6a921e86..baa76ac31 100644
--- a/lux-jvm/source/program.lux
+++ b/lux-jvm/source/program.lux
@@ -159,22 +159,26 @@
(promise.future (\ world/program.default exit +0)))
(program: [{service /cli.service}]
- (exec (do promise.monad
- [_ (/.compiler {#/static.host @.jvm
- #/static.host_module_extension ".jvm"
- #/static.target (/cli.target service)
- #/static.artifact_extension ".class"}
- ..expander
- analysis.bundle
- ..platform
- ## generation.bundle
- translation.bundle
- (directive.bundle ..extender)
- (jvm/program.program jvm/runtime.class_name)
- [_.Anchor _.Inst _.Definition]
- ..extender
- service
- [packager.package
- (format (/cli.target service) (\ file.default separator) "program.jar")])]
- (..declare_success! []))
- (io.io [])))
+ (let [static {#/static.host @.jvm
+ #/static.host_module_extension ".jvm"
+ #/static.target (/cli.target service)
+ #/static.artifact_extension ".class"}]
+ (exec (do promise.monad
+ [_ (/.compiler {#/static.host @.jvm
+ #/static.host_module_extension ".jvm"
+ #/static.target (/cli.target service)
+ #/static.artifact_extension ".class"}
+ ..expander
+ analysis.bundle
+ ..platform
+ ## generation.bundle
+ translation.bundle
+ (directive.bundle ..extender)
+ (jvm/program.program jvm/runtime.class_name)
+ [_.Anchor _.Inst _.Definition]
+ ..extender
+ service
+ [(packager.package static)
+ (format (/cli.target service) (\ file.default separator) "program.jar")])]
+ (..declare_success! []))
+ (io.io []))))