diff options
author | Eduardo Julian | 2017-11-13 23:26:06 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-13 23:26:06 -0400 |
commit | 70005a6dee1eba3e3f5694aa4903e95988dcaa3d (patch) | |
tree | 19141f900847092c3aa5032a62b6b97eb1ea9a33 /new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux | |
parent | b08f7d83a591be770af64b4c9ccd59f3306689e8 (diff) |
- Refactoring.
- Now giving type checking/inference a higher priority.
- Better error messages.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux b/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux index 7168514c1..a5e06aac3 100644 --- a/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux @@ -10,7 +10,7 @@ ["l" lexer]) (coll [list "list/" Functor<List>] [dict #+ Dict])) - [meta #+ with-gensyms "meta/" Monad<Meta>] + [meta "meta/" Monad<Meta>] (meta [code] ["s" syntax #+ syntax:]) [host]) @@ -25,6 +25,15 @@ ["ls" synthesis])) ["@" ../common]) +(exception: #export Wrong-Syntax) +(def: (wrong-syntax procedure args) + (-> Text (List ls;Synthesis) Text) + (format "Procedure: " procedure "\n" + "Arguments: " (%code (code;tuple args)))) + +(exception: #export Invalid-Syntax-For-JVM-Type) +(exception: #export Invalid-Syntax-For-Argument-Generation) + (do-template [<name> <inst>] [(def: <name> $;Inst @@ -295,7 +304,7 @@ ($i;array arrayJT)))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: (array//read proc translate inputs) (-> Text @;Proc) @@ -321,7 +330,7 @@ loadI))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: (array//write proc translate inputs) (-> Text @;Proc) @@ -350,7 +359,7 @@ storeI))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: array-procs @;Bundle @@ -406,7 +415,7 @@ false)))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: (object//instance? proc translate inputs) (-> Text @;Proc) @@ -419,7 +428,7 @@ ($i;wrap #$;Boolean)))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: object-procs @;Bundle @@ -470,7 +479,7 @@ (wrap ($i;GETSTATIC class field ($t;class unboxed (list)))))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: (static//put proc translate inputs) (-> Text @;Proc) @@ -502,7 +511,7 @@ ($i;string hostL;unit))))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: (virtual//get proc translate inputs) (-> Text @;Proc) @@ -533,7 +542,7 @@ ($i;GETFIELD class field ($t;class unboxed (list))))))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: (virtual//put proc translate inputs) (-> Text @;Proc) @@ -570,9 +579,7 @@ ($i;PUTFIELD class field ($t;class unboxed (list))))))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) - -(exception: #export Invalid-Syntax-For-Argument-Generation) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: base-type (l;Lexer $;Type) @@ -601,7 +608,7 @@ (-> Text (Meta $;Type)) (case (l;run argD java-type) (#e;Error error) - (&;fail error) + (&;throw Invalid-Syntax-For-JVM-Type argD) (#e;Success type) (meta/wrap type))) @@ -647,7 +654,7 @@ (meta/wrap #;None) _ - (:: meta;Monad<Meta> map (|>. #;Some) (translate-type description)))) + (meta/map (|>. #;Some) (translate-type description)))) (def: (prepare-return returnT returnI) (-> (Maybe $;Type) $;Inst $;Inst) @@ -679,7 +686,7 @@ (wrap (prepare-return returnT callI))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (do-template [<name> <invoke> <interface?>] [(def: (<name> proc translate inputs) @@ -700,7 +707,7 @@ (wrap (prepare-return returnT callI))) _ - (&;fail (format "Wrong syntax for '" proc "'."))))] + (&;throw Wrong-Syntax (wrong-syntax proc inputs))))] [invoke//virtual $i;INVOKEVIRTUAL false] [invoke//special $i;INVOKESPECIAL false] @@ -721,7 +728,7 @@ false)))) _ - (&;fail (format "Wrong syntax for '" proc "'.")))) + (&;throw Wrong-Syntax (wrong-syntax proc inputs)))) (def: member-procs @;Bundle @@ -741,8 +748,7 @@ (@;install "virtual" invoke//virtual) (@;install "special" invoke//special) (@;install "interface" invoke//interface) - (@;install "constructor" invoke//constructor) - ))) + (@;install "constructor" invoke//constructor)))) ))) (def: #export procedures |