diff options
Diffstat (limited to '')
8 files changed, 81 insertions, 56 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js.lux b/new-luxc/source/luxc/lang/translation/js.lux index c0cf2d0dd..db76a2868 100644 --- a/new-luxc/source/luxc/lang/translation/js.lux +++ b/new-luxc/source/luxc/lang/translation/js.lux @@ -18,6 +18,18 @@ (host [js #+ JS Expression Statement])) [".C" io])) +(do-template [<name>] + [(exception: #export (<name> {message Text}) + message)] + + [No-Active-Module-Buffer] + [Cannot-Execute] + + [No-Anchor] + + [Unknown-Member] + ) + (host.import java/lang/Object (toString [] String)) @@ -79,7 +91,7 @@ (def: #export init-module-buffer (Meta Unit) - (function [compiler] + (function (_ compiler) (#e.Success [(update@ #.host (|>> (:! Host) (set@ #module-buffer (#.Some (StringBuilder::new []))) @@ -87,12 +99,9 @@ compiler) []]))) -(exception: #export No-Active-Module-Buffer) -(exception: #export Cannot-Execute) - (def: #export (with-sub-context expr) (All [a] (-> (Meta a) (Meta [Text a]))) - (function [compiler] + (function (_ compiler) (let [old (:! Host (get@ #.host compiler)) [old-name old-sub] (get@ #context old) new-name (format old-name "$" (%i (nat-to-int old-sub)))] @@ -112,7 +121,7 @@ (def: #export context (Meta Text) - (function [compiler] + (function (_ compiler) (#e.Success [compiler (|> (get@ #.host compiler) (:! Host) @@ -122,7 +131,7 @@ (def: #export (with-anchor anchor expr) (All [a] (-> Anchor (Meta a) (Meta a))) - (function [compiler] + (function (_ compiler) (let [old (:! Host (get@ #.host compiler))] (case (expr (set@ #.host (:! Void (set@ #anchor (#.Some anchor) old)) @@ -138,11 +147,9 @@ (#e.Error error) (#e.Error error))))) -(exception: #export No-Anchor) - (def: #export anchor (Meta Anchor) - (function [compiler] + (function (_ compiler) (case (|> compiler (get@ #.host) (:! Host) (get@ #anchor)) (#.Some anchor) (#e.Success [compiler anchor]) @@ -152,29 +159,29 @@ (def: #export module-buffer (Meta StringBuilder) - (function [compiler] + (function (_ compiler) (case (|> compiler (get@ #.host) (:! Host) (get@ #module-buffer)) #.None - ((lang.fail (No-Active-Module-Buffer "")) compiler) + ((lang.throw No-Active-Module-Buffer "") compiler) (#.Some module-buffer) (#e.Success [compiler module-buffer])))) (def: #export program-buffer (Meta StringBuilder) - (function [compiler] + (function (_ compiler) (#e.Success [compiler (|> compiler (get@ #.host) (:! Host) (get@ #program-buffer))]))) (def: (execute code) (-> Expression (Meta Unit)) - (function [compiler] + (function (_ compiler) (case (|> compiler (get@ #.host) (:! Host) (get@ #interpreter) (ScriptEngine::eval [code])) (#e.Error error) - ((lang.fail (Cannot-Execute error)) compiler) + ((lang.throw Cannot-Execute error) compiler) (#e.Success _) (#e.Success [compiler []])))) @@ -202,8 +209,6 @@ (nat-to-int (array.size value))])))) )) -(exception: #export Unknown-Member) - (def: #export int-high-field Text "H") (def: #export int-low-field Text "L") @@ -242,8 +247,9 @@ (|> value int-to-nat low jvm-int) ## else - (error! (Unknown-Member (format " member = " member "\n" - "object(int) = " (%i value) "\n"))))))) + (error! (ex.construct Unknown-Member + (format " member = " member "\n" + "object(int) = " (%i value) "\n"))))))) (interface: StructureValue (getValue [] (Array Object))) @@ -281,8 +287,8 @@ (::slice js-object value))) ## else - (error! (Unknown-Member (format " member = " (:! Text member) "\n" - "object(structure) = " (Object::toString [] (:! Object value)) "\n"))))) + (error! (ex.construct Unknown-Member (format " member = " (:! Text member) "\n" + "object(structure) = " (Object::toString [] (:! Object value)) "\n"))))) (AbstractJSObject (getSlot [idx int]) Object (|> value (array.read (|> idx (Integer::longValue []) (:! Nat))) diff --git a/new-luxc/source/luxc/lang/translation/js/case.jvm.lux b/new-luxc/source/luxc/lang/translation/js/case.jvm.lux index 7c624c102..45b6ec10e 100644 --- a/new-luxc/source/luxc/lang/translation/js/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/case.jvm.lux @@ -29,7 +29,7 @@ (Meta Expression)) (do macro.Monad<Meta> [valueJS (translate valueS)] - (wrap (list/fold (function [[idx tail?] source] + (wrap (list/fold (function (_ [idx tail?] source) (let [method (if tail? runtimeT.product//right runtimeT.product//left)] (format method "(" source "," (|> idx nat-to-int %i) ")"))) (format "(" valueJS ")") @@ -76,7 +76,8 @@ Statement (format "throw " pm-error ";")) -(exception: #export Unrecognized-Path) +(exception: #export (Unrecognized-Path {message Text}) + message) (def: (translate-pattern-matching' translate path) (-> (-> ls.Synthesis (Meta Expression)) Code (Meta Expression)) diff --git a/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux b/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux index d4546ca4c..3d4dbc782 100644 --- a/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux @@ -11,6 +11,16 @@ (lang (host [js #+ JS Expression Statement]))) [//]) +(do-template [<name>] + [(exception: #export (<name> {message Text}) + message)] + + [Unknown-Kind-Of-JS-Object] + [Null-Has-No-Lux-Representation] + + [Cannot-Evaluate] + ) + (host.import java/lang/Object (toString [] String)) @@ -101,9 +111,6 @@ (#.Some output)))) #.None)) -(exception: #export Unknown-Kind-Of-JS-Object) -(exception: #export Null-Has-No-Lux-Representation) - (def: (lux-object js-object) (-> Object (Error Top)) (`` (cond (host.null? js-object) @@ -152,11 +159,9 @@ ## else (ex.throw Unknown-Kind-Of-JS-Object (Object::toString [] (:! Object js-object)))))) -(exception: #export Cannot-Evaluate) - (def: #export (eval code) (-> Expression (Meta Top)) - (function [compiler] + (function (_ compiler) (case (|> compiler (get@ #.host) (:! //.Host) diff --git a/new-luxc/source/luxc/lang/translation/js/expression.jvm.lux b/new-luxc/source/luxc/lang/translation/js/expression.jvm.lux index 9fbaca3d2..ba6c63e8f 100644 --- a/new-luxc/source/luxc/lang/translation/js/expression.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/expression.jvm.lux @@ -22,8 +22,13 @@ [".T" case] [".T" procedure])) -(exception: #export Invalid-Function-Syntax) -(exception: #export Unrecognized-Synthesis) +(do-template [<name>] + [(exception: #export (<name> {message Text}) + message)] + + [Invalid-Function-Syntax] + [Unrecognized-Synthesis] + ) (def: #export (translate synthesis) (-> ls.Synthesis (Meta Expression)) diff --git a/new-luxc/source/luxc/lang/translation/js/imports.jvm.lux b/new-luxc/source/luxc/lang/translation/js/imports.jvm.lux index 725aff705..64f10dabc 100644 --- a/new-luxc/source/luxc/lang/translation/js/imports.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/imports.jvm.lux @@ -14,9 +14,14 @@ (luxc [lang] (lang [".L" module]))) -(exception: #export Invalid-Imports) -(exception: #export Module-Cannot-Import-Itself) -(exception: #export Circular-Dependency) +(do-template [<name>] + [(exception: #export (<name> {message Text}) + message)] + + [Invalid-Imports] + [Module-Cannot-Import-Itself] + [Circular-Dependency] + ) (type: Import {#module Text @@ -39,7 +44,7 @@ (#e.Error error) (lang.throw Invalid-Imports (%code (code.tuple imports))))) - _ (monad.map @ (function [[dependency alias]] + _ (monad.map @ (function (_ [dependency alias]) (do @ [_ (lang.assert Module-Cannot-Import-Itself current-module (not (text/= current-module dependency))) @@ -58,7 +63,7 @@ imports) compiler macro.get-compiler] (wrap (monad.fold io.Monad<Process> - (function [import] + (function (_ import) (translate-module (get@ #module import))) compiler imports)))) diff --git a/new-luxc/source/luxc/lang/translation/js/procedure.jvm.lux b/new-luxc/source/luxc/lang/translation/js/procedure.jvm.lux index afedc42e0..f67c1e523 100644 --- a/new-luxc/source/luxc/lang/translation/js/procedure.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/procedure.jvm.lux @@ -12,7 +12,8 @@ (/ ["/." common] ["/." host])) -(exception: #export Unknown-Procedure) +(exception: #export (Unknown-Procedure {message Text}) + message) (def: procedures /common.Bundle diff --git a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux index 8b45557cd..365f730e3 100644 --- a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux @@ -51,7 +51,7 @@ (-> Text Bundle Bundle) (|> bundle dict.entries - (list/map (function [[key val]] [(format prefix " " key) val])) + (list/map (function (_ [key val]) [(format prefix " " key) val])) (dict.from-list text.Hash<Text>))) (def: (wrong-arity proc expected actual) @@ -61,19 +61,19 @@ " Actual: " (|> actual nat-to-int %i))) (syntax: (arity: [name s.local-symbol] [arity s.nat]) - (with-gensyms [g!proc g!name g!translate g!inputs] + (with-gensyms [g!_ g!proc g!name g!translate g!inputs] (do @ [g!input+ (monad.seq @ (list.repeat arity (macro.gensym "input")))] (wrap (list (` (def: #export ((~ (code.local-symbol name)) (~ g!proc)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) (-> Text ..Proc)) - (function [(~ g!name)] - (function [(~ g!translate) (~ g!inputs)] + (function ((~ g!_) (~ g!name)) + (function ((~ g!_) (~ g!translate) (~ g!inputs)) (case (~ g!inputs) (^ (list (~+ g!input+))) (do macro.Monad<Meta> [(~+ (|> g!input+ - (list/map (function [g!input] + (list/map (function (_ g!input) (list g!input (` ((~ g!translate) (~ g!input)))))) list.concat))] ((~' wrap) ((~ g!proc) [(~+ g!input+)]))) @@ -88,8 +88,8 @@ (def: #export (variadic proc) (-> Variadic (-> Text Proc)) - (function [proc-name] - (function [translate inputsS] + (function (_ proc-name) + (function (_ translate inputsS) (do macro.Monad<Meta> [inputsI (monad.map @ translate inputsS)] (wrap (proc inputsI)))))) @@ -120,7 +120,9 @@ Unary valueJS) -(exception: #export Wrong-Syntax) +(exception: #export (Wrong-Syntax {message Text}) + message) + (def: #export (wrong-syntax procedure args) (-> Text (List ls.Synthesis) Text) (format "Procedure: " procedure "\n" @@ -128,8 +130,8 @@ (def: lux//loop (-> Text Proc) - (function [proc-name] - (function [translate inputsS] + (function (_ proc-name) + (function (_ translate inputsS) (case (s.run inputsS ($_ p.seq s.nat (s.tuple (p.many s.any)) s.any)) (#e.Success [offset initsS+ bodyS]) (loopT.translate-loop translate offset initsS+ bodyS) @@ -140,8 +142,8 @@ (def: lux//recur (-> Text Proc) - (function [proc-name] - (function [translate inputsS] + (function (_ proc-name) + (function (_ translate inputsS) (loopT.translate-recur translate inputsS)))) ## [[Bits]] diff --git a/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux index 2104dbf81..ea1b82e98 100644 --- a/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux @@ -63,7 +63,7 @@ (`` (def: ((~' ~~) (runtime-implementation-name <lux-name>)) Runtime (feature <lux-name> - (function [(~' @)] + (function ((~' _) (~' @)) <js-definition>))))) (def: #export (int value) @@ -475,13 +475,13 @@ (runtime: int/// "divI64" (let [negate (|>> (list) (js.apply int//negate)) - negative? (function [value] + negative? (function (_ value) (js.apply int//< (list value int//zero))) valid-division-check [(=I int//zero "parameter") (js.throw! (js.string "Cannot divide by zero!"))] short-circuit-check [(=I int//zero "subject") (js.return! int//zero)] - recur (function [subject parameter] + recur (function (_ subject parameter) (js.apply @ (list subject parameter)))] (js.function @ (list "subject" "parameter") (list (js.cond! (list valid-division-check @@ -585,9 +585,9 @@ __int//%)) (runtime: nat//< "ltN64" - (let [high (function [i64] (format "(" i64 "." //.int-high-field ")")) - low (function [i64] (format "(" i64 "." //.int-low-field ")")) - i32 (function [word] (format "(" word " >>> 0)"))] + (let [high (function (_ i64) (format "(" i64 "." //.int-high-field ")")) + low (function (_ i64) (format "(" i64 "." //.int-low-field ")")) + i32 (function (_ word) (format "(" word " >>> 0)"))] (js.function @ (list "subject" "parameter") (list (js.return! (js.or (js.> (i32 (high "subject")) (i32 (high "parameter"))) @@ -615,7 +615,7 @@ (js.apply int//= (list subject param)))) (runtime: nat/// "divN64" - (let [negative? (function [value] + (let [negative? (function (_ value) (js.apply int//< (list value int//zero))) valid-division-check [(=I int//zero "parameter") (js.throw! (js.string "Cannot divide by zero!"))] |