(experimental) made new a unary operator

This commit is contained in:
satyr
2010-09-25 17:39:19 +09:00
parent 9a3b736174
commit c24e1eacb9
10 changed files with 32 additions and 42 deletions

View File

@@ -868,7 +868,7 @@
this.variable = literal(o.scope.freeVariable('ctor'));
}
extension = this.parent && new ExtendsNode(this.variable, this.parent);
props = new Expressions();
props = new Expressions;
o.top = true;
me = null;
className = this.variable.compile(o);
@@ -877,7 +877,7 @@
applied = new ValueNode(this.parent, [new AccessorNode(literal('apply'))]);
constructor = new CodeNode([], new Expressions([new CallNode(applied, [literal('this'), literal('arguments')])]));
} else {
constructor = new CodeNode();
constructor = new CodeNode;
}
_ref2 = this.properties;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
@@ -1055,7 +1055,7 @@
this.params = _arg;
CodeNode.__super__.constructor.call(this);
this.params || (this.params = []);
this.body || (this.body = new Expressions());
this.body || (this.body = (new Expressions));
this.bound = tag === 'boundfunc';
if (this.bound) {
this.context = 'this';
@@ -1311,6 +1311,8 @@
this.flip = !!flip;
if (this.first instanceof ValueNode && this.first.base instanceof ObjectNode) {
this.first = new ParentheticalNode(this.first);
} else if (this.operator === 'new' && this.first instanceof CallNode) {
return this.first.newInstance();
}
this.first.tags.operation = true;
if (this.second) {
@@ -1329,7 +1331,7 @@
};
OpNode.prototype.CHAINABLE = ['<', '>', '>=', '<=', '===', '!=='];
OpNode.prototype.ASSIGNMENT = ['||=', '&&=', '?='];
OpNode.prototype.PREFIX_OPERATORS = ['typeof', 'delete'];
OpNode.prototype.PREFIX_OPERATORS = ['new', 'typeof', 'delete'];
OpNode.prototype["class"] = 'OpNode';
OpNode.prototype.children = ['first', 'second'];
OpNode.prototype.isUnary = function() {