|
@ -648,6 +648,7 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source, |
|
|
} |
|
|
} |
|
|
if (ok) { |
|
|
if (ok) { |
|
|
result = new(zone()) FunctionLiteral( |
|
|
result = new(zone()) FunctionLiteral( |
|
|
|
|
|
isolate(), |
|
|
no_name, |
|
|
no_name, |
|
|
top_scope_, |
|
|
top_scope_, |
|
|
body, |
|
|
body, |
|
@ -718,7 +719,6 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info, |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
// Parse the function literal.
|
|
|
// Parse the function literal.
|
|
|
Handle<String> no_name = isolate()->factory()->empty_symbol(); |
|
|
|
|
|
Scope* scope = NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with()); |
|
|
Scope* scope = NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with()); |
|
|
if (!info->closure().is_null()) { |
|
|
if (!info->closure().is_null()) { |
|
|
scope = Scope::DeserializeScopeChain(info, scope); |
|
|
scope = Scope::DeserializeScopeChain(info, scope); |
|
@ -1262,7 +1262,7 @@ Statement* Parser::ParseStatement(ZoneStringList* labels, bool* ok) { |
|
|
// one must take great care not to treat it as a
|
|
|
// one must take great care not to treat it as a
|
|
|
// fall-through. It is much easier just to wrap the entire
|
|
|
// fall-through. It is much easier just to wrap the entire
|
|
|
// try-statement in a statement block and put the labels there
|
|
|
// try-statement in a statement block and put the labels there
|
|
|
Block* result = new(zone()) Block(labels, 1, false); |
|
|
Block* result = new(zone()) Block(isolate(), labels, 1, false); |
|
|
Target target(&this->target_stack_, result); |
|
|
Target target(&this->target_stack_, result); |
|
|
TryStatement* statement = ParseTryStatement(CHECK_OK); |
|
|
TryStatement* statement = ParseTryStatement(CHECK_OK); |
|
|
if (statement) { |
|
|
if (statement) { |
|
@ -1453,10 +1453,10 @@ Statement* Parser::ParseNativeDeclaration(bool* ok) { |
|
|
// introduced dynamically when we meet their declarations, whereas
|
|
|
// introduced dynamically when we meet their declarations, whereas
|
|
|
// other functions are setup when entering the surrounding scope.
|
|
|
// other functions are setup when entering the surrounding scope.
|
|
|
SharedFunctionInfoLiteral* lit = |
|
|
SharedFunctionInfoLiteral* lit = |
|
|
new(zone()) SharedFunctionInfoLiteral(shared); |
|
|
new(zone()) SharedFunctionInfoLiteral(isolate(), shared); |
|
|
VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); |
|
|
VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); |
|
|
return new(zone()) ExpressionStatement(new(zone()) Assignment( |
|
|
return new(zone()) ExpressionStatement(new(zone()) Assignment( |
|
|
Token::INIT_VAR, var, lit, RelocInfo::kNoPosition)); |
|
|
isolate(), Token::INIT_VAR, var, lit, RelocInfo::kNoPosition)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1489,7 +1489,7 @@ Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) { |
|
|
// (ECMA-262, 3rd, 12.2)
|
|
|
// (ECMA-262, 3rd, 12.2)
|
|
|
//
|
|
|
//
|
|
|
// Construct block expecting 16 statements.
|
|
|
// Construct block expecting 16 statements.
|
|
|
Block* result = new(zone()) Block(labels, 16, false); |
|
|
Block* result = new(zone()) Block(isolate(), labels, 16, false); |
|
|
Target target(&this->target_stack_, result); |
|
|
Target target(&this->target_stack_, result); |
|
|
Expect(Token::LBRACE, CHECK_OK); |
|
|
Expect(Token::LBRACE, CHECK_OK); |
|
|
InitializationBlockFinder block_finder(top_scope_, target_stack_); |
|
|
InitializationBlockFinder block_finder(top_scope_, target_stack_); |
|
@ -1564,7 +1564,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN, |
|
|
// is inside an initializer block, it is ignored.
|
|
|
// is inside an initializer block, it is ignored.
|
|
|
//
|
|
|
//
|
|
|
// Create new block with one expected declaration.
|
|
|
// Create new block with one expected declaration.
|
|
|
Block* block = new(zone()) Block(NULL, 1, true); |
|
|
Block* block = new(zone()) Block(isolate(), NULL, 1, true); |
|
|
int nvars = 0; // the number of variables declared
|
|
|
int nvars = 0; // the number of variables declared
|
|
|
Handle<String> name; |
|
|
Handle<String> name; |
|
|
do { |
|
|
do { |
|
@ -1676,7 +1676,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN, |
|
|
// Compute the arguments for the runtime call.
|
|
|
// Compute the arguments for the runtime call.
|
|
|
ZoneList<Expression*>* arguments = new(zone()) ZoneList<Expression*>(3); |
|
|
ZoneList<Expression*>* arguments = new(zone()) ZoneList<Expression*>(3); |
|
|
// We have at least 1 parameter.
|
|
|
// We have at least 1 parameter.
|
|
|
arguments->Add(new(zone()) Literal(name)); |
|
|
arguments->Add(NewLiteral(name)); |
|
|
CallRuntime* initialize; |
|
|
CallRuntime* initialize; |
|
|
|
|
|
|
|
|
if (is_const) { |
|
|
if (is_const) { |
|
@ -1689,9 +1689,10 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN, |
|
|
// the number of arguments (1 or 2).
|
|
|
// the number of arguments (1 or 2).
|
|
|
initialize = |
|
|
initialize = |
|
|
new(zone()) CallRuntime( |
|
|
new(zone()) CallRuntime( |
|
|
isolate()->factory()->InitializeConstGlobal_symbol(), |
|
|
isolate(), |
|
|
Runtime::FunctionForId(Runtime::kInitializeConstGlobal), |
|
|
isolate()->factory()->InitializeConstGlobal_symbol(), |
|
|
arguments); |
|
|
Runtime::FunctionForId(Runtime::kInitializeConstGlobal), |
|
|
|
|
|
arguments); |
|
|
} else { |
|
|
} else { |
|
|
// Add strict mode.
|
|
|
// Add strict mode.
|
|
|
// We may want to pass singleton to avoid Literal allocations.
|
|
|
// We may want to pass singleton to avoid Literal allocations.
|
|
@ -1715,9 +1716,10 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN, |
|
|
// the number of arguments (2 or 3).
|
|
|
// the number of arguments (2 or 3).
|
|
|
initialize = |
|
|
initialize = |
|
|
new(zone()) CallRuntime( |
|
|
new(zone()) CallRuntime( |
|
|
isolate()->factory()->InitializeVarGlobal_symbol(), |
|
|
isolate(), |
|
|
Runtime::FunctionForId(Runtime::kInitializeVarGlobal), |
|
|
isolate()->factory()->InitializeVarGlobal_symbol(), |
|
|
arguments); |
|
|
Runtime::FunctionForId(Runtime::kInitializeVarGlobal), |
|
|
|
|
|
arguments); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
block->AddStatement(new(zone()) ExpressionStatement(initialize)); |
|
|
block->AddStatement(new(zone()) ExpressionStatement(initialize)); |
|
@ -1739,7 +1741,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN, |
|
|
VariableProxy* proxy = |
|
|
VariableProxy* proxy = |
|
|
initialization_scope->NewUnresolved(name, in_with); |
|
|
initialization_scope->NewUnresolved(name, in_with); |
|
|
Assignment* assignment = |
|
|
Assignment* assignment = |
|
|
new(zone()) Assignment(op, proxy, value, position); |
|
|
new(zone()) Assignment(isolate(), op, proxy, value, position); |
|
|
if (block) { |
|
|
if (block) { |
|
|
block->AddStatement(new(zone()) ExpressionStatement(assignment)); |
|
|
block->AddStatement(new(zone()) ExpressionStatement(assignment)); |
|
|
} |
|
|
} |
|
@ -1842,7 +1844,8 @@ IfStatement* Parser::ParseIfStatement(ZoneStringList* labels, bool* ok) { |
|
|
} else { |
|
|
} else { |
|
|
else_statement = EmptyStatement(); |
|
|
else_statement = EmptyStatement(); |
|
|
} |
|
|
} |
|
|
return new(zone()) IfStatement(condition, then_statement, else_statement); |
|
|
return new(zone()) IfStatement( |
|
|
|
|
|
isolate(), condition, then_statement, else_statement); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1961,17 +1964,17 @@ Block* Parser::WithHelper(Expression* obj, ZoneStringList* labels, bool* ok) { |
|
|
// Create resulting block with two statements.
|
|
|
// Create resulting block with two statements.
|
|
|
// 1: Evaluate the with expression.
|
|
|
// 1: Evaluate the with expression.
|
|
|
// 2: The try-finally block evaluating the body.
|
|
|
// 2: The try-finally block evaluating the body.
|
|
|
Block* result = new(zone()) Block(NULL, 2, false); |
|
|
Block* result = new(zone()) Block(isolate(), NULL, 2, false); |
|
|
|
|
|
|
|
|
if (result != NULL) { |
|
|
if (result != NULL) { |
|
|
result->AddStatement(new(zone()) EnterWithContextStatement(obj)); |
|
|
result->AddStatement(new(zone()) EnterWithContextStatement(obj)); |
|
|
|
|
|
|
|
|
// Create body block.
|
|
|
// Create body block.
|
|
|
Block* body = new(zone()) Block(NULL, 1, false); |
|
|
Block* body = new(zone()) Block(isolate(), NULL, 1, false); |
|
|
body->AddStatement(stat); |
|
|
body->AddStatement(stat); |
|
|
|
|
|
|
|
|
// Create exit block.
|
|
|
// Create exit block.
|
|
|
Block* exit = new(zone()) Block(NULL, 1, false); |
|
|
Block* exit = new(zone()) Block(isolate(), NULL, 1, false); |
|
|
exit->AddStatement(new(zone()) ExitContextStatement()); |
|
|
exit->AddStatement(new(zone()) ExitContextStatement()); |
|
|
|
|
|
|
|
|
// Return a try-finally statement.
|
|
|
// Return a try-finally statement.
|
|
@ -2032,7 +2035,7 @@ CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) { |
|
|
statements->Add(stat); |
|
|
statements->Add(stat); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return new(zone()) CaseClause(label, statements, pos); |
|
|
return new(zone()) CaseClause(isolate(), label, statements, pos); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2041,7 +2044,7 @@ SwitchStatement* Parser::ParseSwitchStatement(ZoneStringList* labels, |
|
|
// SwitchStatement ::
|
|
|
// SwitchStatement ::
|
|
|
// 'switch' '(' Expression ')' '{' CaseClause* '}'
|
|
|
// 'switch' '(' Expression ')' '{' CaseClause* '}'
|
|
|
|
|
|
|
|
|
SwitchStatement* statement = new(zone()) SwitchStatement(labels); |
|
|
SwitchStatement* statement = new(zone()) SwitchStatement(isolate(), labels); |
|
|
Target target(&this->target_stack_, statement); |
|
|
Target target(&this->target_stack_, statement); |
|
|
|
|
|
|
|
|
Expect(Token::SWITCH, CHECK_OK); |
|
|
Expect(Token::SWITCH, CHECK_OK); |
|
@ -2077,7 +2080,8 @@ Statement* Parser::ParseThrowStatement(bool* ok) { |
|
|
Expression* exception = ParseExpression(true, CHECK_OK); |
|
|
Expression* exception = ParseExpression(true, CHECK_OK); |
|
|
ExpectSemicolon(CHECK_OK); |
|
|
ExpectSemicolon(CHECK_OK); |
|
|
|
|
|
|
|
|
return new(zone()) ExpressionStatement(new(zone()) Throw(exception, pos)); |
|
|
return new(zone()) ExpressionStatement( |
|
|
|
|
|
new(zone()) Throw(isolate(), exception, pos)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2156,7 +2160,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Create exit block.
|
|
|
// Create exit block.
|
|
|
Block* inner_finally = new(zone()) Block(NULL, 1, false); |
|
|
Block* inner_finally = new(zone()) Block(isolate(), NULL, 1, false); |
|
|
inner_finally->AddStatement(new(zone()) ExitContextStatement()); |
|
|
inner_finally->AddStatement(new(zone()) ExitContextStatement()); |
|
|
|
|
|
|
|
|
// Create a try/finally statement.
|
|
|
// Create a try/finally statement.
|
|
@ -2164,7 +2168,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
|
|
new(zone()) TryFinallyStatement(inner_body, inner_finally); |
|
|
new(zone()) TryFinallyStatement(inner_body, inner_finally); |
|
|
inner_try_finally->set_escaping_targets(inner_collector.targets()); |
|
|
inner_try_finally->set_escaping_targets(inner_collector.targets()); |
|
|
|
|
|
|
|
|
catch_block = new(zone()) Block(NULL, 1, false); |
|
|
catch_block = new(zone()) Block(isolate(), NULL, 1, false); |
|
|
catch_block->AddStatement(inner_try_finally); |
|
|
catch_block->AddStatement(inner_try_finally); |
|
|
} else { |
|
|
} else { |
|
|
Expect(Token::LBRACE, CHECK_OK); |
|
|
Expect(Token::LBRACE, CHECK_OK); |
|
@ -2193,7 +2197,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
|
|
catch_variable, |
|
|
catch_variable, |
|
|
catch_block); |
|
|
catch_block); |
|
|
statement->set_escaping_targets(try_collector.targets()); |
|
|
statement->set_escaping_targets(try_collector.targets()); |
|
|
try_block = new(zone()) Block(NULL, 1, false); |
|
|
try_block = new(zone()) Block(isolate(), NULL, 1, false); |
|
|
try_block->AddStatement(statement); |
|
|
try_block->AddStatement(statement); |
|
|
catch_block = NULL; // Clear to indicate it's been handled.
|
|
|
catch_block = NULL; // Clear to indicate it's been handled.
|
|
|
} |
|
|
} |
|
@ -2224,7 +2228,7 @@ DoWhileStatement* Parser::ParseDoWhileStatement(ZoneStringList* labels, |
|
|
// DoStatement ::
|
|
|
// DoStatement ::
|
|
|
// 'do' Statement 'while' '(' Expression ')' ';'
|
|
|
// 'do' Statement 'while' '(' Expression ')' ';'
|
|
|
|
|
|
|
|
|
DoWhileStatement* loop = new(zone()) DoWhileStatement(labels); |
|
|
DoWhileStatement* loop = new(zone()) DoWhileStatement(isolate(), labels); |
|
|
Target target(&this->target_stack_, loop); |
|
|
Target target(&this->target_stack_, loop); |
|
|
|
|
|
|
|
|
Expect(Token::DO, CHECK_OK); |
|
|
Expect(Token::DO, CHECK_OK); |
|
@ -2255,7 +2259,7 @@ WhileStatement* Parser::ParseWhileStatement(ZoneStringList* labels, bool* ok) { |
|
|
// WhileStatement ::
|
|
|
// WhileStatement ::
|
|
|
// 'while' '(' Expression ')' Statement
|
|
|
// 'while' '(' Expression ')' Statement
|
|
|
|
|
|
|
|
|
WhileStatement* loop = new(zone()) WhileStatement(labels); |
|
|
WhileStatement* loop = new(zone()) WhileStatement(isolate(), labels); |
|
|
Target target(&this->target_stack_, loop); |
|
|
Target target(&this->target_stack_, loop); |
|
|
|
|
|
|
|
|
Expect(Token::WHILE, CHECK_OK); |
|
|
Expect(Token::WHILE, CHECK_OK); |
|
@ -2285,7 +2289,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
|
|
|
|
|
|
|
|
if (peek() == Token::IN && !name.is_null()) { |
|
|
if (peek() == Token::IN && !name.is_null()) { |
|
|
VariableProxy* each = top_scope_->NewUnresolved(name, inside_with()); |
|
|
VariableProxy* each = top_scope_->NewUnresolved(name, inside_with()); |
|
|
ForInStatement* loop = new(zone()) ForInStatement(labels); |
|
|
ForInStatement* loop = new(zone()) ForInStatement(isolate(), labels); |
|
|
Target target(&this->target_stack_, loop); |
|
|
Target target(&this->target_stack_, loop); |
|
|
|
|
|
|
|
|
Expect(Token::IN, CHECK_OK); |
|
|
Expect(Token::IN, CHECK_OK); |
|
@ -2294,7 +2298,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
|
|
|
|
|
|
|
|
Statement* body = ParseStatement(NULL, CHECK_OK); |
|
|
Statement* body = ParseStatement(NULL, CHECK_OK); |
|
|
loop->Initialize(each, enumerable, body); |
|
|
loop->Initialize(each, enumerable, body); |
|
|
Block* result = new(zone()) Block(NULL, 2, false); |
|
|
Block* result = new(zone()) Block(isolate(), NULL, 2, false); |
|
|
result->AddStatement(variable_statement); |
|
|
result->AddStatement(variable_statement); |
|
|
result->AddStatement(loop); |
|
|
result->AddStatement(loop); |
|
|
// Parsed for-in loop w/ variable/const declaration.
|
|
|
// Parsed for-in loop w/ variable/const declaration.
|
|
@ -2315,7 +2319,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
|
|
isolate()->factory()->invalid_lhs_in_for_in_symbol(); |
|
|
isolate()->factory()->invalid_lhs_in_for_in_symbol(); |
|
|
expression = NewThrowReferenceError(type); |
|
|
expression = NewThrowReferenceError(type); |
|
|
} |
|
|
} |
|
|
ForInStatement* loop = new(zone()) ForInStatement(labels); |
|
|
ForInStatement* loop = new(zone()) ForInStatement(isolate(), labels); |
|
|
Target target(&this->target_stack_, loop); |
|
|
Target target(&this->target_stack_, loop); |
|
|
|
|
|
|
|
|
Expect(Token::IN, CHECK_OK); |
|
|
Expect(Token::IN, CHECK_OK); |
|
@ -2334,7 +2338,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Standard 'for' loop
|
|
|
// Standard 'for' loop
|
|
|
ForStatement* loop = new(zone()) ForStatement(labels); |
|
|
ForStatement* loop = new(zone()) ForStatement(isolate(), labels); |
|
|
Target target(&this->target_stack_, loop); |
|
|
Target target(&this->target_stack_, loop); |
|
|
|
|
|
|
|
|
// Parsed initializer at this point.
|
|
|
// Parsed initializer at this point.
|
|
@ -2370,7 +2374,8 @@ Expression* Parser::ParseExpression(bool accept_IN, bool* ok) { |
|
|
Expect(Token::COMMA, CHECK_OK); |
|
|
Expect(Token::COMMA, CHECK_OK); |
|
|
int position = scanner().location().beg_pos; |
|
|
int position = scanner().location().beg_pos; |
|
|
Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK); |
|
|
Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK); |
|
|
result = new(zone()) BinaryOperation(Token::COMMA, result, right, position); |
|
|
result = new(zone()) BinaryOperation( |
|
|
|
|
|
isolate(), Token::COMMA, result, right, position); |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
@ -2442,7 +2447,7 @@ Expression* Parser::ParseAssignmentExpression(bool accept_IN, bool* ok) { |
|
|
fni_->Leave(); |
|
|
fni_->Leave(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return new(zone()) Assignment(op, expression, right, pos); |
|
|
return new(zone()) Assignment(isolate(), op, expression, right, pos); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2464,8 +2469,8 @@ Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) { |
|
|
Expect(Token::COLON, CHECK_OK); |
|
|
Expect(Token::COLON, CHECK_OK); |
|
|
int right_position = scanner().peek_location().beg_pos; |
|
|
int right_position = scanner().peek_location().beg_pos; |
|
|
Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK); |
|
|
Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK); |
|
|
return new(zone()) Conditional(expression, left, right, |
|
|
return new(zone()) Conditional( |
|
|
left_position, right_position); |
|
|
isolate(), expression, left, right, left_position, right_position); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2552,12 +2557,12 @@ Expression* Parser::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) { |
|
|
x = NewCompareNode(cmp, x, y, position); |
|
|
x = NewCompareNode(cmp, x, y, position); |
|
|
if (cmp != op) { |
|
|
if (cmp != op) { |
|
|
// The comparison was negated - add a NOT.
|
|
|
// The comparison was negated - add a NOT.
|
|
|
x = new(zone()) UnaryOperation(Token::NOT, x, position); |
|
|
x = new(zone()) UnaryOperation(isolate(), Token::NOT, x, position); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// We have a "normal" binary operation.
|
|
|
// We have a "normal" binary operation.
|
|
|
x = new(zone()) BinaryOperation(op, x, y, position); |
|
|
x = new(zone()) BinaryOperation(isolate(), op, x, y, position); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -2574,15 +2579,15 @@ Expression* Parser::NewCompareNode(Token::Value op, |
|
|
bool is_strict = (op == Token::EQ_STRICT); |
|
|
bool is_strict = (op == Token::EQ_STRICT); |
|
|
Literal* x_literal = x->AsLiteral(); |
|
|
Literal* x_literal = x->AsLiteral(); |
|
|
if (x_literal != NULL && x_literal->IsNull()) { |
|
|
if (x_literal != NULL && x_literal->IsNull()) { |
|
|
return new(zone()) CompareToNull(is_strict, y); |
|
|
return new(zone()) CompareToNull(isolate(), is_strict, y); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Literal* y_literal = y->AsLiteral(); |
|
|
Literal* y_literal = y->AsLiteral(); |
|
|
if (y_literal != NULL && y_literal->IsNull()) { |
|
|
if (y_literal != NULL && y_literal->IsNull()) { |
|
|
return new(zone()) CompareToNull(is_strict, x); |
|
|
return new(zone()) CompareToNull(isolate(), is_strict, x); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return new(zone()) CompareOperation(op, x, y, position); |
|
|
return new(zone()) CompareOperation(isolate(), op, x, y, position); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2611,7 +2616,7 @@ Expression* Parser::ParseUnaryExpression(bool* ok) { |
|
|
// Convert the literal to a boolean condition and negate it.
|
|
|
// Convert the literal to a boolean condition and negate it.
|
|
|
bool condition = literal->ToBoolean()->IsTrue(); |
|
|
bool condition = literal->ToBoolean()->IsTrue(); |
|
|
Handle<Object> result(isolate()->heap()->ToBoolean(!condition)); |
|
|
Handle<Object> result(isolate()->heap()->ToBoolean(!condition)); |
|
|
return new(zone()) Literal(result); |
|
|
return NewLiteral(result); |
|
|
} else if (literal->IsNumber()) { |
|
|
} else if (literal->IsNumber()) { |
|
|
// Compute some expressions involving only number literals.
|
|
|
// Compute some expressions involving only number literals.
|
|
|
double value = literal->Number(); |
|
|
double value = literal->Number(); |
|
@ -2638,7 +2643,7 @@ Expression* Parser::ParseUnaryExpression(bool* ok) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return new(zone()) UnaryOperation(op, expression, position); |
|
|
return new(zone()) UnaryOperation(isolate(), op, expression, position); |
|
|
|
|
|
|
|
|
} else if (Token::IsCountOp(op)) { |
|
|
} else if (Token::IsCountOp(op)) { |
|
|
op = Next(); |
|
|
op = Next(); |
|
@ -2659,7 +2664,8 @@ Expression* Parser::ParseUnaryExpression(bool* ok) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int position = scanner().location().beg_pos; |
|
|
int position = scanner().location().beg_pos; |
|
|
return new(zone()) CountOperation(op, |
|
|
return new(zone()) CountOperation(isolate(), |
|
|
|
|
|
op, |
|
|
true /* prefix */, |
|
|
true /* prefix */, |
|
|
expression, |
|
|
expression, |
|
|
position); |
|
|
position); |
|
@ -2695,7 +2701,8 @@ Expression* Parser::ParsePostfixExpression(bool* ok) { |
|
|
Token::Value next = Next(); |
|
|
Token::Value next = Next(); |
|
|
int position = scanner().location().beg_pos; |
|
|
int position = scanner().location().beg_pos; |
|
|
expression = |
|
|
expression = |
|
|
new(zone()) CountOperation(next, |
|
|
new(zone()) CountOperation(isolate(), |
|
|
|
|
|
next, |
|
|
false /* postfix */, |
|
|
false /* postfix */, |
|
|
expression, |
|
|
expression, |
|
|
position); |
|
|
position); |
|
@ -2721,7 +2728,7 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) { |
|
|
Consume(Token::LBRACK); |
|
|
Consume(Token::LBRACK); |
|
|
int pos = scanner().location().beg_pos; |
|
|
int pos = scanner().location().beg_pos; |
|
|
Expression* index = ParseExpression(true, CHECK_OK); |
|
|
Expression* index = ParseExpression(true, CHECK_OK); |
|
|
result = new(zone()) Property(result, index, pos); |
|
|
result = new(zone()) Property(isolate(), result, index, pos); |
|
|
Expect(Token::RBRACK, CHECK_OK); |
|
|
Expect(Token::RBRACK, CHECK_OK); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -2759,7 +2766,10 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) { |
|
|
Consume(Token::PERIOD); |
|
|
Consume(Token::PERIOD); |
|
|
int pos = scanner().location().beg_pos; |
|
|
int pos = scanner().location().beg_pos; |
|
|
Handle<String> name = ParseIdentifierName(CHECK_OK); |
|
|
Handle<String> name = ParseIdentifierName(CHECK_OK); |
|
|
result = new(zone()) Property(result, new(zone()) Literal(name), pos); |
|
|
result = new(zone()) Property(isolate(), |
|
|
|
|
|
result, |
|
|
|
|
|
NewLiteral(name), |
|
|
|
|
|
pos); |
|
|
if (fni_ != NULL) fni_->PushLiteralName(name); |
|
|
if (fni_ != NULL) fni_->PushLiteralName(name); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -2795,7 +2805,8 @@ Expression* Parser::ParseNewPrefix(PositionStack* stack, bool* ok) { |
|
|
|
|
|
|
|
|
if (!stack->is_empty()) { |
|
|
if (!stack->is_empty()) { |
|
|
int last = stack->pop(); |
|
|
int last = stack->pop(); |
|
|
result = new(zone()) CallNew(result, |
|
|
result = new(zone()) CallNew(isolate(), |
|
|
|
|
|
result, |
|
|
new(zone()) ZoneList<Expression*>(0), |
|
|
new(zone()) ZoneList<Expression*>(0), |
|
|
last); |
|
|
last); |
|
|
} |
|
|
} |
|
@ -2843,7 +2854,7 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack, |
|
|
Consume(Token::LBRACK); |
|
|
Consume(Token::LBRACK); |
|
|
int pos = scanner().location().beg_pos; |
|
|
int pos = scanner().location().beg_pos; |
|
|
Expression* index = ParseExpression(true, CHECK_OK); |
|
|
Expression* index = ParseExpression(true, CHECK_OK); |
|
|
result = new(zone()) Property(result, index, pos); |
|
|
result = new(zone()) Property(isolate(), result, index, pos); |
|
|
if (fni_ != NULL) { |
|
|
if (fni_ != NULL) { |
|
|
if (index->IsPropertyName()) { |
|
|
if (index->IsPropertyName()) { |
|
|
fni_->PushLiteralName(index->AsLiteral()->AsPropertyName()); |
|
|
fni_->PushLiteralName(index->AsLiteral()->AsPropertyName()); |
|
@ -2859,7 +2870,10 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack, |
|
|
Consume(Token::PERIOD); |
|
|
Consume(Token::PERIOD); |
|
|
int pos = scanner().location().beg_pos; |
|
|
int pos = scanner().location().beg_pos; |
|
|
Handle<String> name = ParseIdentifierName(CHECK_OK); |
|
|
Handle<String> name = ParseIdentifierName(CHECK_OK); |
|
|
result = new(zone()) Property(result, new(zone()) Literal(name), pos); |
|
|
result = new(zone()) Property(isolate(), |
|
|
|
|
|
result, |
|
|
|
|
|
NewLiteral(name), |
|
|
|
|
|
pos); |
|
|
if (fni_ != NULL) fni_->PushLiteralName(name); |
|
|
if (fni_ != NULL) fni_->PushLiteralName(name); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -2868,7 +2882,7 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack, |
|
|
// Consume one of the new prefixes (already parsed).
|
|
|
// Consume one of the new prefixes (already parsed).
|
|
|
ZoneList<Expression*>* args = ParseArguments(CHECK_OK); |
|
|
ZoneList<Expression*>* args = ParseArguments(CHECK_OK); |
|
|
int last = stack->pop(); |
|
|
int last = stack->pop(); |
|
|
result = new CallNew(result, args, last); |
|
|
result = new(zone()) CallNew(isolate(), result, args, last); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
default: |
|
|
default: |
|
@ -2952,23 +2966,26 @@ Expression* Parser::ParsePrimaryExpression(bool* ok) { |
|
|
switch (peek()) { |
|
|
switch (peek()) { |
|
|
case Token::THIS: { |
|
|
case Token::THIS: { |
|
|
Consume(Token::THIS); |
|
|
Consume(Token::THIS); |
|
|
result = new(zone()) VariableProxy(top_scope_->receiver()); |
|
|
result = new(zone()) VariableProxy(isolate(), top_scope_->receiver()); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case Token::NULL_LITERAL: |
|
|
case Token::NULL_LITERAL: |
|
|
Consume(Token::NULL_LITERAL); |
|
|
Consume(Token::NULL_LITERAL); |
|
|
result = new(zone()) Literal(isolate()->factory()->null_value()); |
|
|
result = new(zone()) Literal( |
|
|
|
|
|
isolate(), isolate()->factory()->null_value()); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case Token::TRUE_LITERAL: |
|
|
case Token::TRUE_LITERAL: |
|
|
Consume(Token::TRUE_LITERAL); |
|
|
Consume(Token::TRUE_LITERAL); |
|
|
result = new(zone()) Literal(isolate()->factory()->true_value()); |
|
|
result = new(zone()) Literal( |
|
|
|
|
|
isolate(), isolate()->factory()->true_value()); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case Token::FALSE_LITERAL: |
|
|
case Token::FALSE_LITERAL: |
|
|
Consume(Token::FALSE_LITERAL); |
|
|
Consume(Token::FALSE_LITERAL); |
|
|
result = new(zone()) Literal(isolate()->factory()->false_value()); |
|
|
result = new(zone()) Literal( |
|
|
|
|
|
isolate(), isolate()->factory()->false_value()); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case Token::IDENTIFIER: |
|
|
case Token::IDENTIFIER: |
|
@ -2994,7 +3011,7 @@ Expression* Parser::ParsePrimaryExpression(bool* ok) { |
|
|
case Token::STRING: { |
|
|
case Token::STRING: { |
|
|
Consume(Token::STRING); |
|
|
Consume(Token::STRING); |
|
|
Handle<String> symbol = GetSymbol(CHECK_OK); |
|
|
Handle<String> symbol = GetSymbol(CHECK_OK); |
|
|
result = new(zone()) Literal(symbol); |
|
|
result = NewLiteral(symbol); |
|
|
if (fni_ != NULL) fni_->PushLiteralName(symbol); |
|
|
if (fni_ != NULL) fni_->PushLiteralName(symbol); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -3121,8 +3138,8 @@ Expression* Parser::ParseArrayLiteral(bool* ok) { |
|
|
literals->set_map(isolate()->heap()->fixed_cow_array_map()); |
|
|
literals->set_map(isolate()->heap()->fixed_cow_array_map()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return new(zone()) ArrayLiteral(literals, values, |
|
|
return new(zone()) ArrayLiteral( |
|
|
literal_index, is_simple, depth); |
|
|
isolate(), literals, values, literal_index, is_simple, depth); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3425,7 +3442,6 @@ Expression* Parser::ParseObjectLiteral(bool* ok) { |
|
|
ObjectLiteralPropertyChecker checker(this, top_scope_->is_strict_mode()); |
|
|
ObjectLiteralPropertyChecker checker(this, top_scope_->is_strict_mode()); |
|
|
|
|
|
|
|
|
Expect(Token::LBRACE, CHECK_OK); |
|
|
Expect(Token::LBRACE, CHECK_OK); |
|
|
Scanner::Location loc = scanner().location(); |
|
|
|
|
|
|
|
|
|
|
|
while (peek() != Token::RBRACE) { |
|
|
while (peek() != Token::RBRACE) { |
|
|
if (fni_ != NULL) fni_->Enter(); |
|
|
if (fni_ != NULL) fni_->Enter(); |
|
@ -3467,7 +3483,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) { |
|
|
} |
|
|
} |
|
|
// Failed to parse as get/set property, so it's just a property
|
|
|
// Failed to parse as get/set property, so it's just a property
|
|
|
// called "get" or "set".
|
|
|
// called "get" or "set".
|
|
|
key = new(zone()) Literal(id); |
|
|
key = NewLiteral(id); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case Token::STRING: { |
|
|
case Token::STRING: { |
|
@ -3479,7 +3495,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) { |
|
|
key = NewNumberLiteral(index); |
|
|
key = NewNumberLiteral(index); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
key = new(zone()) Literal(string); |
|
|
key = NewLiteral(string); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case Token::NUMBER: { |
|
|
case Token::NUMBER: { |
|
@ -3495,7 +3511,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) { |
|
|
if (Token::IsKeyword(next)) { |
|
|
if (Token::IsKeyword(next)) { |
|
|
Consume(next); |
|
|
Consume(next); |
|
|
Handle<String> string = GetSymbol(CHECK_OK); |
|
|
Handle<String> string = GetSymbol(CHECK_OK); |
|
|
key = new(zone()) Literal(string); |
|
|
key = NewLiteral(string); |
|
|
} else { |
|
|
} else { |
|
|
// Unexpected token.
|
|
|
// Unexpected token.
|
|
|
Token::Value next = Next(); |
|
|
Token::Value next = Next(); |
|
@ -3548,13 +3564,14 @@ Expression* Parser::ParseObjectLiteral(bool* ok) { |
|
|
&is_simple, |
|
|
&is_simple, |
|
|
&fast_elements, |
|
|
&fast_elements, |
|
|
&depth); |
|
|
&depth); |
|
|
return new(zone()) ObjectLiteral(constant_properties, |
|
|
return new(zone()) ObjectLiteral(isolate(), |
|
|
properties, |
|
|
constant_properties, |
|
|
literal_index, |
|
|
properties, |
|
|
is_simple, |
|
|
literal_index, |
|
|
fast_elements, |
|
|
is_simple, |
|
|
depth, |
|
|
fast_elements, |
|
|
has_function); |
|
|
depth, |
|
|
|
|
|
has_function); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3573,7 +3590,8 @@ Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) { |
|
|
Handle<String> js_flags = NextLiteralString(TENURED); |
|
|
Handle<String> js_flags = NextLiteralString(TENURED); |
|
|
Next(); |
|
|
Next(); |
|
|
|
|
|
|
|
|
return new(zone()) RegExpLiteral(js_pattern, js_flags, literal_index); |
|
|
return new(zone()) RegExpLiteral( |
|
|
|
|
|
isolate(), js_pattern, js_flags, literal_index); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3690,9 +3708,11 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name, |
|
|
top_scope_->NewUnresolved(function_name, inside_with()); |
|
|
top_scope_->NewUnresolved(function_name, inside_with()); |
|
|
fproxy->BindTo(fvar); |
|
|
fproxy->BindTo(fvar); |
|
|
body->Add(new(zone()) ExpressionStatement( |
|
|
body->Add(new(zone()) ExpressionStatement( |
|
|
new(zone()) Assignment(Token::INIT_CONST, fproxy, |
|
|
new(zone()) Assignment(isolate(), |
|
|
new(zone()) ThisFunction(), |
|
|
Token::INIT_CONST, |
|
|
RelocInfo::kNoPosition))); |
|
|
fproxy, |
|
|
|
|
|
new(zone()) ThisFunction(isolate()), |
|
|
|
|
|
RelocInfo::kNoPosition))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Determine if the function will be lazily compiled. The mode can
|
|
|
// Determine if the function will be lazily compiled. The mode can
|
|
@ -3782,7 +3802,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
FunctionLiteral* function_literal = |
|
|
FunctionLiteral* function_literal = |
|
|
new(zone()) FunctionLiteral(name, |
|
|
new(zone()) FunctionLiteral(isolate(), |
|
|
|
|
|
name, |
|
|
scope, |
|
|
scope, |
|
|
body, |
|
|
body, |
|
|
materialized_literal_count, |
|
|
materialized_literal_count, |
|
@ -3843,7 +3864,7 @@ Expression* Parser::ParseV8Intrinsic(bool* ok) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// We have a valid intrinsics call or a call to a builtin.
|
|
|
// We have a valid intrinsics call or a call to a builtin.
|
|
|
return new(zone()) CallRuntime(name, function, args); |
|
|
return new(zone()) CallRuntime(isolate(), name, function, args); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3899,12 +3920,12 @@ void Parser::ExpectSemicolon(bool* ok) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Literal* Parser::GetLiteralUndefined() { |
|
|
Literal* Parser::GetLiteralUndefined() { |
|
|
return new(zone()) Literal(isolate()->factory()->undefined_value()); |
|
|
return NewLiteral(isolate()->factory()->undefined_value()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Literal* Parser::GetLiteralTheHole() { |
|
|
Literal* Parser::GetLiteralTheHole() { |
|
|
return new(zone()) Literal(isolate()->factory()->the_hole_value()); |
|
|
return NewLiteral(isolate()->factory()->the_hole_value()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -4060,7 +4081,7 @@ void Parser::RegisterTargetUse(Label* target, Target* stop) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Literal* Parser::NewNumberLiteral(double number) { |
|
|
Literal* Parser::NewNumberLiteral(double number) { |
|
|
return new(zone()) Literal(isolate()->factory()->NewNumber(number, TENURED)); |
|
|
return NewLiteral(isolate()->factory()->NewNumber(number, TENURED)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -4107,10 +4128,15 @@ Expression* Parser::NewThrowError(Handle<String> constructor, |
|
|
TENURED); |
|
|
TENURED); |
|
|
|
|
|
|
|
|
ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2); |
|
|
ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2); |
|
|
args->Add(new(zone()) Literal(type)); |
|
|
args->Add(NewLiteral(type)); |
|
|
args->Add(new(zone()) Literal(array)); |
|
|
args->Add(NewLiteral(array)); |
|
|
return new(zone()) Throw(new(zone()) CallRuntime(constructor, NULL, args), |
|
|
CallRuntime* call_constructor = new(zone()) CallRuntime(isolate(), |
|
|
scanner().location().beg_pos); |
|
|
constructor, |
|
|
|
|
|
NULL, |
|
|
|
|
|
args); |
|
|
|
|
|
return new(zone()) Throw(isolate(), |
|
|
|
|
|
call_constructor, |
|
|
|
|
|
scanner().location().beg_pos); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
// ----------------------------------------------------------------------------
|
|
|