All classes now named.

This commit is contained in:
Timothy Jones
2010-10-05 15:52:33 +13:00
parent 8eb283df2c
commit 645075f910
6 changed files with 73 additions and 67 deletions

View File

@@ -4,7 +4,7 @@
Rewriter = require('./rewriter').Rewriter; Rewriter = require('./rewriter').Rewriter;
_ref = require('./helpers'), include = _ref.include, count = _ref.count, starts = _ref.starts, compact = _ref.compact, last = _ref.last; _ref = require('./helpers'), include = _ref.include, count = _ref.count, starts = _ref.starts, compact = _ref.compact, last = _ref.last;
exports.Lexer = (function() { exports.Lexer = (function() {
Lexer = function() {}; Lexer = (function() { function Lexer() {} return Lexer; })();
Lexer.prototype.tokenize = function(code, options) { Lexer.prototype.tokenize = function(code, options) {
var o; var o;
code = code.replace(/\r/g, '').replace(/\s+$/, ''); code = code.replace(/\r/g, '').replace(/\s+$/, '');

View File

@@ -20,10 +20,10 @@
return this; return this;
}; };
exports.BaseNode = (function() { exports.BaseNode = (function() {
BaseNode = function() { BaseNode = (function() { function BaseNode() {
this.tags = {}; this.tags = {};
return this; return this;
}; } return BaseNode; })();
BaseNode.prototype.compile = function(o) { BaseNode.prototype.compile = function(o) {
var closure, code, top; var closure, code, top;
this.options = o ? merge(o) : {}; this.options = o ? merge(o) : {};
@@ -159,11 +159,11 @@
return BaseNode; return BaseNode;
})(); })();
exports.Expressions = (function() { exports.Expressions = (function() {
Expressions = function(nodes) { Expressions = (function() { function Expressions(nodes) {
Expressions.__super__.constructor.call(this); Expressions.__super__.constructor.call(this);
this.expressions = compact(flatten(nodes || [])); this.expressions = compact(flatten(nodes || []));
return this; return this;
}; } return Expressions; })();
__extends(Expressions, BaseNode); __extends(Expressions, BaseNode);
Expressions.prototype["class"] = 'Expressions'; Expressions.prototype["class"] = 'Expressions';
Expressions.prototype.children = ['expressions']; Expressions.prototype.children = ['expressions'];
@@ -244,11 +244,11 @@
return new Expressions(nodes); return new Expressions(nodes);
}; };
exports.LiteralNode = (function() { exports.LiteralNode = (function() {
LiteralNode = function(_arg) { LiteralNode = (function() { function LiteralNode(_arg) {
this.value = _arg; this.value = _arg;
LiteralNode.__super__.constructor.call(this); LiteralNode.__super__.constructor.call(this);
return this; return this;
}; } return LiteralNode; })();
__extends(LiteralNode, BaseNode); __extends(LiteralNode, BaseNode);
LiteralNode.prototype["class"] = 'LiteralNode'; LiteralNode.prototype["class"] = 'LiteralNode';
LiteralNode.prototype.makeReturn = function() { LiteralNode.prototype.makeReturn = function() {
@@ -272,11 +272,11 @@
return LiteralNode; return LiteralNode;
})(); })();
exports.ReturnNode = (function() { exports.ReturnNode = (function() {
ReturnNode = function(_arg) { ReturnNode = (function() { function ReturnNode(_arg) {
this.expression = _arg; this.expression = _arg;
ReturnNode.__super__.constructor.call(this); ReturnNode.__super__.constructor.call(this);
return this; return this;
}; } return ReturnNode; })();
__extends(ReturnNode, BaseNode); __extends(ReturnNode, BaseNode);
ReturnNode.prototype["class"] = 'ReturnNode'; ReturnNode.prototype["class"] = 'ReturnNode';
ReturnNode.prototype.isStatement = YES; ReturnNode.prototype.isStatement = YES;
@@ -300,13 +300,13 @@
return ReturnNode; return ReturnNode;
})(); })();
exports.ValueNode = (function() { exports.ValueNode = (function() {
ValueNode = function(_arg, _arg2) { ValueNode = (function() { function ValueNode(_arg, _arg2) {
this.properties = _arg2; this.properties = _arg2;
this.base = _arg; this.base = _arg;
ValueNode.__super__.constructor.call(this); ValueNode.__super__.constructor.call(this);
this.properties || (this.properties = []); this.properties || (this.properties = []);
return this; return this;
}; } return ValueNode; })();
__extends(ValueNode, BaseNode); __extends(ValueNode, BaseNode);
ValueNode.prototype["class"] = 'ValueNode'; ValueNode.prototype["class"] = 'ValueNode';
ValueNode.prototype.children = ['base', 'properties']; ValueNode.prototype.children = ['base', 'properties'];
@@ -429,11 +429,11 @@
return ValueNode; return ValueNode;
}).call(this); }).call(this);
exports.CommentNode = (function() { exports.CommentNode = (function() {
CommentNode = function(_arg) { CommentNode = (function() { function CommentNode(_arg) {
this.comment = _arg; this.comment = _arg;
CommentNode.__super__.constructor.call(this); CommentNode.__super__.constructor.call(this);
return this; return this;
}; } return CommentNode; })();
__extends(CommentNode, BaseNode); __extends(CommentNode, BaseNode);
CommentNode.prototype["class"] = 'CommentNode'; CommentNode.prototype["class"] = 'CommentNode';
CommentNode.prototype.isStatement = YES; CommentNode.prototype.isStatement = YES;
@@ -444,7 +444,7 @@
return CommentNode; return CommentNode;
})(); })();
exports.CallNode = (function() { exports.CallNode = (function() {
CallNode = function(variable, _arg, _arg2) { CallNode = (function() { function CallNode(variable, _arg, _arg2) {
this.exist = _arg2; this.exist = _arg2;
this.args = _arg; this.args = _arg;
CallNode.__super__.constructor.call(this); CallNode.__super__.constructor.call(this);
@@ -453,7 +453,7 @@
this.variable = this.isSuper ? null : variable; this.variable = this.isSuper ? null : variable;
this.args || (this.args = []); this.args || (this.args = []);
return this; return this;
}; } return CallNode; })();
__extends(CallNode, BaseNode); __extends(CallNode, BaseNode);
CallNode.prototype["class"] = 'CallNode'; CallNode.prototype["class"] = 'CallNode';
CallNode.prototype.children = ['variable', 'args']; CallNode.prototype.children = ['variable', 'args'];
@@ -593,12 +593,12 @@
return CallNode; return CallNode;
})(); })();
exports.ExtendsNode = (function() { exports.ExtendsNode = (function() {
ExtendsNode = function(_arg, _arg2) { ExtendsNode = (function() { function ExtendsNode(_arg, _arg2) {
this.parent = _arg2; this.parent = _arg2;
this.child = _arg; this.child = _arg;
ExtendsNode.__super__.constructor.call(this); ExtendsNode.__super__.constructor.call(this);
return this; return this;
}; } return ExtendsNode; })();
__extends(ExtendsNode, BaseNode); __extends(ExtendsNode, BaseNode);
ExtendsNode.prototype["class"] = 'ExtendsNode'; ExtendsNode.prototype["class"] = 'ExtendsNode';
ExtendsNode.prototype.children = ['child', 'parent']; ExtendsNode.prototype.children = ['child', 'parent'];
@@ -610,13 +610,13 @@
return ExtendsNode; return ExtendsNode;
})(); })();
exports.AccessorNode = (function() { exports.AccessorNode = (function() {
AccessorNode = function(_arg, tag) { AccessorNode = (function() { function AccessorNode(_arg, tag) {
this.name = _arg; this.name = _arg;
AccessorNode.__super__.constructor.call(this); AccessorNode.__super__.constructor.call(this);
this.prototype = tag === 'prototype' ? '.prototype' : ''; this.prototype = tag === 'prototype' ? '.prototype' : '';
this.soakNode = tag === 'soak'; this.soakNode = tag === 'soak';
return this; return this;
}; } return AccessorNode; })();
__extends(AccessorNode, BaseNode); __extends(AccessorNode, BaseNode);
AccessorNode.prototype["class"] = 'AccessorNode'; AccessorNode.prototype["class"] = 'AccessorNode';
AccessorNode.prototype.children = ['name']; AccessorNode.prototype.children = ['name'];
@@ -630,11 +630,11 @@
return AccessorNode; return AccessorNode;
})(); })();
exports.IndexNode = (function() { exports.IndexNode = (function() {
IndexNode = function(_arg) { IndexNode = (function() { function IndexNode(_arg) {
this.index = _arg; this.index = _arg;
IndexNode.__super__.constructor.call(this); IndexNode.__super__.constructor.call(this);
return this; return this;
}; } return IndexNode; })();
__extends(IndexNode, BaseNode); __extends(IndexNode, BaseNode);
IndexNode.prototype["class"] = 'IndexNode'; IndexNode.prototype["class"] = 'IndexNode';
IndexNode.prototype.children = ['index']; IndexNode.prototype.children = ['index'];
@@ -650,14 +650,14 @@
return IndexNode; return IndexNode;
})(); })();
exports.RangeNode = (function() { exports.RangeNode = (function() {
RangeNode = function(_arg, _arg2, tag) { RangeNode = (function() { function RangeNode(_arg, _arg2, tag) {
this.to = _arg2; this.to = _arg2;
this.from = _arg; this.from = _arg;
RangeNode.__super__.constructor.call(this); RangeNode.__super__.constructor.call(this);
this.exclusive = tag === 'exclusive'; this.exclusive = tag === 'exclusive';
this.equals = this.exclusive ? '' : '='; this.equals = this.exclusive ? '' : '=';
return this; return this;
}; } return RangeNode; })();
__extends(RangeNode, BaseNode); __extends(RangeNode, BaseNode);
RangeNode.prototype["class"] = 'RangeNode'; RangeNode.prototype["class"] = 'RangeNode';
RangeNode.prototype.children = ['from', 'to']; RangeNode.prototype.children = ['from', 'to'];
@@ -740,11 +740,11 @@
return RangeNode; return RangeNode;
})(); })();
exports.SliceNode = (function() { exports.SliceNode = (function() {
SliceNode = function(_arg) { SliceNode = (function() { function SliceNode(_arg) {
this.range = _arg; this.range = _arg;
SliceNode.__super__.constructor.call(this); SliceNode.__super__.constructor.call(this);
return this; return this;
}; } return SliceNode; })();
__extends(SliceNode, BaseNode); __extends(SliceNode, BaseNode);
SliceNode.prototype["class"] = 'SliceNode'; SliceNode.prototype["class"] = 'SliceNode';
SliceNode.prototype.children = ['range']; SliceNode.prototype.children = ['range'];
@@ -761,11 +761,11 @@
return SliceNode; return SliceNode;
})(); })();
exports.ObjectNode = (function() { exports.ObjectNode = (function() {
ObjectNode = function(props) { ObjectNode = (function() { function ObjectNode(props) {
ObjectNode.__super__.constructor.call(this); ObjectNode.__super__.constructor.call(this);
this.objects = (this.properties = props || []); this.objects = (this.properties = props || []);
return this; return this;
}; } return ObjectNode; })();
__extends(ObjectNode, BaseNode); __extends(ObjectNode, BaseNode);
ObjectNode.prototype["class"] = 'ObjectNode'; ObjectNode.prototype["class"] = 'ObjectNode';
ObjectNode.prototype.children = ['properties']; ObjectNode.prototype.children = ['properties'];
@@ -813,12 +813,12 @@
return ObjectNode; return ObjectNode;
})(); })();
exports.ArrayNode = (function() { exports.ArrayNode = (function() {
ArrayNode = function(_arg) { ArrayNode = (function() { function ArrayNode(_arg) {
this.objects = _arg; this.objects = _arg;
ArrayNode.__super__.constructor.call(this); ArrayNode.__super__.constructor.call(this);
this.objects || (this.objects = []); this.objects || (this.objects = []);
return this; return this;
}; } return ArrayNode; })();
__extends(ArrayNode, BaseNode); __extends(ArrayNode, BaseNode);
ArrayNode.prototype["class"] = 'ArrayNode'; ArrayNode.prototype["class"] = 'ArrayNode';
ArrayNode.prototype.children = ['objects']; ArrayNode.prototype.children = ['objects'];
@@ -849,7 +849,7 @@
return ArrayNode; return ArrayNode;
})(); })();
exports.ClassNode = (function() { exports.ClassNode = (function() {
ClassNode = function(_arg, _arg2, _arg3) { ClassNode = (function() { function ClassNode(_arg, _arg2, _arg3) {
this.properties = _arg3; this.properties = _arg3;
this.parent = _arg2; this.parent = _arg2;
this.variable = _arg; this.variable = _arg;
@@ -857,7 +857,7 @@
this.properties || (this.properties = []); this.properties || (this.properties = []);
this.returns = false; this.returns = false;
return this; return this;
}; } return ClassNode; })();
__extends(ClassNode, BaseNode); __extends(ClassNode, BaseNode);
ClassNode.prototype["class"] = 'ClassNode'; ClassNode.prototype["class"] = 'ClassNode';
ClassNode.prototype.children = ['variable', 'parent', 'properties']; ClassNode.prototype.children = ['variable', 'parent', 'properties'];
@@ -919,6 +919,7 @@
} }
props.push(prop); props.push(prop);
} }
constructor.className = className.match(/[\w\d\$_]+$/);
if (me) { if (me) {
constructor.body.unshift(literal("" + (me) + " = this")); constructor.body.unshift(literal("" + (me) + " = this"));
} }
@@ -933,13 +934,13 @@
return ClassNode; return ClassNode;
})(); })();
exports.AssignNode = (function() { exports.AssignNode = (function() {
AssignNode = function(_arg, _arg2, _arg3) { AssignNode = (function() { function AssignNode(_arg, _arg2, _arg3) {
this.context = _arg3; this.context = _arg3;
this.value = _arg2; this.value = _arg2;
this.variable = _arg; this.variable = _arg;
AssignNode.__super__.constructor.call(this); AssignNode.__super__.constructor.call(this);
return this; return this;
}; } return AssignNode; })();
__extends(AssignNode, BaseNode); __extends(AssignNode, BaseNode);
AssignNode.prototype.METHOD_DEF = /^(?:(\S+)\.prototype\.)?([$A-Za-z_][$\w]*)$/; AssignNode.prototype.METHOD_DEF = /^(?:(\S+)\.prototype\.)?([$A-Za-z_][$\w]*)$/;
AssignNode.prototype["class"] = 'AssignNode'; AssignNode.prototype["class"] = 'AssignNode';
@@ -1056,7 +1057,7 @@
return AssignNode; return AssignNode;
})(); })();
exports.CodeNode = (function() { exports.CodeNode = (function() {
CodeNode = function(_arg, _arg2, tag) { CodeNode = (function() { function CodeNode(_arg, _arg2, tag) {
this.body = _arg2; this.body = _arg2;
this.params = _arg; this.params = _arg;
CodeNode.__super__.constructor.call(this); CodeNode.__super__.constructor.call(this);
@@ -1067,12 +1068,12 @@
this.context = 'this'; this.context = 'this';
} }
return this; return this;
}; } return CodeNode; })();
__extends(CodeNode, BaseNode); __extends(CodeNode, BaseNode);
CodeNode.prototype["class"] = 'CodeNode'; CodeNode.prototype["class"] = 'CodeNode';
CodeNode.prototype.children = ['params', 'body']; CodeNode.prototype.children = ['params', 'body'];
CodeNode.prototype.compileNode = function(o) { CodeNode.prototype.compileNode = function(o) {
var _i, _len, _ref2, _ref3, _result, code, empty, func, i, param, params, sharedScope, splat, top, value; var _i, _len, _ref2, _ref3, _result, close, code, empty, func, i, open, param, params, sharedScope, splat, top, value;
sharedScope = del(o, 'sharedScope'); sharedScope = del(o, 'sharedScope');
top = del(o, 'top'); top = del(o, 'top');
o.scope = sharedScope || new Scope(o.scope, this.body, this); o.scope = sharedScope || new Scope(o.scope, this.body, this);
@@ -1124,8 +1125,10 @@
param = params[_i]; param = params[_i];
(o.scope.parameter(param)); (o.scope.parameter(param));
} }
open = this.className ? ("(function() { function " + (this.className) + "(") : "function(";
close = this.className ? ("} return " + (this.className) + "; })()") : "}";
code = this.body.expressions.length ? ("\n" + (this.body.compileWithDeclarations(o)) + "\n") : ''; code = this.body.expressions.length ? ("\n" + (this.body.compileWithDeclarations(o)) + "\n") : '';
func = ("function(" + (params.join(', ')) + ") {" + (code) + (code && this.tab) + "}"); func = ("" + (open) + (params.join(', ')) + ") {" + (code) + (code && this.tab) + (close));
if (this.bound) { if (this.bound) {
return ("(" + (utility('bind')) + "(" + (func) + ", " + (this.context) + "))"); return ("(" + (utility('bind')) + "(" + (func) + ", " + (this.context) + "))");
} }
@@ -1138,14 +1141,14 @@
return CodeNode; return CodeNode;
})(); })();
exports.ParamNode = (function() { exports.ParamNode = (function() {
ParamNode = function(_arg, _arg2, _arg3) { ParamNode = (function() { function ParamNode(_arg, _arg2, _arg3) {
this.splat = _arg3; this.splat = _arg3;
this.attach = _arg2; this.attach = _arg2;
this.name = _arg; this.name = _arg;
ParamNode.__super__.constructor.call(this); ParamNode.__super__.constructor.call(this);
this.value = literal(this.name); this.value = literal(this.name);
return this; return this;
}; } return ParamNode; })();
__extends(ParamNode, BaseNode); __extends(ParamNode, BaseNode);
ParamNode.prototype["class"] = 'ParamNode'; ParamNode.prototype["class"] = 'ParamNode';
ParamNode.prototype.children = ['name']; ParamNode.prototype.children = ['name'];
@@ -1166,14 +1169,14 @@
return ParamNode; return ParamNode;
})(); })();
exports.SplatNode = (function() { exports.SplatNode = (function() {
SplatNode = function(name) { SplatNode = (function() { function SplatNode(name) {
SplatNode.__super__.constructor.call(this); SplatNode.__super__.constructor.call(this);
if (!(name.compile)) { if (!(name.compile)) {
name = literal(name); name = literal(name);
} }
this.name = name; this.name = name;
return this; return this;
}; } return SplatNode; })();
__extends(SplatNode, BaseNode); __extends(SplatNode, BaseNode);
SplatNode.prototype["class"] = 'SplatNode'; SplatNode.prototype["class"] = 'SplatNode';
SplatNode.prototype.children = ['name']; SplatNode.prototype.children = ['name'];
@@ -1236,7 +1239,7 @@
return SplatNode; return SplatNode;
}).call(this); }).call(this);
exports.WhileNode = (function() { exports.WhileNode = (function() {
WhileNode = function(condition, opts) { WhileNode = (function() { function WhileNode(condition, opts) {
WhileNode.__super__.constructor.call(this); WhileNode.__super__.constructor.call(this);
if (((opts != null) ? opts.invert : undefined)) { if (((opts != null) ? opts.invert : undefined)) {
if (condition instanceof OpNode) { if (condition instanceof OpNode) {
@@ -1247,7 +1250,7 @@
this.condition = condition; this.condition = condition;
this.guard = ((opts != null) ? opts.guard : undefined); this.guard = ((opts != null) ? opts.guard : undefined);
return this; return this;
}; } return WhileNode; })();
__extends(WhileNode, BaseNode); __extends(WhileNode, BaseNode);
WhileNode.prototype["class"] = 'WhileNode'; WhileNode.prototype["class"] = 'WhileNode';
WhileNode.prototype.children = ['condition', 'guard', 'body']; WhileNode.prototype.children = ['condition', 'guard', 'body'];
@@ -1292,7 +1295,7 @@
return WhileNode; return WhileNode;
})(); })();
exports.OpNode = (function() { exports.OpNode = (function() {
OpNode = function(_arg, _arg2, _arg3, flip) { OpNode = (function() { function OpNode(_arg, _arg2, _arg3, flip) {
this.second = _arg3; this.second = _arg3;
this.first = _arg2; this.first = _arg2;
this.operator = _arg; this.operator = _arg;
@@ -1309,7 +1312,7 @@
this.second.tags.operation = true; this.second.tags.operation = true;
} }
return this; return this;
}; } return OpNode; })();
__extends(OpNode, BaseNode); __extends(OpNode, BaseNode);
OpNode.prototype.CONVERSIONS = { OpNode.prototype.CONVERSIONS = {
'==': '===', '==': '===',
@@ -1408,12 +1411,12 @@
return OpNode; return OpNode;
})(); })();
exports.InNode = (function() { exports.InNode = (function() {
InNode = function(_arg, _arg2) { InNode = (function() { function InNode(_arg, _arg2) {
this.array = _arg2; this.array = _arg2;
this.object = _arg; this.object = _arg;
InNode.__super__.constructor.call(this); InNode.__super__.constructor.call(this);
return this; return this;
}; } return InNode; })();
__extends(InNode, BaseNode); __extends(InNode, BaseNode);
InNode.prototype["class"] = 'InNode'; InNode.prototype["class"] = 'InNode';
InNode.prototype.children = ['object', 'array']; InNode.prototype.children = ['object', 'array'];
@@ -1451,14 +1454,14 @@
return InNode; return InNode;
})(); })();
exports.TryNode = (function() { exports.TryNode = (function() {
TryNode = function(_arg, _arg2, _arg3, _arg4) { TryNode = (function() { function TryNode(_arg, _arg2, _arg3, _arg4) {
this.ensure = _arg4; this.ensure = _arg4;
this.recovery = _arg3; this.recovery = _arg3;
this.error = _arg2; this.error = _arg2;
this.attempt = _arg; this.attempt = _arg;
TryNode.__super__.constructor.call(this); TryNode.__super__.constructor.call(this);
return this; return this;
}; } return TryNode; })();
__extends(TryNode, BaseNode); __extends(TryNode, BaseNode);
TryNode.prototype["class"] = 'TryNode'; TryNode.prototype["class"] = 'TryNode';
TryNode.prototype.children = ['attempt', 'recovery', 'ensure']; TryNode.prototype.children = ['attempt', 'recovery', 'ensure'];
@@ -1485,11 +1488,11 @@
return TryNode; return TryNode;
})(); })();
exports.ThrowNode = (function() { exports.ThrowNode = (function() {
ThrowNode = function(_arg) { ThrowNode = (function() { function ThrowNode(_arg) {
this.expression = _arg; this.expression = _arg;
ThrowNode.__super__.constructor.call(this); ThrowNode.__super__.constructor.call(this);
return this; return this;
}; } return ThrowNode; })();
__extends(ThrowNode, BaseNode); __extends(ThrowNode, BaseNode);
ThrowNode.prototype["class"] = 'ThrowNode'; ThrowNode.prototype["class"] = 'ThrowNode';
ThrowNode.prototype.children = ['expression']; ThrowNode.prototype.children = ['expression'];
@@ -1501,11 +1504,11 @@
return ThrowNode; return ThrowNode;
})(); })();
exports.ExistenceNode = (function() { exports.ExistenceNode = (function() {
ExistenceNode = function(_arg) { ExistenceNode = (function() { function ExistenceNode(_arg) {
this.expression = _arg; this.expression = _arg;
ExistenceNode.__super__.constructor.call(this); ExistenceNode.__super__.constructor.call(this);
return this; return this;
}; } return ExistenceNode; })();
__extends(ExistenceNode, BaseNode); __extends(ExistenceNode, BaseNode);
ExistenceNode.prototype["class"] = 'ExistenceNode'; ExistenceNode.prototype["class"] = 'ExistenceNode';
ExistenceNode.prototype.children = ['expression']; ExistenceNode.prototype.children = ['expression'];
@@ -1518,11 +1521,11 @@
return ExistenceNode; return ExistenceNode;
})(); })();
exports.ParentheticalNode = (function() { exports.ParentheticalNode = (function() {
ParentheticalNode = function(_arg) { ParentheticalNode = (function() { function ParentheticalNode(_arg) {
this.expression = _arg; this.expression = _arg;
ParentheticalNode.__super__.constructor.call(this); ParentheticalNode.__super__.constructor.call(this);
return this; return this;
}; } return ParentheticalNode; })();
__extends(ParentheticalNode, BaseNode); __extends(ParentheticalNode, BaseNode);
ParentheticalNode.prototype["class"] = 'ParentheticalNode'; ParentheticalNode.prototype["class"] = 'ParentheticalNode';
ParentheticalNode.prototype.children = ['expression']; ParentheticalNode.prototype.children = ['expression'];
@@ -1552,7 +1555,7 @@
return ParentheticalNode; return ParentheticalNode;
})(); })();
exports.ForNode = (function() { exports.ForNode = (function() {
ForNode = function(_arg, source, _arg2, _arg3) { ForNode = (function() { function ForNode(_arg, source, _arg2, _arg3) {
var _ref2; var _ref2;
this.index = _arg3; this.index = _arg3;
this.name = _arg2; this.name = _arg2;
@@ -1573,7 +1576,7 @@
} }
this.returns = false; this.returns = false;
return this; return this;
}; } return ForNode; })();
__extends(ForNode, BaseNode); __extends(ForNode, BaseNode);
ForNode.prototype["class"] = 'ForNode'; ForNode.prototype["class"] = 'ForNode';
ForNode.prototype.children = ['body', 'source', 'guard']; ForNode.prototype.children = ['body', 'source', 'guard'];
@@ -1691,7 +1694,7 @@
return ForNode; return ForNode;
})(); })();
exports.SwitchNode = (function() { exports.SwitchNode = (function() {
SwitchNode = function(_arg, _arg2, _arg3) { SwitchNode = (function() { function SwitchNode(_arg, _arg2, _arg3) {
this.otherwise = _arg3; this.otherwise = _arg3;
this.cases = _arg2; this.cases = _arg2;
this.subject = _arg; this.subject = _arg;
@@ -1699,7 +1702,7 @@
this.tags.subjectless = !this.subject; this.tags.subjectless = !this.subject;
this.subject || (this.subject = literal('true')); this.subject || (this.subject = literal('true'));
return this; return this;
}; } return SwitchNode; })();
__extends(SwitchNode, BaseNode); __extends(SwitchNode, BaseNode);
SwitchNode.prototype["class"] = 'SwitchNode'; SwitchNode.prototype["class"] = 'SwitchNode';
SwitchNode.prototype.children = ['subject', 'cases', 'otherwise']; SwitchNode.prototype.children = ['subject', 'cases', 'otherwise'];
@@ -1748,7 +1751,7 @@
return SwitchNode; return SwitchNode;
})(); })();
exports.IfNode = (function() { exports.IfNode = (function() {
IfNode = function(_arg, _arg2, _arg3) { IfNode = (function() { function IfNode(_arg, _arg2, _arg3) {
this.tags = _arg3; this.tags = _arg3;
this.body = _arg2; this.body = _arg2;
this.condition = _arg; this.condition = _arg;
@@ -1763,7 +1766,7 @@
this.elseBody = null; this.elseBody = null;
this.isChain = false; this.isChain = false;
return this; return this;
}; } return IfNode; })();
__extends(IfNode, BaseNode); __extends(IfNode, BaseNode);
IfNode.prototype["class"] = 'IfNode'; IfNode.prototype["class"] = 'IfNode';
IfNode.prototype.children = ['condition', 'body', 'elseBody', 'assigner']; IfNode.prototype.children = ['condition', 'body', 'elseBody', 'assigner'];

View File

@@ -1,11 +1,11 @@
(function() { (function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments; var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments;
exports.OptionParser = (function() { exports.OptionParser = (function() {
OptionParser = function(rules, banner) { OptionParser = (function() { function OptionParser(rules, banner) {
this.banner = banner; this.banner = banner;
this.rules = buildRules(rules); this.rules = buildRules(rules);
return this; return this;
}; } return OptionParser; })();
OptionParser.prototype.parse = function(args) { OptionParser.prototype.parse = function(args) {
var _i, _len, _len2, _ref, arg, i, isOption, matchedRule, options, rule, value; var _i, _len, _len2, _ref, arg, i, isOption, matchedRule, options, rule, value;
options = { options = {

View File

@@ -1,7 +1,7 @@
(function() { (function() {
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, _i, _len, _ref, include, left, rite; var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, _i, _len, _ref, include, left, rite;
include = require('./helpers').include; include = require('./helpers').include;
exports.Rewriter = function() {}; exports.Rewriter = (function() { function Rewriter() {} return Rewriter; })();
exports.Rewriter.prototype.rewrite = function(_arg) { exports.Rewriter.prototype.rewrite = function(_arg) {
this.tokens = _arg; this.tokens = _arg;
this.adjustComments(); this.adjustComments();

View File

@@ -3,7 +3,7 @@
var __hasProp = Object.prototype.hasOwnProperty; var __hasProp = Object.prototype.hasOwnProperty;
_ref = require('./helpers'), extend = _ref.extend, last = _ref.last; _ref = require('./helpers'), extend = _ref.extend, last = _ref.last;
exports.Scope = (function() { exports.Scope = (function() {
Scope = function(_arg, _arg2, _arg3) { Scope = (function() { function Scope(_arg, _arg2, _arg3) {
this.method = _arg3; this.method = _arg3;
this.expressions = _arg2; this.expressions = _arg2;
this.parent = _arg; this.parent = _arg;
@@ -17,7 +17,7 @@
Scope.root = this; Scope.root = this;
} }
return this; return this;
}; } return Scope; })();
Scope.root = null; Scope.root = null;
Scope.prototype.startLevel = function() { Scope.prototype.startLevel = function() {
return this.garbage.push([]); return this.garbage.push([]);

View File

@@ -819,6 +819,7 @@ exports.ClassNode = class ClassNode extends BaseNode
prop = new AssignNode(val, func) prop = new AssignNode(val, func)
props.push prop props.push prop
constructor.className = className.match /[\w\d\$_]+$/
constructor.body.unshift literal "#{me} = this" if me constructor.body.unshift literal "#{me} = this" if me
construct = @idt() + (new AssignNode(@variable, constructor)).compile(merge o, {sharedScope: constScope}) + ';' construct = @idt() + (new AssignNode(@variable, constructor)).compile(merge o, {sharedScope: constScope}) + ';'
props = if !props.empty() then '\n' + props.compile(o) else '' props = if !props.empty() then '\n' + props.compile(o) else ''
@@ -983,8 +984,10 @@ exports.CodeNode = class CodeNode extends BaseNode
params = (param.compile(o) for param in params) params = (param.compile(o) for param in params)
@body.makeReturn() unless empty @body.makeReturn() unless empty
(o.scope.parameter(param)) for param in params (o.scope.parameter(param)) for param in params
open = if @className then "(function() { function #{@className}(" else "function("
close = if @className then "} return #{@className}; })()" else "}"
code = if @body.expressions.length then "\n#{ @body.compileWithDeclarations(o) }\n" else '' code = if @body.expressions.length then "\n#{ @body.compileWithDeclarations(o) }\n" else ''
func = "function(#{ params.join(', ') }) {#{code}#{ code and @tab }}" func = "#{open}#{ params.join(', ') }) {#{code}#{ code and @tab }#{close}"
return "(#{utility 'bind'}(#{func}, #{@context}))" if @bound return "(#{utility 'bind'}(#{func}, #{@context}))" if @bound
if top then "(#{func})" else func if top then "(#{func})" else func