aboutsummaryrefslogtreecommitdiff
path: root/lux-jvm/source
diff options
context:
space:
mode:
Diffstat (limited to 'lux-jvm/source')
-rw-r--r--lux-jvm/source/luxc/lang/directive/jvm.lux6
-rw-r--r--lux-jvm/source/luxc/lang/host/jvm.lux6
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm.lux6
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/common.lux74
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/expression.lux1
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux6
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/function.lux18
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/runtime.lux30
-rw-r--r--lux-jvm/source/program.lux16
9 files changed, 45 insertions, 118 deletions
diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux
index 7b1b35b52..6063d0df0 100644
--- a/lux-jvm/source/luxc/lang/directive/jvm.lux
+++ b/lux-jvm/source/luxc/lang/directive/jvm.lux
@@ -1464,9 +1464,9 @@
(list#each ..constraint type_variables)
supers
(|> method_declarations
- (list#each (function (_ (^slots [#name #annotations #type_variables #exceptions #arguments #return]))
- (def.abstract_method {jvm.#Public} jvm.noneM name
- (/type.method [type_variables arguments return exceptions]))))
+ (list#each (function (_ (^open "_[0]"))
+ (def.abstract_method {jvm.#Public} jvm.noneM _#name
+ (/type.method [_#type_variables _#arguments _#return _#exceptions]))))
def.fuse))]]]
(directive.lifted_generation
(do !
diff --git a/lux-jvm/source/luxc/lang/host/jvm.lux b/lux-jvm/source/luxc/lang/host/jvm.lux
index 600f26dd7..dc4a3b351 100644
--- a/lux-jvm/source/luxc/lang/host/jvm.lux
+++ b/lux-jvm/source/luxc/lang/host/jvm.lux
@@ -9,6 +9,8 @@
["<[0]>" code]]]
[data
[binary {"+" Binary}]
+ [text
+ ["%" format {"+" format}]]
[collection
["[0]" list ("[1]#[0]" monad)]]]
[macro
@@ -96,14 +98,14 @@
options (<code>.tuple (<>.many <code>.local_identifier))])
(let [g!type (code.local_identifier type)
g!none (code.local_identifier none)
- g!tags+ (list#each code.local_tag options)
+ g!tags+ (list#each (|>> (format "#") code.local_identifier) options)
g!_left (code.local_identifier "_left")
g!_right (code.local_identifier "_right")
g!options+ (list#each (function (_ option)
(` (def: .public (~ (code.local_identifier option))
(~ g!type)
(|> (~ g!none)
- (with@ (~ (code.local_tag option)) #1)))))
+ (with@ (~ (code.local_identifier (format "#" option))) #1)))))
options)]
(in (list& (` (type: .public (~ g!type)
(.Record
diff --git a/lux-jvm/source/luxc/lang/translation/jvm.lux b/lux-jvm/source/luxc/lang/translation/jvm.lux
index b3ae09176..5fee195d4 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm.lux
@@ -164,14 +164,14 @@
[loader
(: Host
(implementation
- (def: (evaluate! context valueI)
+ (def: (evaluate context valueI)
(# try.monad each product.left
(..evaluate! library loader context valueI)))
- (def: execute!
+ (def: execute
(..execute! library loader))
- (def: define!
+ (def: define
(..define! library loader))
(def: (ingest context bytecode)
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/common.lux
deleted file mode 100644
index 57f3ee822..000000000
--- a/lux-jvm/source/luxc/lang/translation/jvm/common.lux
+++ /dev/null
@@ -1,74 +0,0 @@
-(.module:
- [library
- ... [lux "*"
- ... [abstract
- ... [monad {"+" do}]]
- ... [control
- ... ["[0]" try {"+" Try}]
- ... ["ex" exception {"+" exception:}]
- ... ["[0]" io]]
- ... [data
- ... [binary {"+" Binary}]
- ... ["[0]" text {"+" \n} ("[1]#[0]" hash)
- ... format]
- ... [collection
- ... ["[0]" dictionary {"+" Dictionary}]]]
- ... ["[0]" macro]
- ... [host {"+" import:}]
- ... [tool
- ... [compiler
- ... [reference {"+" Register}]
- ... ["[0]" name]
- ... ["[0]" phase]]]
- ... ]
- ]
- ... [luxc
- ... [lang
- ... [host
- ... ["[0]" jvm
- ... [type]]]]]
- )
-
-... (def: .public (with-artifacts action)
-... (All (_ a) (-> (Meta a) (Meta [Artifacts a])))
-... (function (_ state)
-... (case (action (revised@ .#host
-... (|>> (:coerce Host)
-... (with@ #artifacts (dictionary.new text.hash))
-... (:coerce Nothing))
-... state))
-... {try.#Success [state' output]}
-... {try.#Success [(revised@ .#host
-... (|>> (:coerce Host)
-... (with@ #artifacts (|> (value@ .#host state) (:coerce Host) (value@ #artifacts)))
-... (:coerce Nothing))
-... state')
-... [(|> state' (value@ .#host) (:coerce Host) (value@ #artifacts))
-... output]]}
-
-... {try.#Failure error}
-... {try.#Failure error})))
-
-... (def: .public (load-definition state)
-... (-> Lux (-> Name Binary (Try Any)))
-... (function (_ (^@ def-name [def-module def-name]) def-bytecode)
-... (let [normal-name (format (name.normalize def-name) (%n (text#hash def-name)))
-... class-name (format (text.replace-all "/" "." def-module) "." normal-name)]
-... (<| (macro.result state)
-... (do macro.monad
-... [_ (..store-class class-name def-bytecode)
-... class (..load-class class-name)]
-... (case (do try.monad
-... [field (Class::getField [..value-field] class)]
-... (Field::get [{.#None}] field))
-... {try.#Success {.#Some def-value}}
-... (wrap def-value)
-
-... {try.#Success {.#None}}
-... (phase.throw invalid-definition-value (%name def-name))
-
-... {try.#Failure error}
-... (phase.throw cannot-load-definition
-... (format "Definition: " (%name def-name) \n
-... "Error:" \n
-... error))))))))
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/expression.lux b/lux-jvm/source/luxc/lang/translation/jvm/expression.lux
index c2dfe0ace..de8ac3c12 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/expression.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/expression.lux
@@ -13,7 +13,6 @@
[host
[jvm {"+" Phase}]]]]
[//
- ["[0]" common]
["[0]" primitive]
["[0]" structure]
["[0]" reference]
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 137633847..e32e35869 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
@@ -980,7 +980,7 @@
(_.ALOAD (++ register))
(_.PUTFIELD class (///reference.foreign_name register) $Object))))
_.fuse)]
- (_def.method #$.Public $.noneM "<init>" (anonymous_init_method env)
+ (_def.method {$.#Public} $.noneM "<init>" (anonymous_init_method env)
(|>> (_.ALOAD 0)
((_.fuse (list#each product.right inputsTI)))
(_.INVOKESPECIAL super_class "<init>" (type.method [(list) (list#each product.left inputsTI) type.void (list)]))
@@ -1132,7 +1132,7 @@
[bodyG (generation.with_context artifact_id
(generate archive bodyS))
.let [argumentsT (list#each product.right arguments)]]
- (in (_def.method #$.Public
+ (in (_def.method {$.#Public}
(if strict_fp?
($_ $.++M $.finalM $.strictM)
$.finalM)
@@ -1143,7 +1143,7 @@
(returnI returnT)))))))
(# ! each _def.fuse))
.let [directive [anonymous_class_name
- (_def.class #$.V1_6 #$.Public $.finalC
+ (_def.class {$.#V1_6} {$.#Public} $.finalC
anonymous_class_name (list)
super_class super_interfaces
(|>> (///function.with_environment total_environment)
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
index fc8670946..17a246833 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
@@ -127,7 +127,7 @@
(def: (with_reset class arity env)
(-> (Type Class) Arity (Environment Synthesis) Def)
- (def.method #$.Public $.noneM "reset" (reset_method class)
+ (def.method {$.#Public} $.noneM "reset" (reset_method class)
(if (poly_arg? arity)
(let [env_size (list.size env)
captureI (|> (case env_size
@@ -151,7 +151,7 @@
(def: (with_implementation arity @begin bodyI)
(-> Nat Label Inst Def)
- (def.method #$.Public $.strictM "impl" (implementation_method arity)
+ (def.method {$.#Public} $.strictM "impl" (implementation_method arity)
(|>> (_.label @begin)
bodyI
_.ARETURN)))
@@ -189,7 +189,7 @@
(_.PUTFIELD class (reference.partial_name idx) //.$Value)))))
_.fuse)
function.identity)]
- (def.method #$.Public $.noneM "<init>" (init_method env arity)
+ (def.method {$.#Public} $.noneM "<init>" (init_method env arity)
(|>> (_.ALOAD 0)
(function_init arity env_size)
store_capturedI
@@ -253,7 +253,7 @@
_.ARETURN))
))))
_.fuse)]
- (def.method #$.Public $.noneM //runtime.apply_method (//runtime.apply_signature apply_arity)
+ (def.method {$.#Public} $.noneM //runtime.apply_method (//runtime.apply_signature apply_arity)
(|>> get_amount_of_partialsI
(_.TABLESWITCH +0 (|> num_partials -- .int)
@default @labels)
@@ -264,7 +264,7 @@
(-> (Environment Synthesis) Def)
(|>> list.enumeration
(list@each (.function (_ [env_idx env_source])
- (def.field #$.Private $.finalF (reference.foreign_name env_idx) //.$Value)))
+ (def.field {$.#Private} $.finalF (reference.foreign_name env_idx) //.$Value)))
def.fuse))
(def: (with_partial arity)
@@ -272,7 +272,7 @@
(if (poly_arg? arity)
(|> (enum.range n.enum 0 (n.- 2 arity))
(list@each (.function (_ idx)
- (def.field #$.Private $.finalF (reference.partial_name idx) //.$Value)))
+ (def.field {$.#Private} $.finalF (reference.partial_name idx) //.$Value)))
def.fuse)
function.identity))
@@ -287,12 +287,12 @@
(list@each (with_apply classD env arity @begin bodyI))
(list& (with_implementation arity @begin bodyI))
def.fuse)
- (def.method #$.Public $.strictM //runtime.apply_method (//runtime.apply_signature 1)
+ (def.method {$.#Public} $.strictM //runtime.apply_method (//runtime.apply_signature 1)
(|>> (_.label @begin)
bodyI
_.ARETURN))))
functionD (: Def
- (|>> (def.int_field #$.Public ($_ $.++F $.staticF $.finalF) arity_field (.int arity))
+ (|>> (def.int_field {$.#Public} ($_ $.++F $.staticF $.finalF) arity_field (.int arity))
(with_environment env)
(with_partial arity)
(with_init classD env arity)
@@ -322,7 +322,7 @@
.let [function_class (//.class_name function_context)]
[functionD instanceI] (..with_function generate archive @begin function_class env arity bodyI)
.let [directive [function_class
- (def.class #$.V1_6 #$.Public $.finalC
+ (def.class {$.#V1_6} {$.#Public} $.finalC
function_class (list)
//.$Function (list)
functionD)]]
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
index cb62ddb4b..ae14639f0 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
@@ -122,7 +122,7 @@
(let [store_leftsI (|>> _.DUP _.ICONST_0 (_.ILOAD 0) (_.wrap type.int) _.AASTORE)
store_flagI (|>> _.DUP _.ICONST_1 (_.ALOAD 1) _.AASTORE)
store_valueI (|>> _.DUP _.ICONST_2 (_.ALOAD 2) _.AASTORE)]
- (|>> ($d.method #$.Public $.staticM "variant_make"
+ (|>> ($d.method {$.#Public} $.staticM "variant_make"
(type.method [(list) (list $Lefts $Right? $Value) //.$Variant (list)])
(|>> _.ICONST_3
(_.ANEWARRAY $Value)
@@ -133,7 +133,7 @@
(def: frac_methods
Def
- (|>> ($d.method #$.Public $.staticM "decode_frac" (type.method [(list) (list $Text) //.$Variant (list)])
+ (|>> ($d.method {$.#Public} $.staticM "decode_frac" (type.method [(list) (list $Text) //.$Variant (list)])
(tryI
(|>> (_.ALOAD 0)
(_.INVOKESTATIC (type.class "java.lang.Double" (list)) "parseDouble" (type.method [(list) (list $Text) type.double (list)]))
@@ -169,13 +169,13 @@
(|>> sub_leftsI (_.ISTORE 1)
sub_tupleI (_.ASTORE 0)
(_.GOTO @loop))))]
- (|>> ($d.method #$.Public $.staticM "pm_fail" throw_methodT
+ (|>> ($d.method {$.#Public} $.staticM "pm_fail" throw_methodT
(|>> (illegal_state_exception "Invalid expression for pattern-matching.")
_.ATHROW))
- ($d.method #$.Public $.staticM "apply_fail" throw_methodT
+ ($d.method {$.#Public} $.staticM "apply_fail" throw_methodT
(|>> (illegal_state_exception "Error while applying function.")
_.ATHROW))
- ($d.method #$.Public $.staticM "pm_push" (type.method [(list) (list $Stack $Value) $Stack (list)])
+ ($d.method {$.#Public} $.staticM "pm_push" (type.method [(list) (list $Stack $Value) $Stack (list)])
(|>> _.ICONST_2
(_.ANEWARRAY $Value)
_.DUP
@@ -187,7 +187,7 @@
(_.ALOAD 1)
_.AASTORE
_.ARETURN))
- ($d.method #$.Public $.staticM "pm_variant" (type.method [(list) (list //.$Variant $Lefts $Right?) $Value (list)])
+ ($d.method {$.#Public} $.staticM "pm_variant" (type.method [(list) (list //.$Variant $Lefts $Right?) $Value (list)])
(<| _.with_label (function (_ @loop))
_.with_label (function (_ @perfect_match!))
_.with_label (function (_ @lefts_match!))
@@ -261,7 +261,7 @@
... _.POP2
$variant ::value
_.ARETURN)))
- ($d.method #$.Public $.staticM "tuple_left" (type.method [(list) (list //.$Tuple $Index) $Value (list)])
+ ($d.method {$.#Public} $.staticM "tuple_left" (type.method [(list) (list //.$Tuple $Index) $Value (list)])
(<| _.with_label (function (_ @loop))
_.with_label (function (_ @recursive))
(let [left_accessI (|>> (_.ALOAD 0) left_indexI _.AALOAD)])
@@ -272,7 +272,7 @@
(_.label @recursive)
... Recursive
(recurI @loop))))
- ($d.method #$.Public $.staticM "tuple_right" (type.method [(list) (list //.$Tuple $Index) $Value (list)])
+ ($d.method {$.#Public} $.staticM "tuple_right" (type.method [(list) (list //.$Tuple $Index) $Value (list)])
(<| _.with_label (function (_ @loop))
_.with_label (function (_ @not_tail))
_.with_label (function (_ @slice))
@@ -323,7 +323,7 @@
(_.boolean true)
(_.INVOKESPECIAL PrintWriter "<init>" (type.method [(list) (list (type.class "java.io.Writer" (list)) type.boolean) type.void (list)]))
)]
- (|>> ($d.method #$.Public $.staticM "try" ..try
+ (|>> ($d.method {$.#Public} $.staticM "try" ..try
(<| _.with_label (function (_ @from))
_.with_label (function (_ @to))
_.with_label (function (_ @handler))
@@ -356,7 +356,7 @@
(def: translate_runtime
(Operation [artifact.ID (Maybe Text) Binary])
(let [runtime_class (..reflection //.$Runtime)
- bytecode ($d.class #$.V1_6 #$.Public $.finalC runtime_class (list) (type.class "java.lang.Object" (list)) (list)
+ bytecode ($d.class {$.#V1_6} {$.#Public} $.finalC runtime_class (list) (type.class "java.lang.Object" (list)) (list)
(|>> adt_methods
frac_methods
pm_methods
@@ -374,7 +374,7 @@
(Operation [artifact.ID (Maybe Text) Binary])
(let [applyI (|> (enum.range n.enum 2 num_apply_variants)
(list@each (function (_ arity)
- ($d.method #$.Public $.noneM apply_method (apply_signature arity)
+ ($d.method {$.#Public} $.noneM apply_method (apply_signature arity)
(let [preI (|> (enum.range n.enum 0 (-- arity))
(list@each _.ALOAD)
_.fuse)]
@@ -384,13 +384,13 @@
(_.ALOAD arity)
(_.INVOKEVIRTUAL //.$Function apply_method (apply_signature 1))
_.ARETURN)))))
- (list& ($d.abstract_method #$.Public $.noneM apply_method (apply_signature 1)))
+ (list& ($d.abstract_method {$.#Public} $.noneM apply_method (apply_signature 1)))
$d.fuse)
$Object (type.class "java.lang.Object" (list))
function_class (..reflection //.$Function)
- bytecode ($d.abstract #$.V1_6 #$.Public $.noneC function_class (list) $Object (list)
- (|>> ($d.field #$.Public $.finalF partials_field type.int)
- ($d.method #$.Public $.noneM "<init>" (type.method [(list) (list type.int) type.void (list)])
+ bytecode ($d.abstract {$.#V1_6} {$.#Public} $.noneC function_class (list) $Object (list)
+ (|>> ($d.field {$.#Public} $.finalF partials_field type.int)
+ ($d.method {$.#Public} $.noneM "<init>" (type.method [(list) (list type.int) type.void (list)])
(|>> (_.ALOAD 0)
(_.INVOKESPECIAL $Object "<init>" nullary_init_methodT)
(_.ALOAD 0)
diff --git a/lux-jvm/source/program.lux b/lux-jvm/source/program.lux
index 4484db653..79205fd84 100644
--- a/lux-jvm/source/program.lux
+++ b/lux-jvm/source/program.lux
@@ -144,27 +144,27 @@
unwrap_long (: (-> Synthesis Synthesis)
(|>> (list ($.text jvm/type/box.long)
($.text "long"))
- {#$.Extension "jvm object cast"}))
+ {$.#Extension "jvm object cast"}))
long_to_int (: (-> Synthesis Synthesis)
(|>> (list)
- {#$.Extension "jvm conversion long-to-int"}))
+ {$.#Extension "jvm conversion long-to-int"}))
literal_nat (: (-> Nat Synthesis)
(|>> .i64 $.i64 unwrap_long long_to_int))
write! (: (-> Text Nat Synthesis Synthesis Synthesis)
(function (_ element_class index value array)
- {#$.Extension "jvm array write object"
+ {$.#Extension "jvm array write object"
(list (jvm_type (jvm/type.array (jvm/type.class element_class (list))))
(literal_nat index)
value
array)}))
object_array (: (-> Text Nat Synthesis)
(function (_ class_name size)
- {#$.Extension "jvm array new object"
+ {$.#Extension "jvm array new object"
(list (class_type class_name)
(literal_nat size))}))
class_of (: (-> Synthesis Synthesis)
(function (_ object)
- {#$.Extension "jvm member invoke virtual"
+ {$.#Extension "jvm member invoke virtual"
(list& (class_type "java.lang.Object")
($.text "getClass")
(class_type "java.lang.Class")
@@ -174,7 +174,7 @@
(function (_ value_type value)
($.tuple (list (jvm_type value_type) value))))
- example_object {#$.Extension "jvm member invoke constructor"
+ example_object {$.#Extension "jvm member invoke constructor"
(list& (class_type "java.lang.Object")
(list))}
phase_arity 3
@@ -182,7 +182,7 @@
$archive ($.variable/local 2)
$input ($.variable/local 3)
$state ($.variable/local 4)
- apply_method {#$.Extension "jvm member invoke virtual"
+ apply_method {$.#Extension "jvm member invoke virtual"
(list& (class_type "java.lang.Class")
($.text "getMethod")
(class_type "java.lang.reflect.Method")
@@ -194,7 +194,7 @@
(write! "java.lang.Class" 0 (class_of example_object))
(write! "java.lang.Class" 1 (class_of example_object))
(write! "java.lang.Class" 2 (class_of example_object))))))}]
- {#$.Extension "jvm member invoke virtual"
+ {$.#Extension "jvm member invoke virtual"
(list& (class_type "java.lang.reflect.Method")
($.text "invoke")
(class_type "java.lang.Object")