From ca238f9c89d3156842b0a3d5fe24a5d69b2eedb0 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 6 Apr 2018 08:32:41 -0400 Subject: - Adapted new-luxc's code to latest stdlib changes. --- .../source/luxc/lang/translation/js/case.jvm.lux | 5 +++-- .../source/luxc/lang/translation/js/eval.jvm.lux | 17 +++++++++----- .../luxc/lang/translation/js/expression.jvm.lux | 9 ++++++-- .../luxc/lang/translation/js/imports.jvm.lux | 15 ++++++++----- .../luxc/lang/translation/js/procedure.jvm.lux | 3 ++- .../lang/translation/js/procedure/common.jvm.lux | 26 ++++++++++++---------- .../luxc/lang/translation/js/runtime.jvm.lux | 14 ++++++------ 7 files changed, 54 insertions(+), 35 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/js') 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 [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 [] + [(exception: #export ( {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 [] + [(exception: #export ( {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 [] + [(exception: #export ( {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 - (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))) (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 [(~+ (|> 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 [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 )) Runtime (feature - (function [(~' @)] + (function ((~' _) (~' @)) ))))) (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!"))] -- cgit v1.2.3