Adding anonymous class support (gets a temporary variable for a name.) Issue #548

This commit is contained in:
Jeremy Ashkenas
2010-07-27 22:05:55 -04:00
parent cc7b0f2e8f
commit 8d544ce80b
6 changed files with 147 additions and 129 deletions

View File

@@ -104,7 +104,7 @@ exports.BaseNode = class BaseNode
# Convenience for the most common use of contains. Does the node contain
# a pure statement?
containsPureStatement: ->
@isPureStatement() or @contains (n) -> n.isPureStatement()
@isPureStatement() or @contains (n) -> n.isPureStatement and n.isPureStatement()
# Perform an in-order traversal of the AST. Crosses scope boundaries.
traverse: (block) -> @traverseChildren true, block
@@ -688,6 +688,7 @@ exports.ClassNode = class ClassNode extends BaseNode
# equivalent syntax tree and compile that, in pieces. You can see the
# constructor, property assignments, and inheritance getting built out below.
compileNode: (o) ->
@variable = literal o.scope.freeVariable() if @variable is '__temp__'
extension = @parent and new ExtendsNode(@variable, @parent)
props = new Expressions
o.top = true