diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/target/js.lux | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/stdlib/source/lux/target/js.lux b/stdlib/source/lux/target/js.lux index 687a6d632..ae3591668 100644 --- a/stdlib/source/lux/target/js.lux +++ b/stdlib/source/lux/target/js.lux @@ -20,8 +20,8 @@ (def: nest (-> Text Text) - (|>> (format text.new-line) - (text.replace-all text.new-line (format text.new-line text.tab)))) + (|>> (format text.new_line) + (text.replace_all text.new_line (format text.new_line text.tab)))) (abstract: #export (Code brand) Text @@ -68,13 +68,13 @@ (def: #export (number value) (-> Frac Literal) (:abstraction - (.cond (f.not-a-number? value) + (.cond (f.not_a_number? value) "NaN" - (f.= f.positive-infinity value) + (f.= f.positive_infinity value) "Infinity" - (f.= f.negative-infinity value) + (f.= f.negative_infinity value) "-Infinity" ## else @@ -83,35 +83,35 @@ (def: sanitize (-> Text Text) (`` (|>> (~~ (template [<replace> <find>] - [(text.replace-all <find> <replace>)] + [(text.replace_all <find> <replace>)] ["\\" "\"] ["\t" text.tab] - ["\v" text.vertical-tab] + ["\v" text.vertical_tab] ["\0" text.null] - ["\b" text.back-space] - ["\f" text.form-feed] - ["\n" text.new-line] - ["\r" text.carriage-return] - [(format "\" text.double-quote) - text.double-quote] + ["\b" text.back_space] + ["\f" text.form_feed] + ["\n" text.new_line] + ["\r" text.carriage_return] + [(format "\" text.double_quote) + text.double_quote] )) ))) (def: #export string (-> Text Literal) (|>> ..sanitize - (text.enclose [text.double-quote text.double-quote]) + (text.enclose [text.double_quote text.double_quote]) :abstraction)) - (def: argument-separator ", ") - (def: field-separator ": ") - (def: statement-suffix ";") + (def: argument_separator ", ") + (def: field_separator ": ") + (def: statement_suffix ";") (def: #export array (-> (List Expression) Computation) (|>> (list\map ..code) - (text.join-with ..argument-separator) + (text.join_with ..argument_separator) ..element :abstraction)) @@ -119,9 +119,9 @@ (-> Text Var) (|>> :abstraction)) - (def: #export (at index array-or-object) + (def: #export (at index array_or_object) (-> Expression Expression Access) - (:abstraction (format (:representation array-or-object) (..element (:representation index))))) + (:abstraction (format (:representation array_or_object) (..element (:representation index))))) (def: #export (the field object) (-> Text Expression Access) @@ -131,7 +131,7 @@ (-> Expression (List Expression) Computation) (|> inputs (list\map ..code) - (text.join-with ..argument-separator) + (text.join_with ..argument_separator) ..expression (format (:representation function)) :abstraction)) @@ -143,27 +143,27 @@ (def: #export object (-> (List [Text Expression]) Computation) (|>> (list\map (.function (_ [key val]) - (format (:representation (..string key)) ..field-separator (:representation val)))) - (text.join-with ..argument-separator) + (format (:representation (..string key)) ..field_separator (:representation val)))) + (text.join_with ..argument_separator) (text.enclose ["{" "}"]) ..expression :abstraction)) (def: #export (, pre post) (-> Expression Expression Computation) - (|> (format (:representation pre) ..argument-separator (:representation post)) + (|> (format (:representation pre) ..argument_separator (:representation post)) ..expression :abstraction)) (def: #export (then pre post) (-> Statement Statement Statement) (:abstraction (format (:representation pre) - text.new-line + text.new_line (:representation post)))) (def: block (-> Statement Text) - (let [close (format text.new-line "}")] + (let [close (format text.new_line "}")] (|>> :representation ..nest (text.enclose ["{" @@ -176,7 +176,7 @@ (format "function " (:representation name) (|> inputs (list\map ..code) - (text.join-with ..argument-separator) + (text.join_with ..argument_separator) ..expression) " ") :abstraction)) @@ -195,7 +195,7 @@ (format "function" (|> inputs (list\map ..code) - (text.join-with ..argument-separator) + (text.join_with ..argument_separator) ..expression) " ") ..expression @@ -220,15 +220,15 @@ [/ "/"] [% "%"] - [left-shift "<<"] - [arithmetic-right-shift ">>"] - [logic-right-shift ">>>"] + [left_shift "<<"] + [arithmetic_right_shift ">>"] + [logic_right_shift ">>>"] [or "||"] [and "&&"] - [bit-xor "^"] - [bit-or "|"] - [bit-and "&"] + [bit_xor "^"] + [bit_or "|"] + [bit_and "&"] ) (template [<name> <prefix>] @@ -237,7 +237,7 @@ (|>> :representation (text.prefix <prefix>) ..expression :abstraction))] [not "!"] - [bit-not "~"] + [bit_not "~"] [negate "-"] ) @@ -247,7 +247,7 @@ (-> <input> Computation) (:abstraction (..expression (format (<format> value) "|0"))))] - [to-i32 Expression :representation] + [to_i32 Expression :representation] [i32 Int %.int] ) @@ -265,7 +265,7 @@ ..expression :abstraction)) - (def: #export type-of + (def: #export type_of (-> Expression Computation) (|>> :representation (format "typeof ") @@ -277,26 +277,26 @@ (|> (format "new " (:representation constructor) (|> inputs (list\map ..code) - (text.join-with ..argument-separator) + (text.join_with ..argument_separator) ..expression)) ..expression :abstraction)) (def: #export statement (-> Expression Statement) - (|>> :representation (text.suffix ..statement-suffix) :abstraction)) + (|>> :representation (text.suffix ..statement_suffix) :abstraction)) - (def: #export use-strict + (def: #export use_strict Statement - (:abstraction (format text.double-quote "use strict" text.double-quote ..statement-suffix))) + (:abstraction (format text.double_quote "use strict" text.double_quote ..statement_suffix))) (def: #export (declare name) (-> Var Statement) - (:abstraction (format "var " (:representation name) ..statement-suffix))) + (:abstraction (format "var " (:representation name) ..statement_suffix))) (def: #export (define name value) (-> Var Expression Statement) - (:abstraction (format "var " (:representation name) " = " (:representation value) ..statement-suffix))) + (:abstraction (format "var " (:representation name) " = " (:representation value) ..statement_suffix))) (def: #export (set' name value) (-> Location Expression Expression) @@ -304,15 +304,15 @@ (def: #export (set name value) (-> Location Expression Statement) - (:abstraction (format (:representation name) " = " (:representation value) ..statement-suffix))) + (:abstraction (format (:representation name) " = " (:representation value) ..statement_suffix))) (def: #export (throw message) (-> Expression Statement) - (:abstraction (format "throw " (:representation message) ..statement-suffix))) + (:abstraction (format "throw " (:representation message) ..statement_suffix))) (def: #export (return value) (-> Expression Statement) - (:abstraction (format "return " (:representation value) ..statement-suffix))) + (:abstraction (format "return " (:representation value) ..statement_suffix))) (def: #export (delete' value) (-> Location Expression) @@ -320,7 +320,7 @@ (def: #export (delete value) (-> Location Statement) - (:abstraction (format (:representation (delete' value)) ..statement-suffix))) + (:abstraction (format (:representation (delete' value)) ..statement_suffix))) (def: #export (if test then! else!) (-> Expression Statement Statement Statement) @@ -339,10 +339,10 @@ (:abstraction (format "while(" (:representation test) ") " (..block body)))) - (def: #export (do-while test body) + (def: #export (do_while test body) (-> Expression Statement Loop) (:abstraction (format "do " (..block body) - " while(" (:representation test) ")" ..statement-suffix))) + " while(" (:representation test) ")" ..statement_suffix))) (def: #export (try body [exception catch]) (-> Statement [Var Statement] Statement) @@ -355,7 +355,7 @@ (-> Var Expression Expression Expression Statement Loop) (:abstraction (format "for(" (:representation (..define var init)) " " (:representation condition) - ..statement-suffix " " (:representation update) + ..statement_suffix " " (:representation update) ")" (..block iteration)))) @@ -363,21 +363,21 @@ (-> Text Label) (|>> :abstraction)) - (def: #export (with-label label loop) + (def: #export (with_label label loop) (-> Label Loop Statement) (:abstraction (format (:representation label) ": " (:representation loop)))) (template [<keyword> <0> <1>] [(def: #export <0> Statement - (:abstraction (format <keyword> ..statement-suffix))) + (:abstraction (format <keyword> ..statement_suffix))) (def: #export (<1> label) (-> Label Statement) - (:abstraction (format <keyword> " " (:representation label) ..statement-suffix)))] + (:abstraction (format <keyword> " " (:representation label) ..statement_suffix)))] - ["break" break break-at] - ["continue" continue continue-at] + ["break" break break_at] + ["continue" continue continue_at] ) (template [<name> <js>] @@ -402,10 +402,10 @@ (list\map (.function (_ [when then]) (format (|> when (list\map (|>> :representation (text.enclose ["case " ":"]))) - (text.join-with text.new-line)) + (text.join_with text.new_line)) (..nest (:representation then))))) - (text.join-with text.new-line)) - text.new-line + (text.join_with text.new_line)) + text.new_line (case default (#.Some default) (format "default:" @@ -435,7 +435,7 @@ (~~ (template.splice <function>+))))] [apply/1 [_0] [Expression] - [[not-a-number? "isNaN"]]] + [[not_a_number? "isNaN"]]] [apply/2 [_0 _1] [Expression Expression] []] |