Permalink
Browse files

More work on expressions, got more things working like the tests incl…

…uded.
  • Loading branch information...
1 parent 7dad16e commit cc3c09f0bd1f421686d4f2591fcfba378d136fc2 @maxtaco committed Jan 3, 2012
Showing with 63 additions and 10 deletions.
  1. +34 −0 lib/coffee-script/nodes.js
  2. +17 −0 src/nodes.coffee
  3. +12 −10 test/tame.coffee
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -773,6 +773,16 @@ exports.Value = class Value extends Base
nref = new Index nref
[base.add(name), new Value(bref or base.base, [nref or name])]
+ tameWrapContinuation : YES
+ tameCpsRotate: ->
+ unless @properties.length
+ super()
+ return
+ @base = nv if (nv = @tameCpsExprRotate @base)
+ for p in @properties
+ if (p.index? and @tameCpsExprRotate p.index)
+ p.index = v
+
# We compile a value to JavaScript by compiling and joining each property.
# Things get much more interesting if the chain of properties has *soak*
# operators `?.` interspersed. Then we have to take care not to accidentally
@@ -857,6 +867,13 @@ exports.Call = class Call extends Base
else
"#{name}.__super__.constructor"
+
+ tameWrapContinuation: YES
+ tameCpsRotate: ->
+ for a,i in @args
+ @args[i] = v if (v = @tameCpsExprRotate a)
+ @variable = v if (v = @tameCpsExprRotate @variable)
+
# Soaked chained invocations unfold into if/else ternary structures.
unfoldSoak: (o) ->
if @soak
View
@@ -387,6 +387,16 @@ atest 'expressions -- addition (2)', (cb) ->
a+b
y = (await slowAdd 10, 20, defer _) + (await slowAdd 30, 40, defer _)
cb(y == 100, {})
+
+atest 'chaining', (cb) ->
+ id = "image data"
+ class Img
+ render : -> id
+ loadImage = (n, cb) ->
+ await delay defer()
+ cb new Img
+ x = (await loadImage "test.png", defer _).render()
+ cb(x is id, {})
#atest 'arrays and objects', (cb) ->
# id = "image data"
@@ -401,16 +411,8 @@ atest 'expressions -- addition (2)', (cb) ->
# v : "another value"
# cb(arr[0] is id and obj.i is id, {})
#
-#atest 'chaining', (cb) ->
-# id = "image data"
-# class Img
-# render : -> id
-# loadImage = (n, cb) ->
-# await delay defer()
-# cb new Img
-# x = (await loadImage "test.png", defer()).render()
-# cb(x is id, {})
-#
+#
+
#atest 'nesting', (cb) ->
# id = "image data"
# loadImage = (n, cb) ->

0 comments on commit cc3c09f

Please sign in to comment.