diff options
-rw-r--r-- | luxc/src/lux/base.clj | 68 | ||||
-rw-r--r-- | stdlib/source/lux/platform/compiler/name.lux | 46 |
2 files changed, 64 insertions, 50 deletions
diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index e6fecf367..0b14e667d 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -258,8 +258,7 @@ (assert false (str "Unknown var: " (first pattern)))) '_ (transform-pattern (vec (rest pattern)))] - :else pattern - )) + :else pattern)) (defmacro |case [value & branches] (assert (= 0 (mod (count branches) 2))) @@ -670,29 +669,29 @@ (defn ^:private normalize-char [char] (case char - \* "_ASTER_" - \+ "_PLUS_" - \- "_DASH_" - \/ "_SLASH_" - \\ "_BSLASH_" - \_ "_UNDERS_" - \% "_PERCENT_" - \$ "_DOLLAR_" - \' "_QUOTE_" - \` "_BQUOTE_" - \@ "_AT_" - \^ "_CARET_" - \& "_AMPERS_" - \= "_EQ_" - \! "_BANG_" - \? "_QM_" - \: "_COLON_" - \. "_PERIOD_" - \, "_COMMA_" - \< "_LT_" - \> "_GT_" - \~ "_TILDE_" - \| "_PIPE_" + \* "_AS" + \+ "_PL" + \- "_DS" + \/ "_SL" + \\ "_BS" + \_ "_US" + \% "_PC" + \$ "_DL" + \' "_QU" + \` "_BQ" + \@ "_AT" + \^ "_CR" + \& "_AA" + \= "_EQ" + \! "_BG" + \? "_QM" + \: "_CO" + \. "_PD" + \, "_CM" + \< "_LT" + \> "_GT" + \~ "_TI" + \| "_PI" ;; default char)) @@ -1208,10 +1207,12 @@ (pr-str ?value) [_ ($Nat ?value)] - (str "+" (Long/toUnsignedString ?value)) + (Long/toUnsignedString ?value) [_ ($Int ?value)] - (pr-str ?value) + (if (< ?value 0) + (pr-str ?value) + (str "+" (pr-str ?value))) [_ ($Rev ?value)] (encode-rev ?value) @@ -1470,3 +1471,16 @@ _output _output))) + +(defn timed% [what when operation] + (fn [state] + (let [pre (System/currentTimeMillis)] + (|case (operation state) + ($Right state* output) + (let [post (System/currentTimeMillis) + duration (- post pre) + _ (|log! (str what " [" when "]: +" duration "ms" "\n"))] + ($Right (T [state* output]))) + + ($Left ^String msg) + (fail* msg))))) diff --git a/stdlib/source/lux/platform/compiler/name.lux b/stdlib/source/lux/platform/compiler/name.lux index 184b2cab5..394bdb2db 100644 --- a/stdlib/source/lux/platform/compiler/name.lux +++ b/stdlib/source/lux/platform/compiler/name.lux @@ -7,29 +7,29 @@ (`` (template: (!sanitize char) ("lux syntax char case!" char - [["*"] "_ASTER_" - ["+"] "_PLUS_" - ["-"] "_DASH_" - ["/"] "_SLASH_" - ["\"] "_BSLASH_" - ["_"] "_UNDERS_" - ["%"] "_PERCENT_" - ["$"] "_DOLLAR_" - ["'"] "_QUOTE_" - ["`"] "_BQUOTE_" - ["@"] "_AT_" - ["^"] "_CARET_" - ["&"] "_AMPERS_" - ["="] "_EQ_" - ["!"] "_BANG_" - ["?"] "_QM_" - [":"] "_COLON_" - ["."] "_PERIOD_" - [","] "_COMMA_" - ["<"] "_LT_" - [">"] "_GT_" - ["~"] "_TILDE_" - ["|"] "_PIPE_"] + [["*"] "_AS" + ["+"] "_PL" + ["-"] "_DS" + ["/"] "_SL" + ["\"] "_BS" + ["_"] "_US" + ["%"] "_PC" + ["$"] "_DL" + ["'"] "_QU" + ["`"] "_BQ" + ["@"] "_AT" + ["^"] "_CR" + ["&"] "_AA" + ["="] "_EQ" + ["!"] "_BG" + ["?"] "_QM" + [":"] "_CO" + ["."] "_PD" + [","] "_CM" + ["<"] "_LT" + [">"] "_GT" + ["~"] "_TI" + ["|"] "_PI"] (text.from-code char)))) (def: #export (normalize name) |