aboutsummaryrefslogtreecommitdiff
path: root/luxc
diff options
context:
space:
mode:
authorEduardo Julian2017-03-11 18:21:41 -0400
committerEduardo Julian2017-03-11 18:21:41 -0400
commitda8163b89261f19c26a76bf0204e735f6f6a0f21 (patch)
treeb773a3e61d6c536eb19f3561b4bb442b6b0b8a69 /luxc
parenta902bbaaceccb11316c6804c459181f62ce7e6a9 (diff)
- Turned the wrapper for chars into a type, for detection when transforming values from JS to Lux.
- Now replacing dashes for underscores in module names during compilation.
Diffstat (limited to 'luxc')
-rw-r--r--luxc/src/lux/compiler/js/base.clj25
1 files changed, 15 insertions, 10 deletions
diff --git a/luxc/src/lux/compiler/js/base.clj b/luxc/src/lux/compiler/js/base.clj
index 8daec05c5..417b35d5a 100644
--- a/luxc/src/lux/compiler/js/base.clj
+++ b/luxc/src/lux/compiler/js/base.clj
@@ -84,14 +84,14 @@
;; else
(assert false (str "I64#getMember = " member)))))
-(defn ^:private encode-char [value]
- (reify JSObject
- (getMember [self member]
- (condp = member
- "C" value
- ;; "toString" (_toString_simple value)
- ;; else
- (assert false (str "encode-char#getMember = " member))))))
+(deftype EncChar [value]
+ JSObject
+ (getMember [self member]
+ (condp = member
+ "C" value
+ ;; "toString" (_toString_simple value)
+ ;; else
+ (assert false (str "EncChar#getMember = " member)))))
(deftype LuxJsObject [^"[Ljava.lang.Object;" obj]
JSObject
@@ -105,7 +105,7 @@
(new I64 value)
(instance? java.lang.Character value)
- (encode-char (str value))
+ (new EncChar (str value))
:else
value)))
@@ -156,6 +156,9 @@
(instance? I64 js-object)
(.-value ^I64 js-object)
+ (instance? EncChar js-object)
+ (.charAt ^String (.-value ^EncChar js-object) 0)
+
;; (instance? Undefined js-object)
;; (assert false "UNDEFINED")
@@ -222,7 +225,9 @@
(return nil)))
(defn js-module [module]
- (string/replace module "/" "$"))
+ (-> module
+ (string/replace "/" "$")
+ (string/replace "-" "_")))
(defn js-var-name [module name]
(str (js-module module) "$" (&host/def-name name)))