Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix for ASYNC-3, cljs set! inside gos doesn't work

  • Loading branch information...
commit 018d26a0faf40f48d7b95c23777224deef91a126 1 parent 89e036a
@halgari halgari authored
View
18 src/main/clojure/cljs/core/async/impl/ioc_macros.clj
@@ -306,6 +306,16 @@
~STATE-IDX :finished)
nil))))
+(defrecord Set! [field object val]
+ IInstruction
+ (reads-from [this] [object val])
+ (writes-to [this] [(:id this)])
+ (block-references [this] [])
+ IEmittableInstruction
+ (emit-instruction [this state-sym]
+ `[~(:id this)
+ (set! (~field ~object) ~val)]))
+
(defrecord CondBr [test then-block else-block]
IInstruction
(reads-from [this] [test])
@@ -396,6 +406,14 @@
ret-id (add-instruction (->Const ::value))]
ret-id)))
+(defmethod sexpr-to-ssa 'set!
+ [[_ [field obj] val]]
+ (gen-plan
+ [obj-id (item-to-ssa obj)
+ val-id (item-to-ssa val)
+ ret-id (add-instruction (->Set! field obj-id val-id))]
+ ret-id))
+
(defmethod sexpr-to-ssa 'do
[[_ & body]]
(gen-plan
View
4 src/test/cljs/cljs/core/async/runner_tests.cljs
@@ -88,6 +88,10 @@
(pause x))
42)))
+ (testing "set!"
+ (let [x (js-obj)]
+ (runner (set! (.-foo x) "bar"))))
+
(testing "keywords as functions"
(is (= :bar
(runner (:foo (pause {:foo :bar}))))))
Please sign in to comment.
Something went wrong with that request. Please try again.