Permalink
Browse files

express args as slots. we're going to need to do the Defer conversion…

… still
  • Loading branch information...
1 parent df05680 commit 6f0b5830de9c9bb6febba3c1cfed9c61471f8722 @maxtaco committed Nov 27, 2011
Showing with 59 additions and 6 deletions.
  1. +36 −3 lib/coffee-script/nodes.js
  2. +2 −1 lib/coffee-script/tame.js
  3. +21 −2 src/nodes.coffee
View

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

Oops, something went wrong.

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

Oops, something went wrong.
View
@@ -583,6 +583,15 @@ exports.Value = class Value extends Base
unwrap: ->
if @properties.length then this else @base
+ # If this value is being used as a slot for the purposes of a defer
+ # then export it here
+ toSlot : ->
+ slotLoc = null
+ props = @properties
+ if props and props.length
+ slotLoc = props.pop()
+ return new Slot @base, props, slotLoc
+
# A reference has base part (`this` value) and name part.
# We cache them separately for compiling complex expressions.
# `a()[b()] ?= c` -> `(_base = a())[_name = b()] ? _base[_name] = c`
@@ -1780,13 +1789,23 @@ exports.In = class In extends Base
toString: (idt) ->
super idt, @constructor.name + if @negated then '!' else ''
+#### Slot
+
+exports.Slot = class Slot extends Base
+ constructor : (base, props, loc) ->
+ @base = base
+ @props = props
+ @loc = loc
+
+ children : [ 'base', 'props', 'loc' ]
+
#### Defer
exports.Defer = class Defer extends Base
constructor : (args) ->
- @args = args
+ @slots = a.toSlot() for a in args
- children : ['args']
+ children : ['slots']
compileNode : (p) ->
call = new Value new Literal tame.const.deferrals

0 comments on commit 6f0b583

Please sign in to comment.