Permalink
Browse files

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

  • Loading branch information...
1 parent 89e036a commit 018d26a0faf40f48d7b95c23777224deef91a126 @halgari halgari committed Aug 9, 2013
@@ -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
@@ -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}))))))

0 comments on commit 018d26a

Please sign in to comment.