Skip to content

Commit

Permalink
express args as slots. we're going to need to do the Defer conversion…
Browse files Browse the repository at this point in the history
… still
  • Loading branch information
maxtaco committed Jan 24, 2012
1 parent df05680 commit 6f0b583
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
39 changes: 36 additions & 3 deletions lib/coffee-script/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/coffee-script/tame.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions src/nodes.coffee
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f0b583

Please sign in to comment.