Skip to content

Commit 12c10ef

Browse files
author
Christian Weilbach
committed
Fix regular expression literals.
This allows cljc.reader to read: #inst "2013-09-02T16:42:00.000-00:00", but since we don't have a Date type yet it just emits a vector of the respective fields as integers. Cleanups.
1 parent 1a02c96 commit 12c10ef

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/clj/cljc/compiler.clj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,11 @@
334334
(defmethod emit-constant Boolean [x] (if x "value_true" "value_false"))
335335

336336
(defmethod emit-constant java.util.regex.Pattern [x]
337-
(emit-value-wrap :pattern-const nil (emits "pcre_pattern ( make_string (" (wrap-in-double-quotes (escape-string (str x))) "))"))
338-
#_(FIXME-IMPLEMENT (str "Cannot emit java.util.regex.Pattern for constant " x " yet.")))
337+
338+
(emit-value-wrap :pattern-const
339+
nil
340+
(emits "FUNCALL1 ((closure_t*)VAR_NAME (cljc_DOT_core_SLASH_re_pattern), make_string ("
341+
(wrap-in-double-quotes (escape-string (str x))) "))")))
339342

340343
(defmethod emit-constant clojure.lang.Keyword [x]
341344
(emit-value-wrap :keyword nil
@@ -1987,7 +1990,7 @@
19871990
(comment
19881991

19891992
;;the new way - use the REPL!!
1990-
(require '[cljs.compiler :as comp])
1993+
(require '[cljc.compiler :as comp])
19911994
(def repl-env (comp/repl-env))
19921995
(comp/repl repl-env)
19931996
;having problems?, try verbose mode

src/cljc/cljc/core.cljc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
(recur (inc i) args))))
9595
a))
9696

97+
(defn ^boolean array? [cand]
98+
(has-type? cand Array))
99+
97100
(defn make-array [size]
98101
(c* "make_array (integer_get (~{}))" size))
99102

@@ -891,7 +894,7 @@ reduces them without incurring seq initialization"
891894
(str ns "/" name)
892895
name)]
893896
#_(Symbol. ns name sym-str nil nil)
894-
(c* "make_symbol( string_get_utf8( make_string_copy( string_get_utf8 (~{}) ) ) )" sym-str))))
897+
(c* "make_symbol( string_get_utf8( ~{}) )" sym-str))))
895898

896899

897900
(defn ^boolean number? [n]
@@ -6315,7 +6318,7 @@ reduces them without incurring seq initialization"
63156318

63166319
(defn- parse-float [s]
63176320
(if-objc
6318-
(§ s :floatValue)
6321+
(§ s :floatValue)
63196322
(c* "make_float (g_ascii_strtod (string_get_utf8 (~{}), NULL ) )" s)))
63206323

63216324

0 commit comments

Comments
 (0)