diff options
author | Eduardo Julian | 2019-03-02 23:55:31 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-03-02 23:55:31 -0400 |
commit | d117adb8fd8869cdff9c9ba0f9e5f14304c285d8 (patch) | |
tree | 920044c08b9262a728dca183d216c7c87f7a68a7 /stdlib/source | |
parent | 8a629bbbb0bd4950fb0f3c6d14c1a9a0ba057174 (diff) |
Small fixes and improvements.
Diffstat (limited to 'stdlib/source')
7 files changed, 31 insertions, 34 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 9d3ca2032..9a90885b9 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -1,21 +1,21 @@ +("lux def" dummy-cursor + ["" 0 0] + [["" 0 0] + (10 (1 [[["" 0 0] (7 ["lux" "export?"])] + [["" 0 0] (0 #1)]] + (0)))]) + ("lux def" double-quote ("lux int char" +34) - [["" 0 0] (10 (0))]) + [dummy-cursor (10 (0))]) ("lux def" new-line ("lux int char" +10) - [["" 0 0] (10 (0))]) + [dummy-cursor (10 (0))]) ("lux def" __paragraph ("lux text concat" new-line new-line) - [["" 0 0] (10 (0))]) - -("lux def" dummy-cursor - ["" 0 0] - [["" 0 0] - (10 (1 [[["" 0 0] (7 ["lux" "export?"])] - [["" 0 0] (0 #1)]] - (0)))]) + [dummy-cursor (10 (0))]) ## (type: Any ## (Ex [a] a)) diff --git a/stdlib/source/lux/host/js.lux b/stdlib/source/lux/host/js.lux index e61ce7985..d50fd29a8 100644 --- a/stdlib/source/lux/host/js.lux +++ b/stdlib/source/lux/host/js.lux @@ -84,7 +84,7 @@ (def: #export string (-> Text Computation) - (|>> ..sanitize %t ..argument :abstraction)) + (|>> ..sanitize %t :abstraction)) (def: argument-separator ", ") (def: field-separator ": ") diff --git a/stdlib/source/lux/tool/compiler/phase/translation/common/reference.lux b/stdlib/source/lux/tool/compiler/phase/translation/common/reference.lux index 033effdfe..7cd24b23d 100644 --- a/stdlib/source/lux/tool/compiler/phase/translation/common/reference.lux +++ b/stdlib/source/lux/tool/compiler/phase/translation/common/reference.lux @@ -32,7 +32,7 @@ (All [expression] (-> Text (-> Text expression) (-> Register expression))) - (|>> .int %i (format prefix) variable)) + (|>> %n (format prefix) variable)) (def: #export foreign (All [expression] diff --git a/stdlib/source/lux/tool/compiler/phase/translation/js/case.lux b/stdlib/source/lux/tool/compiler/phase/translation/js/case.lux index 0eee5383b..499486ff9 100644 --- a/stdlib/source/lux/tool/compiler/phase/translation/js/case.lux +++ b/stdlib/source/lux/tool/compiler/phase/translation/js/case.lux @@ -32,10 +32,11 @@ (do ////.monad [valueO (translate valueS) bodyO (translate bodyS)] - (wrap (<| (_.closure (list)) - ($_ _.then - (_.define (..register register) valueO) - (_.return bodyO)))))) + (wrap (_.apply/* (<| (_.closure (list)) + ($_ _.then + (_.define (..register register) valueO) + (_.return bodyO))) + (list))))) (def: #export (record-get translate valueS pathP) (-> Phase Synthesis (List [Nat Bit]) diff --git a/stdlib/source/lux/tool/compiler/phase/translation/js/function.lux b/stdlib/source/lux/tool/compiler/phase/translation/js/function.lux index 741e66573..5c17ed3d3 100644 --- a/stdlib/source/lux/tool/compiler/phase/translation/js/function.lux +++ b/stdlib/source/lux/tool/compiler/phase/translation/js/function.lux @@ -103,7 +103,7 @@ (_.define @curried all-inputs) (_.return (_.closure (list) (let [@missing all-inputs] - (_.return (apply-poly (_.do ".concat" (list @missing) @curried) + (_.return (apply-poly (_.do "concat" (list @missing) @curried) @self)))))))) ))) )) diff --git a/stdlib/source/lux/tool/compiler/phase/translation/js/runtime.lux b/stdlib/source/lux/tool/compiler/phase/translation/js/runtime.lux index a7b8a5a05..e2014c064 100644 --- a/stdlib/source/lux/tool/compiler/phase/translation/js/runtime.lux +++ b/stdlib/source/lux/tool/compiler/phase/translation/js/runtime.lux @@ -17,7 +17,9 @@ ["_" js (#+ Expression Var Computation Statement)]]] ["." /// ["//." // - ["." synthesis]]] + ["." synthesis] + [// + ["/////." name]]]] ) (do-template [<name> <base>] @@ -69,23 +71,14 @@ (-> Expression Computation) (..variant (_.i32 +1) (flag #1))) -(def: sanitize - (-> Text Text) - (|>> (text.replace-all "/" "_SL") - (text.replace-all "-" "_DS") - (text.replace-all "^" "_CR") - (text.replace-all "=" "_EQ") - (text.replace-all "+" "_PL") - (text.replace-all "*" "_ST"))) - (def: variable (-> Text Var) - (|>> ..sanitize + (|>> /////name.normalize _.var)) (def: runtime-name (-> Text Var) - (|>> ..sanitize + (|>> /////name.normalize (format prefix "$") _.var)) @@ -101,7 +94,7 @@ (wrap (list (` (let [(~+ (|> vars (list/map (function (_ var) (list (code.local-identifier var) - (` (_.var (~ (code.text var))))))) + (` (_.var (~ (code.text (/////name.normalize var)))))))) list.concat))] (~ body)))))) @@ -233,8 +226,8 @@ @sum//get )) -(def: #export i64-high-field Text "H") -(def: #export i64-low-field Text "L") +(def: #export i64-high-field Text "_lux_high") +(def: #export i64-low-field Text "_lux_low") (runtime: (i64//new high low) (_.return (_.object (list [..i64-high-field high] @@ -594,8 +587,8 @@ @i64//2^64 @i64//2^63 @i64//unsigned-low - @i64//zero @i64//new + @i64//zero @i64//min @i64//max @i64//one diff --git a/stdlib/source/lux/tool/compiler/phase/translation/js/structure.lux b/stdlib/source/lux/tool/compiler/phase/translation/js/structure.lux index ec60f6292..5a3a24175 100644 --- a/stdlib/source/lux/tool/compiler/phase/translation/js/structure.lux +++ b/stdlib/source/lux/tool/compiler/phase/translation/js/structure.lux @@ -28,5 +28,8 @@ (def: #export (variant translate [lefts right? valueS]) (-> Phase (Variant Synthesis) (Operation Expression)) (:: ////.monad map - (//runtime.variant (_.i32 (.int lefts)) (//runtime.flag right?)) + (//runtime.variant (_.i32 (.int (if right? + (inc lefts) + lefts))) + (//runtime.flag right?)) (translate valueS))) |