Commits

Mathias Panzenböck committed 86000a4

more fixes

  • Participants
  • Parent commits cedba92

Comments (0)

Files changed (4)

File lib/clonevisitor.js

 	conditionalExpression: function (test, consequent, alternate, loc) {
 		return new nodes.ConditionalExpression(test, consequent, alternate, loc);
 	},
-	newExpression: function (constructor, args, loc) {
-		return new nodes.NewExpression(constructor, args, loc);
+	newExpression: function (callee, args, loc) {
+		return new nodes.NewExpression(callee, args, loc);
 	},
 	callExpression: function (callee, args, loc) {
 		return new nodes.CallExpression(callee, args, loc);

File lib/minvisitor.js

 		switch (op) {
 			case '+':
 			case '-':
-			case '/':
 				if (arg.charAt(0) === op) {
 					return op+" "+arg;
 				}
 		}
 		return test+"?"+cons+":"+alt;
 	},
-	visitNewExpression: function (constr, args) {
-		var constr = this.visit(node.constr);
+	visitNewExpression: function (node) {
+		var callee = this.visit(node.callee);
 		var args = node.arguments;
-		if (node.hasPrecedence(node.constr)) {
-			constr = '('+constr+')';
+		if (node.hasPrecedence(node.callee)) {
+			callee = '('+callee+')';
 		}
 		else {
-			constr = lwrap(constr);
+			callee = lwrap(callee);
 		}
-		return "new"+constr+(args ?
+		return "new"+callee+(args ?
 			"("+args.map(this.visit.bind(this)).join(",")+")" :
 			"()");
 	},
 	visitMemberExpression: function (node) {
 		var obj = this.visit(node.object);
 		var prop = this.visit(node.property);
-		if (node.hasPrecedence(node.object)) {
+		if (node.hasLeftPrecedence(node.object)) {
 			obj = '('+obj+')';
 		}
 		return node.computed ? obj+"["+prop+"]" : obj+"."+prop;

File lib/nodes.js

 	this.precedence = PrecedenceMap[operator];
 }
 
-function NewExpression (constructor, args, loc) {
+function NewExpression (callee, args, loc) {
 	this.type = "NewExpression";
-	this.constructor = constructor;
+	this.callee = callee;
 	this.arguments = args;
 	this.loc = loc;
 	this.precedence = PrecedenceMap["new"];
 			return !this.precedence.rtl;
 		}
 	},
-	hasPrecedence: function (node) {
-		if (this.precedence.order < node.precedence.order) {
-			return true;
-		}
-		else if (this.precedence.order > node.precedence.order) {
-			return false;
-		}
-		else {
-			return this.precedence.rtl;
-		}
-	},
 	precedence: {order: 0, rtl: false}
 });
+Expression.prototype.hasPrecedence = Expression.prototype.hasRightPrecedence;
 Declaration.prototype = new Statement();
 Program.prototype = new Node();
 EmptyStatement.prototype = new Statement();

File lib/visitor.js

 	},
 	visitNewExpression: function (node) {
 		return this.newExpression(
-			this.visit(node.constructor),
+			this.visit(node.callee),
 			node.arguments ? node.arguments.map(this.visit.bind(this)) : null,
 			node.loc);
 	},
 	updateExpression: function (op, arg, prefix, loc) {},
 	logicalExpression: function (op, left, right, loc) {},
 	conditionalExpression: function (test, cons, alt, loc) {},
-	newExpression: function (constr, args, loc) {},
+	newExpression: function (callee, args, loc) {},
 	callExpression: function (callee, args, loc) {},
 	memberExpression: function (obj, prop, computed, loc) {},
 	switchCase: function (test, cons, loc) {},