diff options
Diffstat (limited to 'lux-jvm/source/luxc')
8 files changed, 37 insertions, 110 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) |