Unify handling of position info in AST, part 2
* Eliminate Conditional::then/else_position and WhileStatement::condition_position. R=yangguo@chromium.org BUG= Review URL: https://codereview.chromium.org/23597037 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17184 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
19d716989e
commit
530109c73b
30
src/ast.h
30
src/ast.h
@ -255,7 +255,6 @@ class AstNode: public ZoneObject {
|
||||
|
||||
class Statement : public AstNode {
|
||||
public:
|
||||
// TODO(rossberg)
|
||||
explicit Statement(int position) : AstNode(position) {}
|
||||
|
||||
bool IsEmpty() { return AsEmptyStatement() != NULL; }
|
||||
@ -765,12 +764,6 @@ class DoWhileStatement V8_FINAL : public IterationStatement {
|
||||
|
||||
Expression* cond() const { return cond_; }
|
||||
|
||||
// TODO(rossberg): get rid of this.
|
||||
// Position where condition expression starts. We need it to make
|
||||
// the loop's condition a breakable location.
|
||||
int condition_position() { return condition_position_; }
|
||||
void set_condition_position(int pos) { condition_position_ = pos; }
|
||||
|
||||
virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; }
|
||||
virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; }
|
||||
BailoutId BackEdgeId() const { return back_edge_id_; }
|
||||
@ -779,7 +772,6 @@ class DoWhileStatement V8_FINAL : public IterationStatement {
|
||||
DoWhileStatement(Isolate* isolate, ZoneStringList* labels, int pos)
|
||||
: IterationStatement(isolate, labels, pos),
|
||||
cond_(NULL),
|
||||
condition_position_(-1),
|
||||
continue_id_(GetNextId(isolate)),
|
||||
back_edge_id_(GetNextId(isolate)) {
|
||||
}
|
||||
@ -787,8 +779,6 @@ class DoWhileStatement V8_FINAL : public IterationStatement {
|
||||
private:
|
||||
Expression* cond_;
|
||||
|
||||
int condition_position_;
|
||||
|
||||
const BailoutId continue_id_;
|
||||
const BailoutId back_edge_id_;
|
||||
};
|
||||
@ -2058,10 +2048,6 @@ class Conditional V8_FINAL : public Expression {
|
||||
Expression* then_expression() const { return then_expression_; }
|
||||
Expression* else_expression() const { return else_expression_; }
|
||||
|
||||
// TODO(rossberg): get rid of this.
|
||||
int then_expression_position() const { return then_expression_position_; }
|
||||
int else_expression_position() const { return else_expression_position_; }
|
||||
|
||||
BailoutId ThenId() const { return then_id_; }
|
||||
BailoutId ElseId() const { return else_id_; }
|
||||
|
||||
@ -2070,15 +2056,11 @@ class Conditional V8_FINAL : public Expression {
|
||||
Expression* condition,
|
||||
Expression* then_expression,
|
||||
Expression* else_expression,
|
||||
int then_expression_position,
|
||||
int else_expression_position,
|
||||
int position)
|
||||
: Expression(isolate, position),
|
||||
condition_(condition),
|
||||
then_expression_(then_expression),
|
||||
else_expression_(else_expression),
|
||||
then_expression_position_(then_expression_position),
|
||||
else_expression_position_(else_expression_position),
|
||||
then_id_(GetNextId(isolate)),
|
||||
else_id_(GetNextId(isolate)) { }
|
||||
|
||||
@ -2086,8 +2068,6 @@ class Conditional V8_FINAL : public Expression {
|
||||
Expression* condition_;
|
||||
Expression* then_expression_;
|
||||
Expression* else_expression_;
|
||||
int then_expression_position_;
|
||||
int else_expression_position_;
|
||||
const BailoutId then_id_;
|
||||
const BailoutId else_id_;
|
||||
};
|
||||
@ -3192,12 +3172,9 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
|
||||
Conditional* NewConditional(Expression* condition,
|
||||
Expression* then_expression,
|
||||
Expression* else_expression,
|
||||
int then_expression_position,
|
||||
int else_expression_position,
|
||||
int position) {
|
||||
Conditional* cond = new(zone_) Conditional(
|
||||
isolate_, condition, then_expression, else_expression,
|
||||
then_expression_position, else_expression_position, position);
|
||||
isolate_, condition, then_expression, else_expression, position);
|
||||
VISIT_AND_RETURN(Conditional, cond)
|
||||
}
|
||||
|
||||
@ -3251,9 +3228,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
|
||||
return lit;
|
||||
}
|
||||
|
||||
NativeFunctionLiteral* NewNativeFunctionLiteral(Handle<String> name,
|
||||
v8::Extension* extension,
|
||||
int pos) {
|
||||
NativeFunctionLiteral* NewNativeFunctionLiteral(
|
||||
Handle<String> name, v8::Extension* extension, int pos) {
|
||||
NativeFunctionLiteral* lit =
|
||||
new(zone_) NativeFunctionLiteral(isolate_, name, extension, pos);
|
||||
VISIT_AND_RETURN(NativeFunctionLiteral, lit)
|
||||
|
@ -849,10 +849,10 @@ void FullCodeGenerator::SetStatementPosition(Statement* stmt) {
|
||||
}
|
||||
|
||||
|
||||
void FullCodeGenerator::SetExpressionPosition(Expression* expr, int pos) {
|
||||
void FullCodeGenerator::SetExpressionPosition(Expression* expr) {
|
||||
#ifdef ENABLE_DEBUGGER_SUPPORT
|
||||
if (!isolate()->debugger()->IsDebuggerActive()) {
|
||||
CodeGenerator::RecordPositions(masm_, pos);
|
||||
CodeGenerator::RecordPositions(masm_, expr->position());
|
||||
} else {
|
||||
// Check if the expression will be breakable without adding a debug break
|
||||
// slot.
|
||||
@ -866,7 +866,7 @@ void FullCodeGenerator::SetExpressionPosition(Expression* expr, int pos) {
|
||||
// statement positions this is used for e.g. the condition expression of
|
||||
// a do while loop.
|
||||
bool position_recorded = CodeGenerator::RecordPositions(
|
||||
masm_, pos, !checker.is_breakable());
|
||||
masm_, expr->position(), !checker.is_breakable());
|
||||
// If the position recording did record a new position generate a debug
|
||||
// break slot to make the statement breakable.
|
||||
if (position_recorded) {
|
||||
@ -1293,7 +1293,7 @@ void FullCodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) {
|
||||
// possible to break on the condition.
|
||||
__ bind(loop_statement.continue_label());
|
||||
PrepareForBailoutForId(stmt->ContinueId(), NO_REGISTERS);
|
||||
SetExpressionPosition(stmt->cond(), stmt->condition_position());
|
||||
SetExpressionPosition(stmt->cond());
|
||||
VisitForControl(stmt->cond(),
|
||||
&book_keeping,
|
||||
loop_statement.break_label(),
|
||||
@ -1522,8 +1522,7 @@ void FullCodeGenerator::VisitConditional(Conditional* expr) {
|
||||
|
||||
PrepareForBailoutForId(expr->ThenId(), NO_REGISTERS);
|
||||
__ bind(&true_case);
|
||||
SetExpressionPosition(expr->then_expression(),
|
||||
expr->then_expression_position());
|
||||
SetExpressionPosition(expr->then_expression());
|
||||
if (context()->IsTest()) {
|
||||
const TestContext* for_test = TestContext::cast(context());
|
||||
VisitForControl(expr->then_expression(),
|
||||
@ -1537,8 +1536,7 @@ void FullCodeGenerator::VisitConditional(Conditional* expr) {
|
||||
|
||||
PrepareForBailoutForId(expr->ElseId(), NO_REGISTERS);
|
||||
__ bind(&false_case);
|
||||
SetExpressionPosition(expr->else_expression(),
|
||||
expr->else_expression_position());
|
||||
SetExpressionPosition(expr->else_expression());
|
||||
VisitInDuplicateContext(expr->else_expression());
|
||||
// If control flow falls through Visit, merge it with true case here.
|
||||
if (!context()->IsTest()) {
|
||||
|
@ -576,7 +576,7 @@ class FullCodeGenerator: public AstVisitor {
|
||||
void SetFunctionPosition(FunctionLiteral* fun);
|
||||
void SetReturnPosition(FunctionLiteral* fun);
|
||||
void SetStatementPosition(Statement* stmt);
|
||||
void SetExpressionPosition(Expression* expr, int pos);
|
||||
void SetExpressionPosition(Expression* expr);
|
||||
void SetStatementPosition(int pos);
|
||||
void SetSourcePosition(int pos);
|
||||
|
||||
|
@ -2571,8 +2571,6 @@ DoWhileStatement* Parser::ParseDoWhileStatement(ZoneStringList* labels,
|
||||
Expect(Token::WHILE, CHECK_OK);
|
||||
Expect(Token::LPAREN, CHECK_OK);
|
||||
|
||||
if (loop != NULL) loop->set_condition_position(position());
|
||||
|
||||
Expression* cond = ParseExpression(true, CHECK_OK);
|
||||
Expect(Token::RPAREN, CHECK_OK);
|
||||
|
||||
@ -3024,13 +3022,10 @@ Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) {
|
||||
// In parsing the first assignment expression in conditional
|
||||
// expressions we always accept the 'in' keyword; see ECMA-262,
|
||||
// section 11.12, page 58.
|
||||
int left_position = peek_position();
|
||||
Expression* left = ParseAssignmentExpression(true, CHECK_OK);
|
||||
Expect(Token::COLON, CHECK_OK);
|
||||
int right_position = peek_position();
|
||||
Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK);
|
||||
return factory()->NewConditional(
|
||||
expression, left, right, left_position, right_position, pos);
|
||||
return factory()->NewConditional(expression, left, right, pos);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user