Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Unified Diff: src/parser.cc

Issue 3120027: Add position information for compares, binary ops, and count (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
===================================================================
--- src/parser.cc (revision 5328)
+++ src/parser.cc (working copy)
@@ -214,7 +214,10 @@
ObjectLiteral::Property* ParseObjectLiteralGetSet(bool is_getter, bool* ok);
Expression* ParseRegExpLiteral(bool seen_equal, bool* ok);
- Expression* NewCompareNode(Token::Value op, Expression* x, Expression* y);
+ Expression* NewCompareNode(Token::Value op,
+ Expression* x,
+ Expression* y,
+ int position);
// Populate the constant properties fixed array for a materialized object
// literal.
@@ -2817,8 +2820,9 @@
Expression* result = ParseAssignmentExpression(accept_IN, CHECK_OK);
while (peek() == Token::COMMA) {
Expect(Token::COMMA, CHECK_OK);
+ int position = scanner().location().beg_pos;
Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK);
- result = NEW(BinaryOperation(Token::COMMA, result, right));
+ result = NEW(BinaryOperation(Token::COMMA, result, right, position));
}
return result;
}
@@ -2921,6 +2925,7 @@
// prec1 >= 4
while (Precedence(peek(), accept_IN) == prec1) {
Token::Value op = Next();
+ int position = scanner().location().beg_pos;
Expression* y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK);
// Compute some expressions involving only number literals.
@@ -3004,7 +3009,7 @@
case Token::NE_STRICT: cmp = Token::EQ_STRICT; break;
default: break;
}
- x = NewCompareNode(cmp, x, y);
+ x = NewCompareNode(cmp, x, y, position);
if (cmp != op) {
// The comparison was negated - add a NOT.
x = NEW(UnaryOperation(Token::NOT, x));
@@ -3012,7 +3017,7 @@
} else {
// We have a "normal" binary operation.
- x = NEW(BinaryOperation(op, x, y));
+ x = NEW(BinaryOperation(op, x, y, position));
}
}
}
@@ -3022,7 +3027,8 @@
Expression* Parser::NewCompareNode(Token::Value op,
Expression* x,
- Expression* y) {
+ Expression* y,
+ int position) {
ASSERT(op != Token::NE && op != Token::NE_STRICT);
if (!is_pre_parsing_ && (op == Token::EQ || op == Token::EQ_STRICT)) {
bool is_strict = (op == Token::EQ_STRICT);
@@ -3036,7 +3042,7 @@
return NEW(CompareToNull(is_strict, x));
}
}
- return NEW(CompareOperation(op, x, y));
+ return NEW(CompareOperation(op, x, y, position));
}
@@ -3086,8 +3092,9 @@
Handle<String> type = Factory::invalid_lhs_in_prefix_op_symbol();
expression = NewThrowReferenceError(type);
}
+ int position = scanner().location().beg_pos;
IncrementOperation* increment = NEW(IncrementOperation(op, expression));
- return NEW(CountOperation(true /* prefix */, increment));
+ return NEW(CountOperation(true /* prefix */, increment, position));
} else {
return ParsePostfixExpression(ok);
@@ -3110,8 +3117,9 @@
expression = NewThrowReferenceError(type);
}
Token::Value next = Next();
+ int position = scanner().location().beg_pos;
IncrementOperation* increment = NEW(IncrementOperation(next, expression));
- expression = NEW(CountOperation(false /* postfix */, increment));
+ expression = NEW(CountOperation(false /* postfix */, increment, position));
}
return expression;
}
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698