| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 } | 641 } |
| 642 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16); | 642 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16); |
| 643 bool ok = true; | 643 bool ok = true; |
| 644 int beg_loc = scanner().location().beg_pos; | 644 int beg_loc = scanner().location().beg_pos; |
| 645 ParseSourceElements(body, Token::EOS, &ok); | 645 ParseSourceElements(body, Token::EOS, &ok); |
| 646 if (ok && top_scope_->is_strict_mode()) { | 646 if (ok && top_scope_->is_strict_mode()) { |
| 647 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok); | 647 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok); |
| 648 } | 648 } |
| 649 if (ok) { | 649 if (ok) { |
| 650 result = new(zone()) FunctionLiteral( | 650 result = new(zone()) FunctionLiteral( |
| 651 isolate(), |
| 651 no_name, | 652 no_name, |
| 652 top_scope_, | 653 top_scope_, |
| 653 body, | 654 body, |
| 654 lexical_scope.materialized_literal_count(), | 655 lexical_scope.materialized_literal_count(), |
| 655 lexical_scope.expected_property_count(), | 656 lexical_scope.expected_property_count(), |
| 656 lexical_scope.only_simple_this_property_assignments(), | 657 lexical_scope.only_simple_this_property_assignments(), |
| 657 lexical_scope.this_property_assignments(), | 658 lexical_scope.this_property_assignments(), |
| 658 0, | 659 0, |
| 659 0, | 660 0, |
| 660 source->length(), | 661 source->length(), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 fni_ = new(zone()) FuncNameInferrer(isolate()); | 712 fni_ = new(zone()) FuncNameInferrer(isolate()); |
| 712 fni_->PushEnclosingName(name); | 713 fni_->PushEnclosingName(name); |
| 713 | 714 |
| 714 mode_ = PARSE_EAGERLY; | 715 mode_ = PARSE_EAGERLY; |
| 715 | 716 |
| 716 // Place holder for the result. | 717 // Place holder for the result. |
| 717 FunctionLiteral* result = NULL; | 718 FunctionLiteral* result = NULL; |
| 718 | 719 |
| 719 { | 720 { |
| 720 // Parse the function literal. | 721 // Parse the function literal. |
| 721 Handle<String> no_name = isolate()->factory()->empty_symbol(); | |
| 722 Scope* scope = NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with()); | 722 Scope* scope = NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with()); |
| 723 if (!info->closure().is_null()) { | 723 if (!info->closure().is_null()) { |
| 724 scope = Scope::DeserializeScopeChain(info, scope); | 724 scope = Scope::DeserializeScopeChain(info, scope); |
| 725 } | 725 } |
| 726 LexicalScope lexical_scope(this, scope, isolate()); | 726 LexicalScope lexical_scope(this, scope, isolate()); |
| 727 | 727 |
| 728 if (shared_info->strict_mode()) { | 728 if (shared_info->strict_mode()) { |
| 729 top_scope_->EnableStrictMode(); | 729 top_scope_->EnableStrictMode(); |
| 730 } | 730 } |
| 731 | 731 |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 case Token::THROW: | 1255 case Token::THROW: |
| 1256 stmt = ParseThrowStatement(ok); | 1256 stmt = ParseThrowStatement(ok); |
| 1257 break; | 1257 break; |
| 1258 | 1258 |
| 1259 case Token::TRY: { | 1259 case Token::TRY: { |
| 1260 // NOTE: It is somewhat complicated to have labels on | 1260 // NOTE: It is somewhat complicated to have labels on |
| 1261 // try-statements. When breaking out of a try-finally statement, | 1261 // try-statements. When breaking out of a try-finally statement, |
| 1262 // one must take great care not to treat it as a | 1262 // one must take great care not to treat it as a |
| 1263 // fall-through. It is much easier just to wrap the entire | 1263 // fall-through. It is much easier just to wrap the entire |
| 1264 // try-statement in a statement block and put the labels there | 1264 // try-statement in a statement block and put the labels there |
| 1265 Block* result = new(zone()) Block(labels, 1, false); | 1265 Block* result = new(zone()) Block(isolate(), labels, 1, false); |
| 1266 Target target(&this->target_stack_, result); | 1266 Target target(&this->target_stack_, result); |
| 1267 TryStatement* statement = ParseTryStatement(CHECK_OK); | 1267 TryStatement* statement = ParseTryStatement(CHECK_OK); |
| 1268 if (statement) { | 1268 if (statement) { |
| 1269 statement->set_statement_pos(statement_pos); | 1269 statement->set_statement_pos(statement_pos); |
| 1270 } | 1270 } |
| 1271 if (result) result->AddStatement(statement); | 1271 if (result) result->AddStatement(statement); |
| 1272 return result; | 1272 return result; |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 case Token::FUNCTION: { | 1275 case Token::FUNCTION: { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 | 1446 |
| 1447 // Copy the function data to the shared function info. | 1447 // Copy the function data to the shared function info. |
| 1448 shared->set_function_data(fun->shared()->function_data()); | 1448 shared->set_function_data(fun->shared()->function_data()); |
| 1449 int parameters = fun->shared()->formal_parameter_count(); | 1449 int parameters = fun->shared()->formal_parameter_count(); |
| 1450 shared->set_formal_parameter_count(parameters); | 1450 shared->set_formal_parameter_count(parameters); |
| 1451 | 1451 |
| 1452 // TODO(1240846): It's weird that native function declarations are | 1452 // TODO(1240846): It's weird that native function declarations are |
| 1453 // introduced dynamically when we meet their declarations, whereas | 1453 // introduced dynamically when we meet their declarations, whereas |
| 1454 // other functions are setup when entering the surrounding scope. | 1454 // other functions are setup when entering the surrounding scope. |
| 1455 SharedFunctionInfoLiteral* lit = | 1455 SharedFunctionInfoLiteral* lit = |
| 1456 new(zone()) SharedFunctionInfoLiteral(shared); | 1456 new(zone()) SharedFunctionInfoLiteral(isolate(), shared); |
| 1457 VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); | 1457 VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); |
| 1458 return new(zone()) ExpressionStatement(new(zone()) Assignment( | 1458 return new(zone()) ExpressionStatement(new(zone()) Assignment( |
| 1459 Token::INIT_VAR, var, lit, RelocInfo::kNoPosition)); | 1459 isolate(), Token::INIT_VAR, var, lit, RelocInfo::kNoPosition)); |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 | 1462 |
| 1463 Statement* Parser::ParseFunctionDeclaration(bool* ok) { | 1463 Statement* Parser::ParseFunctionDeclaration(bool* ok) { |
| 1464 // FunctionDeclaration :: | 1464 // FunctionDeclaration :: |
| 1465 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' | 1465 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' |
| 1466 Expect(Token::FUNCTION, CHECK_OK); | 1466 Expect(Token::FUNCTION, CHECK_OK); |
| 1467 int function_token_position = scanner().location().beg_pos; | 1467 int function_token_position = scanner().location().beg_pos; |
| 1468 bool is_strict_reserved = false; | 1468 bool is_strict_reserved = false; |
| 1469 Handle<String> name = ParseIdentifierOrStrictReservedWord( | 1469 Handle<String> name = ParseIdentifierOrStrictReservedWord( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1482 | 1482 |
| 1483 | 1483 |
| 1484 Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) { | 1484 Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) { |
| 1485 // Block :: | 1485 // Block :: |
| 1486 // '{' Statement* '}' | 1486 // '{' Statement* '}' |
| 1487 | 1487 |
| 1488 // Note that a Block does not introduce a new execution scope! | 1488 // Note that a Block does not introduce a new execution scope! |
| 1489 // (ECMA-262, 3rd, 12.2) | 1489 // (ECMA-262, 3rd, 12.2) |
| 1490 // | 1490 // |
| 1491 // Construct block expecting 16 statements. | 1491 // Construct block expecting 16 statements. |
| 1492 Block* result = new(zone()) Block(labels, 16, false); | 1492 Block* result = new(zone()) Block(isolate(), labels, 16, false); |
| 1493 Target target(&this->target_stack_, result); | 1493 Target target(&this->target_stack_, result); |
| 1494 Expect(Token::LBRACE, CHECK_OK); | 1494 Expect(Token::LBRACE, CHECK_OK); |
| 1495 InitializationBlockFinder block_finder(top_scope_, target_stack_); | 1495 InitializationBlockFinder block_finder(top_scope_, target_stack_); |
| 1496 while (peek() != Token::RBRACE) { | 1496 while (peek() != Token::RBRACE) { |
| 1497 Statement* stat = ParseStatement(NULL, CHECK_OK); | 1497 Statement* stat = ParseStatement(NULL, CHECK_OK); |
| 1498 if (stat && !stat->IsEmpty()) { | 1498 if (stat && !stat->IsEmpty()) { |
| 1499 result->AddStatement(stat); | 1499 result->AddStatement(stat); |
| 1500 block_finder.Update(stat); | 1500 block_finder.Update(stat); |
| 1501 } | 1501 } |
| 1502 } | 1502 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 // Scope declaration, and rewrite the source-level initialization into an | 1557 // Scope declaration, and rewrite the source-level initialization into an |
| 1558 // assignment statement. We use a block to collect multiple assignments. | 1558 // assignment statement. We use a block to collect multiple assignments. |
| 1559 // | 1559 // |
| 1560 // We mark the block as initializer block because we don't want the | 1560 // We mark the block as initializer block because we don't want the |
| 1561 // rewriter to add a '.result' assignment to such a block (to get compliant | 1561 // rewriter to add a '.result' assignment to such a block (to get compliant |
| 1562 // behavior for code such as print(eval('var x = 7')), and for cosmetic | 1562 // behavior for code such as print(eval('var x = 7')), and for cosmetic |
| 1563 // reasons when pretty-printing. Also, unless an assignment (initialization) | 1563 // reasons when pretty-printing. Also, unless an assignment (initialization) |
| 1564 // is inside an initializer block, it is ignored. | 1564 // is inside an initializer block, it is ignored. |
| 1565 // | 1565 // |
| 1566 // Create new block with one expected declaration. | 1566 // Create new block with one expected declaration. |
| 1567 Block* block = new(zone()) Block(NULL, 1, true); | 1567 Block* block = new(zone()) Block(isolate(), NULL, 1, true); |
| 1568 int nvars = 0; // the number of variables declared | 1568 int nvars = 0; // the number of variables declared |
| 1569 Handle<String> name; | 1569 Handle<String> name; |
| 1570 do { | 1570 do { |
| 1571 if (fni_ != NULL) fni_->Enter(); | 1571 if (fni_ != NULL) fni_->Enter(); |
| 1572 | 1572 |
| 1573 // Parse variable name. | 1573 // Parse variable name. |
| 1574 if (nvars > 0) Consume(Token::COMMA); | 1574 if (nvars > 0) Consume(Token::COMMA); |
| 1575 name = ParseIdentifier(CHECK_OK); | 1575 name = ParseIdentifier(CHECK_OK); |
| 1576 if (fni_ != NULL) fni_->PushVariableName(name); | 1576 if (fni_ != NULL) fni_->PushVariableName(name); |
| 1577 | 1577 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 // prototype. This way, global variable declarations can shadow | 1669 // prototype. This way, global variable declarations can shadow |
| 1670 // properties in the prototype chain, but only after the variable | 1670 // properties in the prototype chain, but only after the variable |
| 1671 // declaration statement has been executed. This is important in | 1671 // declaration statement has been executed. This is important in |
| 1672 // browsers where the global object (window) has lots of | 1672 // browsers where the global object (window) has lots of |
| 1673 // properties defined in prototype objects. | 1673 // properties defined in prototype objects. |
| 1674 | 1674 |
| 1675 if (initialization_scope->is_global_scope()) { | 1675 if (initialization_scope->is_global_scope()) { |
| 1676 // Compute the arguments for the runtime call. | 1676 // Compute the arguments for the runtime call. |
| 1677 ZoneList<Expression*>* arguments = new(zone()) ZoneList<Expression*>(3); | 1677 ZoneList<Expression*>* arguments = new(zone()) ZoneList<Expression*>(3); |
| 1678 // We have at least 1 parameter. | 1678 // We have at least 1 parameter. |
| 1679 arguments->Add(new(zone()) Literal(name)); | 1679 arguments->Add(NewLiteral(name)); |
| 1680 CallRuntime* initialize; | 1680 CallRuntime* initialize; |
| 1681 | 1681 |
| 1682 if (is_const) { | 1682 if (is_const) { |
| 1683 arguments->Add(value); | 1683 arguments->Add(value); |
| 1684 value = NULL; // zap the value to avoid the unnecessary assignment | 1684 value = NULL; // zap the value to avoid the unnecessary assignment |
| 1685 | 1685 |
| 1686 // Construct the call to Runtime_InitializeConstGlobal | 1686 // Construct the call to Runtime_InitializeConstGlobal |
| 1687 // and add it to the initialization statement block. | 1687 // and add it to the initialization statement block. |
| 1688 // Note that the function does different things depending on | 1688 // Note that the function does different things depending on |
| 1689 // the number of arguments (1 or 2). | 1689 // the number of arguments (1 or 2). |
| 1690 initialize = | 1690 initialize = |
| 1691 new(zone()) CallRuntime( | 1691 new(zone()) CallRuntime( |
| 1692 isolate()->factory()->InitializeConstGlobal_symbol(), | 1692 isolate(), |
| 1693 Runtime::FunctionForId(Runtime::kInitializeConstGlobal), | 1693 isolate()->factory()->InitializeConstGlobal_symbol(), |
| 1694 arguments); | 1694 Runtime::FunctionForId(Runtime::kInitializeConstGlobal), |
| 1695 arguments); |
| 1695 } else { | 1696 } else { |
| 1696 // Add strict mode. | 1697 // Add strict mode. |
| 1697 // We may want to pass singleton to avoid Literal allocations. | 1698 // We may want to pass singleton to avoid Literal allocations. |
| 1698 StrictModeFlag flag = initialization_scope->is_strict_mode() | 1699 StrictModeFlag flag = initialization_scope->is_strict_mode() |
| 1699 ? kStrictMode | 1700 ? kStrictMode |
| 1700 : kNonStrictMode; | 1701 : kNonStrictMode; |
| 1701 arguments->Add(NewNumberLiteral(flag)); | 1702 arguments->Add(NewNumberLiteral(flag)); |
| 1702 | 1703 |
| 1703 // Be careful not to assign a value to the global variable if | 1704 // Be careful not to assign a value to the global variable if |
| 1704 // we're in a with. The initialization value should not | 1705 // we're in a with. The initialization value should not |
| 1705 // necessarily be stored in the global object in that case, | 1706 // necessarily be stored in the global object in that case, |
| 1706 // which is why we need to generate a separate assignment node. | 1707 // which is why we need to generate a separate assignment node. |
| 1707 if (value != NULL && !inside_with()) { | 1708 if (value != NULL && !inside_with()) { |
| 1708 arguments->Add(value); | 1709 arguments->Add(value); |
| 1709 value = NULL; // zap the value to avoid the unnecessary assignment | 1710 value = NULL; // zap the value to avoid the unnecessary assignment |
| 1710 } | 1711 } |
| 1711 | 1712 |
| 1712 // Construct the call to Runtime_InitializeVarGlobal | 1713 // Construct the call to Runtime_InitializeVarGlobal |
| 1713 // and add it to the initialization statement block. | 1714 // and add it to the initialization statement block. |
| 1714 // Note that the function does different things depending on | 1715 // Note that the function does different things depending on |
| 1715 // the number of arguments (2 or 3). | 1716 // the number of arguments (2 or 3). |
| 1716 initialize = | 1717 initialize = |
| 1717 new(zone()) CallRuntime( | 1718 new(zone()) CallRuntime( |
| 1718 isolate()->factory()->InitializeVarGlobal_symbol(), | 1719 isolate(), |
| 1719 Runtime::FunctionForId(Runtime::kInitializeVarGlobal), | 1720 isolate()->factory()->InitializeVarGlobal_symbol(), |
| 1720 arguments); | 1721 Runtime::FunctionForId(Runtime::kInitializeVarGlobal), |
| 1722 arguments); |
| 1721 } | 1723 } |
| 1722 | 1724 |
| 1723 block->AddStatement(new(zone()) ExpressionStatement(initialize)); | 1725 block->AddStatement(new(zone()) ExpressionStatement(initialize)); |
| 1724 } | 1726 } |
| 1725 | 1727 |
| 1726 // Add an assignment node to the initialization statement block if | 1728 // Add an assignment node to the initialization statement block if |
| 1727 // we still have a pending initialization value. We must distinguish | 1729 // we still have a pending initialization value. We must distinguish |
| 1728 // between variables and constants: Variable initializations are simply | 1730 // between variables and constants: Variable initializations are simply |
| 1729 // assignments (with all the consequences if they are inside a 'with' | 1731 // assignments (with all the consequences if they are inside a 'with' |
| 1730 // statement - they may change a 'with' object property). Constant | 1732 // statement - they may change a 'with' object property). Constant |
| 1731 // initializations always assign to the declared constant which is | 1733 // initializations always assign to the declared constant which is |
| 1732 // always at the function scope level. This is only relevant for | 1734 // always at the function scope level. This is only relevant for |
| 1733 // dynamically looked-up variables and constants (the start context | 1735 // dynamically looked-up variables and constants (the start context |
| 1734 // for constant lookups is always the function context, while it is | 1736 // for constant lookups is always the function context, while it is |
| 1735 // the top context for variables). Sigh... | 1737 // the top context for variables). Sigh... |
| 1736 if (value != NULL) { | 1738 if (value != NULL) { |
| 1737 Token::Value op = (is_const ? Token::INIT_CONST : Token::INIT_VAR); | 1739 Token::Value op = (is_const ? Token::INIT_CONST : Token::INIT_VAR); |
| 1738 bool in_with = is_const ? false : inside_with(); | 1740 bool in_with = is_const ? false : inside_with(); |
| 1739 VariableProxy* proxy = | 1741 VariableProxy* proxy = |
| 1740 initialization_scope->NewUnresolved(name, in_with); | 1742 initialization_scope->NewUnresolved(name, in_with); |
| 1741 Assignment* assignment = | 1743 Assignment* assignment = |
| 1742 new(zone()) Assignment(op, proxy, value, position); | 1744 new(zone()) Assignment(isolate(), op, proxy, value, position); |
| 1743 if (block) { | 1745 if (block) { |
| 1744 block->AddStatement(new(zone()) ExpressionStatement(assignment)); | 1746 block->AddStatement(new(zone()) ExpressionStatement(assignment)); |
| 1745 } | 1747 } |
| 1746 } | 1748 } |
| 1747 | 1749 |
| 1748 if (fni_ != NULL) fni_->Leave(); | 1750 if (fni_ != NULL) fni_->Leave(); |
| 1749 } while (peek() == Token::COMMA); | 1751 } while (peek() == Token::COMMA); |
| 1750 | 1752 |
| 1751 // If there was a single non-const declaration, return it in the output | 1753 // If there was a single non-const declaration, return it in the output |
| 1752 // parameter for possible use by for/in. | 1754 // parameter for possible use by for/in. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1835 Expression* condition = ParseExpression(true, CHECK_OK); | 1837 Expression* condition = ParseExpression(true, CHECK_OK); |
| 1836 Expect(Token::RPAREN, CHECK_OK); | 1838 Expect(Token::RPAREN, CHECK_OK); |
| 1837 Statement* then_statement = ParseStatement(labels, CHECK_OK); | 1839 Statement* then_statement = ParseStatement(labels, CHECK_OK); |
| 1838 Statement* else_statement = NULL; | 1840 Statement* else_statement = NULL; |
| 1839 if (peek() == Token::ELSE) { | 1841 if (peek() == Token::ELSE) { |
| 1840 Next(); | 1842 Next(); |
| 1841 else_statement = ParseStatement(labels, CHECK_OK); | 1843 else_statement = ParseStatement(labels, CHECK_OK); |
| 1842 } else { | 1844 } else { |
| 1843 else_statement = EmptyStatement(); | 1845 else_statement = EmptyStatement(); |
| 1844 } | 1846 } |
| 1845 return new(zone()) IfStatement(condition, then_statement, else_statement); | 1847 return new(zone()) IfStatement( |
| 1848 isolate(), condition, then_statement, else_statement); |
| 1846 } | 1849 } |
| 1847 | 1850 |
| 1848 | 1851 |
| 1849 Statement* Parser::ParseContinueStatement(bool* ok) { | 1852 Statement* Parser::ParseContinueStatement(bool* ok) { |
| 1850 // ContinueStatement :: | 1853 // ContinueStatement :: |
| 1851 // 'continue' Identifier? ';' | 1854 // 'continue' Identifier? ';' |
| 1852 | 1855 |
| 1853 Expect(Token::CONTINUE, CHECK_OK); | 1856 Expect(Token::CONTINUE, CHECK_OK); |
| 1854 Handle<String> label = Handle<String>::null(); | 1857 Handle<String> label = Handle<String>::null(); |
| 1855 Token::Value tok = peek(); | 1858 Token::Value tok = peek(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 Statement* stat; | 1957 Statement* stat; |
| 1955 { Target target(&this->target_stack_, &collector); | 1958 { Target target(&this->target_stack_, &collector); |
| 1956 with_nesting_level_++; | 1959 with_nesting_level_++; |
| 1957 top_scope_->DeclarationScope()->RecordWithStatement(); | 1960 top_scope_->DeclarationScope()->RecordWithStatement(); |
| 1958 stat = ParseStatement(labels, CHECK_OK); | 1961 stat = ParseStatement(labels, CHECK_OK); |
| 1959 with_nesting_level_--; | 1962 with_nesting_level_--; |
| 1960 } | 1963 } |
| 1961 // Create resulting block with two statements. | 1964 // Create resulting block with two statements. |
| 1962 // 1: Evaluate the with expression. | 1965 // 1: Evaluate the with expression. |
| 1963 // 2: The try-finally block evaluating the body. | 1966 // 2: The try-finally block evaluating the body. |
| 1964 Block* result = new(zone()) Block(NULL, 2, false); | 1967 Block* result = new(zone()) Block(isolate(), NULL, 2, false); |
| 1965 | 1968 |
| 1966 if (result != NULL) { | 1969 if (result != NULL) { |
| 1967 result->AddStatement(new(zone()) EnterWithContextStatement(obj)); | 1970 result->AddStatement(new(zone()) EnterWithContextStatement(obj)); |
| 1968 | 1971 |
| 1969 // Create body block. | 1972 // Create body block. |
| 1970 Block* body = new(zone()) Block(NULL, 1, false); | 1973 Block* body = new(zone()) Block(isolate(), NULL, 1, false); |
| 1971 body->AddStatement(stat); | 1974 body->AddStatement(stat); |
| 1972 | 1975 |
| 1973 // Create exit block. | 1976 // Create exit block. |
| 1974 Block* exit = new(zone()) Block(NULL, 1, false); | 1977 Block* exit = new(zone()) Block(isolate(), NULL, 1, false); |
| 1975 exit->AddStatement(new(zone()) ExitContextStatement()); | 1978 exit->AddStatement(new(zone()) ExitContextStatement()); |
| 1976 | 1979 |
| 1977 // Return a try-finally statement. | 1980 // Return a try-finally statement. |
| 1978 TryFinallyStatement* wrapper = new(zone()) TryFinallyStatement(body, exit); | 1981 TryFinallyStatement* wrapper = new(zone()) TryFinallyStatement(body, exit); |
| 1979 wrapper->set_escaping_targets(collector.targets()); | 1982 wrapper->set_escaping_targets(collector.targets()); |
| 1980 result->AddStatement(wrapper); | 1983 result->AddStatement(wrapper); |
| 1981 } | 1984 } |
| 1982 return result; | 1985 return result; |
| 1983 } | 1986 } |
| 1984 | 1987 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 Expect(Token::COLON, CHECK_OK); | 2028 Expect(Token::COLON, CHECK_OK); |
| 2026 int pos = scanner().location().beg_pos; | 2029 int pos = scanner().location().beg_pos; |
| 2027 ZoneList<Statement*>* statements = new(zone()) ZoneList<Statement*>(5); | 2030 ZoneList<Statement*>* statements = new(zone()) ZoneList<Statement*>(5); |
| 2028 while (peek() != Token::CASE && | 2031 while (peek() != Token::CASE && |
| 2029 peek() != Token::DEFAULT && | 2032 peek() != Token::DEFAULT && |
| 2030 peek() != Token::RBRACE) { | 2033 peek() != Token::RBRACE) { |
| 2031 Statement* stat = ParseStatement(NULL, CHECK_OK); | 2034 Statement* stat = ParseStatement(NULL, CHECK_OK); |
| 2032 statements->Add(stat); | 2035 statements->Add(stat); |
| 2033 } | 2036 } |
| 2034 | 2037 |
| 2035 return new(zone()) CaseClause(label, statements, pos); | 2038 return new(zone()) CaseClause(isolate(), label, statements, pos); |
| 2036 } | 2039 } |
| 2037 | 2040 |
| 2038 | 2041 |
| 2039 SwitchStatement* Parser::ParseSwitchStatement(ZoneStringList* labels, | 2042 SwitchStatement* Parser::ParseSwitchStatement(ZoneStringList* labels, |
| 2040 bool* ok) { | 2043 bool* ok) { |
| 2041 // SwitchStatement :: | 2044 // SwitchStatement :: |
| 2042 // 'switch' '(' Expression ')' '{' CaseClause* '}' | 2045 // 'switch' '(' Expression ')' '{' CaseClause* '}' |
| 2043 | 2046 |
| 2044 SwitchStatement* statement = new(zone()) SwitchStatement(labels); | 2047 SwitchStatement* statement = new(zone()) SwitchStatement(isolate(), labels); |
| 2045 Target target(&this->target_stack_, statement); | 2048 Target target(&this->target_stack_, statement); |
| 2046 | 2049 |
| 2047 Expect(Token::SWITCH, CHECK_OK); | 2050 Expect(Token::SWITCH, CHECK_OK); |
| 2048 Expect(Token::LPAREN, CHECK_OK); | 2051 Expect(Token::LPAREN, CHECK_OK); |
| 2049 Expression* tag = ParseExpression(true, CHECK_OK); | 2052 Expression* tag = ParseExpression(true, CHECK_OK); |
| 2050 Expect(Token::RPAREN, CHECK_OK); | 2053 Expect(Token::RPAREN, CHECK_OK); |
| 2051 | 2054 |
| 2052 bool default_seen = false; | 2055 bool default_seen = false; |
| 2053 ZoneList<CaseClause*>* cases = new(zone()) ZoneList<CaseClause*>(4); | 2056 ZoneList<CaseClause*>* cases = new(zone()) ZoneList<CaseClause*>(4); |
| 2054 Expect(Token::LBRACE, CHECK_OK); | 2057 Expect(Token::LBRACE, CHECK_OK); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2070 Expect(Token::THROW, CHECK_OK); | 2073 Expect(Token::THROW, CHECK_OK); |
| 2071 int pos = scanner().location().beg_pos; | 2074 int pos = scanner().location().beg_pos; |
| 2072 if (scanner().HasAnyLineTerminatorBeforeNext()) { | 2075 if (scanner().HasAnyLineTerminatorBeforeNext()) { |
| 2073 ReportMessage("newline_after_throw", Vector<const char*>::empty()); | 2076 ReportMessage("newline_after_throw", Vector<const char*>::empty()); |
| 2074 *ok = false; | 2077 *ok = false; |
| 2075 return NULL; | 2078 return NULL; |
| 2076 } | 2079 } |
| 2077 Expression* exception = ParseExpression(true, CHECK_OK); | 2080 Expression* exception = ParseExpression(true, CHECK_OK); |
| 2078 ExpectSemicolon(CHECK_OK); | 2081 ExpectSemicolon(CHECK_OK); |
| 2079 | 2082 |
| 2080 return new(zone()) ExpressionStatement(new(zone()) Throw(exception, pos)); | 2083 return new(zone()) ExpressionStatement( |
| 2084 new(zone()) Throw(isolate(), exception, pos)); |
| 2081 } | 2085 } |
| 2082 | 2086 |
| 2083 | 2087 |
| 2084 TryStatement* Parser::ParseTryStatement(bool* ok) { | 2088 TryStatement* Parser::ParseTryStatement(bool* ok) { |
| 2085 // TryStatement :: | 2089 // TryStatement :: |
| 2086 // 'try' Block Catch | 2090 // 'try' Block Catch |
| 2087 // 'try' Block Finally | 2091 // 'try' Block Finally |
| 2088 // 'try' Block Catch Finally | 2092 // 'try' Block Catch Finally |
| 2089 // | 2093 // |
| 2090 // Catch :: | 2094 // Catch :: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 catch_variable = catch_scope->DeclareLocal(name, Variable::VAR); | 2153 catch_variable = catch_scope->DeclareLocal(name, Variable::VAR); |
| 2150 | 2154 |
| 2151 Scope* saved_scope = top_scope_; | 2155 Scope* saved_scope = top_scope_; |
| 2152 top_scope_ = catch_scope; | 2156 top_scope_ = catch_scope; |
| 2153 inner_body = ParseBlock(NULL, CHECK_OK); | 2157 inner_body = ParseBlock(NULL, CHECK_OK); |
| 2154 top_scope_ = saved_scope; | 2158 top_scope_ = saved_scope; |
| 2155 } | 2159 } |
| 2156 } | 2160 } |
| 2157 | 2161 |
| 2158 // Create exit block. | 2162 // Create exit block. |
| 2159 Block* inner_finally = new(zone()) Block(NULL, 1, false); | 2163 Block* inner_finally = new(zone()) Block(isolate(), NULL, 1, false); |
| 2160 inner_finally->AddStatement(new(zone()) ExitContextStatement()); | 2164 inner_finally->AddStatement(new(zone()) ExitContextStatement()); |
| 2161 | 2165 |
| 2162 // Create a try/finally statement. | 2166 // Create a try/finally statement. |
| 2163 TryFinallyStatement* inner_try_finally = | 2167 TryFinallyStatement* inner_try_finally = |
| 2164 new(zone()) TryFinallyStatement(inner_body, inner_finally); | 2168 new(zone()) TryFinallyStatement(inner_body, inner_finally); |
| 2165 inner_try_finally->set_escaping_targets(inner_collector.targets()); | 2169 inner_try_finally->set_escaping_targets(inner_collector.targets()); |
| 2166 | 2170 |
| 2167 catch_block = new(zone()) Block(NULL, 1, false); | 2171 catch_block = new(zone()) Block(isolate(), NULL, 1, false); |
| 2168 catch_block->AddStatement(inner_try_finally); | 2172 catch_block->AddStatement(inner_try_finally); |
| 2169 } else { | 2173 } else { |
| 2170 Expect(Token::LBRACE, CHECK_OK); | 2174 Expect(Token::LBRACE, CHECK_OK); |
| 2171 } | 2175 } |
| 2172 | 2176 |
| 2173 tok = peek(); | 2177 tok = peek(); |
| 2174 } | 2178 } |
| 2175 | 2179 |
| 2176 Block* finally_block = NULL; | 2180 Block* finally_block = NULL; |
| 2177 if (tok == Token::FINALLY || catch_block == NULL) { | 2181 if (tok == Token::FINALLY || catch_block == NULL) { |
| 2178 Consume(Token::FINALLY); | 2182 Consume(Token::FINALLY); |
| 2179 finally_block = ParseBlock(NULL, CHECK_OK); | 2183 finally_block = ParseBlock(NULL, CHECK_OK); |
| 2180 } | 2184 } |
| 2181 | 2185 |
| 2182 // Simplify the AST nodes by converting: | 2186 // Simplify the AST nodes by converting: |
| 2183 // 'try B0 catch B1 finally B2' | 2187 // 'try B0 catch B1 finally B2' |
| 2184 // to: | 2188 // to: |
| 2185 // 'try { try B0 catch B1 } finally B2' | 2189 // 'try { try B0 catch B1 } finally B2' |
| 2186 | 2190 |
| 2187 if (catch_block != NULL && finally_block != NULL) { | 2191 if (catch_block != NULL && finally_block != NULL) { |
| 2188 // If we have both, create an inner try/catch. | 2192 // If we have both, create an inner try/catch. |
| 2189 ASSERT(catch_scope != NULL && catch_variable != NULL); | 2193 ASSERT(catch_scope != NULL && catch_variable != NULL); |
| 2190 TryCatchStatement* statement = | 2194 TryCatchStatement* statement = |
| 2191 new(zone()) TryCatchStatement(try_block, | 2195 new(zone()) TryCatchStatement(try_block, |
| 2192 catch_scope, | 2196 catch_scope, |
| 2193 catch_variable, | 2197 catch_variable, |
| 2194 catch_block); | 2198 catch_block); |
| 2195 statement->set_escaping_targets(try_collector.targets()); | 2199 statement->set_escaping_targets(try_collector.targets()); |
| 2196 try_block = new(zone()) Block(NULL, 1, false); | 2200 try_block = new(zone()) Block(isolate(), NULL, 1, false); |
| 2197 try_block->AddStatement(statement); | 2201 try_block->AddStatement(statement); |
| 2198 catch_block = NULL; // Clear to indicate it's been handled. | 2202 catch_block = NULL; // Clear to indicate it's been handled. |
| 2199 } | 2203 } |
| 2200 | 2204 |
| 2201 TryStatement* result = NULL; | 2205 TryStatement* result = NULL; |
| 2202 if (catch_block != NULL) { | 2206 if (catch_block != NULL) { |
| 2203 ASSERT(finally_block == NULL); | 2207 ASSERT(finally_block == NULL); |
| 2204 ASSERT(catch_scope != NULL && catch_variable != NULL); | 2208 ASSERT(catch_scope != NULL && catch_variable != NULL); |
| 2205 result = | 2209 result = |
| 2206 new(zone()) TryCatchStatement(try_block, | 2210 new(zone()) TryCatchStatement(try_block, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2217 result->set_escaping_targets(try_collector.targets()); | 2221 result->set_escaping_targets(try_collector.targets()); |
| 2218 return result; | 2222 return result; |
| 2219 } | 2223 } |
| 2220 | 2224 |
| 2221 | 2225 |
| 2222 DoWhileStatement* Parser::ParseDoWhileStatement(ZoneStringList* labels, | 2226 DoWhileStatement* Parser::ParseDoWhileStatement(ZoneStringList* labels, |
| 2223 bool* ok) { | 2227 bool* ok) { |
| 2224 // DoStatement :: | 2228 // DoStatement :: |
| 2225 // 'do' Statement 'while' '(' Expression ')' ';' | 2229 // 'do' Statement 'while' '(' Expression ')' ';' |
| 2226 | 2230 |
| 2227 DoWhileStatement* loop = new(zone()) DoWhileStatement(labels); | 2231 DoWhileStatement* loop = new(zone()) DoWhileStatement(isolate(), labels); |
| 2228 Target target(&this->target_stack_, loop); | 2232 Target target(&this->target_stack_, loop); |
| 2229 | 2233 |
| 2230 Expect(Token::DO, CHECK_OK); | 2234 Expect(Token::DO, CHECK_OK); |
| 2231 Statement* body = ParseStatement(NULL, CHECK_OK); | 2235 Statement* body = ParseStatement(NULL, CHECK_OK); |
| 2232 Expect(Token::WHILE, CHECK_OK); | 2236 Expect(Token::WHILE, CHECK_OK); |
| 2233 Expect(Token::LPAREN, CHECK_OK); | 2237 Expect(Token::LPAREN, CHECK_OK); |
| 2234 | 2238 |
| 2235 if (loop != NULL) { | 2239 if (loop != NULL) { |
| 2236 int position = scanner().location().beg_pos; | 2240 int position = scanner().location().beg_pos; |
| 2237 loop->set_condition_position(position); | 2241 loop->set_condition_position(position); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2248 | 2252 |
| 2249 if (loop != NULL) loop->Initialize(cond, body); | 2253 if (loop != NULL) loop->Initialize(cond, body); |
| 2250 return loop; | 2254 return loop; |
| 2251 } | 2255 } |
| 2252 | 2256 |
| 2253 | 2257 |
| 2254 WhileStatement* Parser::ParseWhileStatement(ZoneStringList* labels, bool* ok) { | 2258 WhileStatement* Parser::ParseWhileStatement(ZoneStringList* labels, bool* ok) { |
| 2255 // WhileStatement :: | 2259 // WhileStatement :: |
| 2256 // 'while' '(' Expression ')' Statement | 2260 // 'while' '(' Expression ')' Statement |
| 2257 | 2261 |
| 2258 WhileStatement* loop = new(zone()) WhileStatement(labels); | 2262 WhileStatement* loop = new(zone()) WhileStatement(isolate(), labels); |
| 2259 Target target(&this->target_stack_, loop); | 2263 Target target(&this->target_stack_, loop); |
| 2260 | 2264 |
| 2261 Expect(Token::WHILE, CHECK_OK); | 2265 Expect(Token::WHILE, CHECK_OK); |
| 2262 Expect(Token::LPAREN, CHECK_OK); | 2266 Expect(Token::LPAREN, CHECK_OK); |
| 2263 Expression* cond = ParseExpression(true, CHECK_OK); | 2267 Expression* cond = ParseExpression(true, CHECK_OK); |
| 2264 Expect(Token::RPAREN, CHECK_OK); | 2268 Expect(Token::RPAREN, CHECK_OK); |
| 2265 Statement* body = ParseStatement(NULL, CHECK_OK); | 2269 Statement* body = ParseStatement(NULL, CHECK_OK); |
| 2266 | 2270 |
| 2267 if (loop != NULL) loop->Initialize(cond, body); | 2271 if (loop != NULL) loop->Initialize(cond, body); |
| 2268 return loop; | 2272 return loop; |
| 2269 } | 2273 } |
| 2270 | 2274 |
| 2271 | 2275 |
| 2272 Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { | 2276 Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
| 2273 // ForStatement :: | 2277 // ForStatement :: |
| 2274 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement | 2278 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement |
| 2275 | 2279 |
| 2276 Statement* init = NULL; | 2280 Statement* init = NULL; |
| 2277 | 2281 |
| 2278 Expect(Token::FOR, CHECK_OK); | 2282 Expect(Token::FOR, CHECK_OK); |
| 2279 Expect(Token::LPAREN, CHECK_OK); | 2283 Expect(Token::LPAREN, CHECK_OK); |
| 2280 if (peek() != Token::SEMICOLON) { | 2284 if (peek() != Token::SEMICOLON) { |
| 2281 if (peek() == Token::VAR || peek() == Token::CONST) { | 2285 if (peek() == Token::VAR || peek() == Token::CONST) { |
| 2282 Handle<String> name; | 2286 Handle<String> name; |
| 2283 Block* variable_statement = | 2287 Block* variable_statement = |
| 2284 ParseVariableDeclarations(false, &name, CHECK_OK); | 2288 ParseVariableDeclarations(false, &name, CHECK_OK); |
| 2285 | 2289 |
| 2286 if (peek() == Token::IN && !name.is_null()) { | 2290 if (peek() == Token::IN && !name.is_null()) { |
| 2287 VariableProxy* each = top_scope_->NewUnresolved(name, inside_with()); | 2291 VariableProxy* each = top_scope_->NewUnresolved(name, inside_with()); |
| 2288 ForInStatement* loop = new(zone()) ForInStatement(labels); | 2292 ForInStatement* loop = new(zone()) ForInStatement(isolate(), labels); |
| 2289 Target target(&this->target_stack_, loop); | 2293 Target target(&this->target_stack_, loop); |
| 2290 | 2294 |
| 2291 Expect(Token::IN, CHECK_OK); | 2295 Expect(Token::IN, CHECK_OK); |
| 2292 Expression* enumerable = ParseExpression(true, CHECK_OK); | 2296 Expression* enumerable = ParseExpression(true, CHECK_OK); |
| 2293 Expect(Token::RPAREN, CHECK_OK); | 2297 Expect(Token::RPAREN, CHECK_OK); |
| 2294 | 2298 |
| 2295 Statement* body = ParseStatement(NULL, CHECK_OK); | 2299 Statement* body = ParseStatement(NULL, CHECK_OK); |
| 2296 loop->Initialize(each, enumerable, body); | 2300 loop->Initialize(each, enumerable, body); |
| 2297 Block* result = new(zone()) Block(NULL, 2, false); | 2301 Block* result = new(zone()) Block(isolate(), NULL, 2, false); |
| 2298 result->AddStatement(variable_statement); | 2302 result->AddStatement(variable_statement); |
| 2299 result->AddStatement(loop); | 2303 result->AddStatement(loop); |
| 2300 // Parsed for-in loop w/ variable/const declaration. | 2304 // Parsed for-in loop w/ variable/const declaration. |
| 2301 return result; | 2305 return result; |
| 2302 } else { | 2306 } else { |
| 2303 init = variable_statement; | 2307 init = variable_statement; |
| 2304 } | 2308 } |
| 2305 | 2309 |
| 2306 } else { | 2310 } else { |
| 2307 Expression* expression = ParseExpression(false, CHECK_OK); | 2311 Expression* expression = ParseExpression(false, CHECK_OK); |
| 2308 if (peek() == Token::IN) { | 2312 if (peek() == Token::IN) { |
| 2309 // Signal a reference error if the expression is an invalid | 2313 // Signal a reference error if the expression is an invalid |
| 2310 // left-hand side expression. We could report this as a syntax | 2314 // left-hand side expression. We could report this as a syntax |
| 2311 // error here but for compatibility with JSC we choose to report | 2315 // error here but for compatibility with JSC we choose to report |
| 2312 // the error at runtime. | 2316 // the error at runtime. |
| 2313 if (expression == NULL || !expression->IsValidLeftHandSide()) { | 2317 if (expression == NULL || !expression->IsValidLeftHandSide()) { |
| 2314 Handle<String> type = | 2318 Handle<String> type = |
| 2315 isolate()->factory()->invalid_lhs_in_for_in_symbol(); | 2319 isolate()->factory()->invalid_lhs_in_for_in_symbol(); |
| 2316 expression = NewThrowReferenceError(type); | 2320 expression = NewThrowReferenceError(type); |
| 2317 } | 2321 } |
| 2318 ForInStatement* loop = new(zone()) ForInStatement(labels); | 2322 ForInStatement* loop = new(zone()) ForInStatement(isolate(), labels); |
| 2319 Target target(&this->target_stack_, loop); | 2323 Target target(&this->target_stack_, loop); |
| 2320 | 2324 |
| 2321 Expect(Token::IN, CHECK_OK); | 2325 Expect(Token::IN, CHECK_OK); |
| 2322 Expression* enumerable = ParseExpression(true, CHECK_OK); | 2326 Expression* enumerable = ParseExpression(true, CHECK_OK); |
| 2323 Expect(Token::RPAREN, CHECK_OK); | 2327 Expect(Token::RPAREN, CHECK_OK); |
| 2324 | 2328 |
| 2325 Statement* body = ParseStatement(NULL, CHECK_OK); | 2329 Statement* body = ParseStatement(NULL, CHECK_OK); |
| 2326 if (loop) loop->Initialize(expression, enumerable, body); | 2330 if (loop) loop->Initialize(expression, enumerable, body); |
| 2327 // Parsed for-in loop. | 2331 // Parsed for-in loop. |
| 2328 return loop; | 2332 return loop; |
| 2329 | 2333 |
| 2330 } else { | 2334 } else { |
| 2331 init = new(zone()) ExpressionStatement(expression); | 2335 init = new(zone()) ExpressionStatement(expression); |
| 2332 } | 2336 } |
| 2333 } | 2337 } |
| 2334 } | 2338 } |
| 2335 | 2339 |
| 2336 // Standard 'for' loop | 2340 // Standard 'for' loop |
| 2337 ForStatement* loop = new(zone()) ForStatement(labels); | 2341 ForStatement* loop = new(zone()) ForStatement(isolate(), labels); |
| 2338 Target target(&this->target_stack_, loop); | 2342 Target target(&this->target_stack_, loop); |
| 2339 | 2343 |
| 2340 // Parsed initializer at this point. | 2344 // Parsed initializer at this point. |
| 2341 Expect(Token::SEMICOLON, CHECK_OK); | 2345 Expect(Token::SEMICOLON, CHECK_OK); |
| 2342 | 2346 |
| 2343 Expression* cond = NULL; | 2347 Expression* cond = NULL; |
| 2344 if (peek() != Token::SEMICOLON) { | 2348 if (peek() != Token::SEMICOLON) { |
| 2345 cond = ParseExpression(true, CHECK_OK); | 2349 cond = ParseExpression(true, CHECK_OK); |
| 2346 } | 2350 } |
| 2347 Expect(Token::SEMICOLON, CHECK_OK); | 2351 Expect(Token::SEMICOLON, CHECK_OK); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2363 Expression* Parser::ParseExpression(bool accept_IN, bool* ok) { | 2367 Expression* Parser::ParseExpression(bool accept_IN, bool* ok) { |
| 2364 // Expression :: | 2368 // Expression :: |
| 2365 // AssignmentExpression | 2369 // AssignmentExpression |
| 2366 // Expression ',' AssignmentExpression | 2370 // Expression ',' AssignmentExpression |
| 2367 | 2371 |
| 2368 Expression* result = ParseAssignmentExpression(accept_IN, CHECK_OK); | 2372 Expression* result = ParseAssignmentExpression(accept_IN, CHECK_OK); |
| 2369 while (peek() == Token::COMMA) { | 2373 while (peek() == Token::COMMA) { |
| 2370 Expect(Token::COMMA, CHECK_OK); | 2374 Expect(Token::COMMA, CHECK_OK); |
| 2371 int position = scanner().location().beg_pos; | 2375 int position = scanner().location().beg_pos; |
| 2372 Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK); | 2376 Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK); |
| 2373 result = new(zone()) BinaryOperation(Token::COMMA, result, right, position); | 2377 result = new(zone()) BinaryOperation( |
| 2378 isolate(), Token::COMMA, result, right, position); |
| 2374 } | 2379 } |
| 2375 return result; | 2380 return result; |
| 2376 } | 2381 } |
| 2377 | 2382 |
| 2378 | 2383 |
| 2379 // Precedence = 2 | 2384 // Precedence = 2 |
| 2380 Expression* Parser::ParseAssignmentExpression(bool accept_IN, bool* ok) { | 2385 Expression* Parser::ParseAssignmentExpression(bool accept_IN, bool* ok) { |
| 2381 // AssignmentExpression :: | 2386 // AssignmentExpression :: |
| 2382 // ConditionalExpression | 2387 // ConditionalExpression |
| 2383 // LeftHandSideExpression AssignmentOperator AssignmentExpression | 2388 // LeftHandSideExpression AssignmentOperator AssignmentExpression |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2435 // expression. | 2440 // expression. |
| 2436 if ((op == Token::INIT_VAR | 2441 if ((op == Token::INIT_VAR |
| 2437 || op == Token::INIT_CONST | 2442 || op == Token::INIT_CONST |
| 2438 || op == Token::ASSIGN) | 2443 || op == Token::ASSIGN) |
| 2439 && (right->AsCall() == NULL && right->AsCallNew() == NULL)) { | 2444 && (right->AsCall() == NULL && right->AsCallNew() == NULL)) { |
| 2440 fni_->Infer(); | 2445 fni_->Infer(); |
| 2441 } | 2446 } |
| 2442 fni_->Leave(); | 2447 fni_->Leave(); |
| 2443 } | 2448 } |
| 2444 | 2449 |
| 2445 return new(zone()) Assignment(op, expression, right, pos); | 2450 return new(zone()) Assignment(isolate(), op, expression, right, pos); |
| 2446 } | 2451 } |
| 2447 | 2452 |
| 2448 | 2453 |
| 2449 // Precedence = 3 | 2454 // Precedence = 3 |
| 2450 Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) { | 2455 Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) { |
| 2451 // ConditionalExpression :: | 2456 // ConditionalExpression :: |
| 2452 // LogicalOrExpression | 2457 // LogicalOrExpression |
| 2453 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression | 2458 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression |
| 2454 | 2459 |
| 2455 // We start using the binary expression parser for prec >= 4 only! | 2460 // We start using the binary expression parser for prec >= 4 only! |
| 2456 Expression* expression = ParseBinaryExpression(4, accept_IN, CHECK_OK); | 2461 Expression* expression = ParseBinaryExpression(4, accept_IN, CHECK_OK); |
| 2457 if (peek() != Token::CONDITIONAL) return expression; | 2462 if (peek() != Token::CONDITIONAL) return expression; |
| 2458 Consume(Token::CONDITIONAL); | 2463 Consume(Token::CONDITIONAL); |
| 2459 // In parsing the first assignment expression in conditional | 2464 // In parsing the first assignment expression in conditional |
| 2460 // expressions we always accept the 'in' keyword; see ECMA-262, | 2465 // expressions we always accept the 'in' keyword; see ECMA-262, |
| 2461 // section 11.12, page 58. | 2466 // section 11.12, page 58. |
| 2462 int left_position = scanner().peek_location().beg_pos; | 2467 int left_position = scanner().peek_location().beg_pos; |
| 2463 Expression* left = ParseAssignmentExpression(true, CHECK_OK); | 2468 Expression* left = ParseAssignmentExpression(true, CHECK_OK); |
| 2464 Expect(Token::COLON, CHECK_OK); | 2469 Expect(Token::COLON, CHECK_OK); |
| 2465 int right_position = scanner().peek_location().beg_pos; | 2470 int right_position = scanner().peek_location().beg_pos; |
| 2466 Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK); | 2471 Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK); |
| 2467 return new(zone()) Conditional(expression, left, right, | 2472 return new(zone()) Conditional( |
| 2468 left_position, right_position); | 2473 isolate(), expression, left, right, left_position, right_position); |
| 2469 } | 2474 } |
| 2470 | 2475 |
| 2471 | 2476 |
| 2472 static int Precedence(Token::Value tok, bool accept_IN) { | 2477 static int Precedence(Token::Value tok, bool accept_IN) { |
| 2473 if (tok == Token::IN && !accept_IN) | 2478 if (tok == Token::IN && !accept_IN) |
| 2474 return 0; // 0 precedence will terminate binary expression parsing | 2479 return 0; // 0 precedence will terminate binary expression parsing |
| 2475 | 2480 |
| 2476 return Token::Precedence(tok); | 2481 return Token::Precedence(tok); |
| 2477 } | 2482 } |
| 2478 | 2483 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2545 // We have a comparison. | 2550 // We have a comparison. |
| 2546 Token::Value cmp = op; | 2551 Token::Value cmp = op; |
| 2547 switch (op) { | 2552 switch (op) { |
| 2548 case Token::NE: cmp = Token::EQ; break; | 2553 case Token::NE: cmp = Token::EQ; break; |
| 2549 case Token::NE_STRICT: cmp = Token::EQ_STRICT; break; | 2554 case Token::NE_STRICT: cmp = Token::EQ_STRICT; break; |
| 2550 default: break; | 2555 default: break; |
| 2551 } | 2556 } |
| 2552 x = NewCompareNode(cmp, x, y, position); | 2557 x = NewCompareNode(cmp, x, y, position); |
| 2553 if (cmp != op) { | 2558 if (cmp != op) { |
| 2554 // The comparison was negated - add a NOT. | 2559 // The comparison was negated - add a NOT. |
| 2555 x = new(zone()) UnaryOperation(Token::NOT, x, position); | 2560 x = new(zone()) UnaryOperation(isolate(), Token::NOT, x, position); |
| 2556 } | 2561 } |
| 2557 | 2562 |
| 2558 } else { | 2563 } else { |
| 2559 // We have a "normal" binary operation. | 2564 // We have a "normal" binary operation. |
| 2560 x = new(zone()) BinaryOperation(op, x, y, position); | 2565 x = new(zone()) BinaryOperation(isolate(), op, x, y, position); |
| 2561 } | 2566 } |
| 2562 } | 2567 } |
| 2563 } | 2568 } |
| 2564 return x; | 2569 return x; |
| 2565 } | 2570 } |
| 2566 | 2571 |
| 2567 | 2572 |
| 2568 Expression* Parser::NewCompareNode(Token::Value op, | 2573 Expression* Parser::NewCompareNode(Token::Value op, |
| 2569 Expression* x, | 2574 Expression* x, |
| 2570 Expression* y, | 2575 Expression* y, |
| 2571 int position) { | 2576 int position) { |
| 2572 ASSERT(op != Token::NE && op != Token::NE_STRICT); | 2577 ASSERT(op != Token::NE && op != Token::NE_STRICT); |
| 2573 if (op == Token::EQ || op == Token::EQ_STRICT) { | 2578 if (op == Token::EQ || op == Token::EQ_STRICT) { |
| 2574 bool is_strict = (op == Token::EQ_STRICT); | 2579 bool is_strict = (op == Token::EQ_STRICT); |
| 2575 Literal* x_literal = x->AsLiteral(); | 2580 Literal* x_literal = x->AsLiteral(); |
| 2576 if (x_literal != NULL && x_literal->IsNull()) { | 2581 if (x_literal != NULL && x_literal->IsNull()) { |
| 2577 return new(zone()) CompareToNull(is_strict, y); | 2582 return new(zone()) CompareToNull(isolate(), is_strict, y); |
| 2578 } | 2583 } |
| 2579 | 2584 |
| 2580 Literal* y_literal = y->AsLiteral(); | 2585 Literal* y_literal = y->AsLiteral(); |
| 2581 if (y_literal != NULL && y_literal->IsNull()) { | 2586 if (y_literal != NULL && y_literal->IsNull()) { |
| 2582 return new(zone()) CompareToNull(is_strict, x); | 2587 return new(zone()) CompareToNull(isolate(), is_strict, x); |
| 2583 } | 2588 } |
| 2584 } | 2589 } |
| 2585 return new(zone()) CompareOperation(op, x, y, position); | 2590 return new(zone()) CompareOperation(isolate(), op, x, y, position); |
| 2586 } | 2591 } |
| 2587 | 2592 |
| 2588 | 2593 |
| 2589 Expression* Parser::ParseUnaryExpression(bool* ok) { | 2594 Expression* Parser::ParseUnaryExpression(bool* ok) { |
| 2590 // UnaryExpression :: | 2595 // UnaryExpression :: |
| 2591 // PostfixExpression | 2596 // PostfixExpression |
| 2592 // 'delete' UnaryExpression | 2597 // 'delete' UnaryExpression |
| 2593 // 'void' UnaryExpression | 2598 // 'void' UnaryExpression |
| 2594 // 'typeof' UnaryExpression | 2599 // 'typeof' UnaryExpression |
| 2595 // '++' UnaryExpression | 2600 // '++' UnaryExpression |
| 2596 // '--' UnaryExpression | 2601 // '--' UnaryExpression |
| 2597 // '+' UnaryExpression | 2602 // '+' UnaryExpression |
| 2598 // '-' UnaryExpression | 2603 // '-' UnaryExpression |
| 2599 // '~' UnaryExpression | 2604 // '~' UnaryExpression |
| 2600 // '!' UnaryExpression | 2605 // '!' UnaryExpression |
| 2601 | 2606 |
| 2602 Token::Value op = peek(); | 2607 Token::Value op = peek(); |
| 2603 if (Token::IsUnaryOp(op)) { | 2608 if (Token::IsUnaryOp(op)) { |
| 2604 op = Next(); | 2609 op = Next(); |
| 2605 int position = scanner().location().beg_pos; | 2610 int position = scanner().location().beg_pos; |
| 2606 Expression* expression = ParseUnaryExpression(CHECK_OK); | 2611 Expression* expression = ParseUnaryExpression(CHECK_OK); |
| 2607 | 2612 |
| 2608 if (expression != NULL && (expression->AsLiteral() != NULL)) { | 2613 if (expression != NULL && (expression->AsLiteral() != NULL)) { |
| 2609 Handle<Object> literal = expression->AsLiteral()->handle(); | 2614 Handle<Object> literal = expression->AsLiteral()->handle(); |
| 2610 if (op == Token::NOT) { | 2615 if (op == Token::NOT) { |
| 2611 // Convert the literal to a boolean condition and negate it. | 2616 // Convert the literal to a boolean condition and negate it. |
| 2612 bool condition = literal->ToBoolean()->IsTrue(); | 2617 bool condition = literal->ToBoolean()->IsTrue(); |
| 2613 Handle<Object> result(isolate()->heap()->ToBoolean(!condition)); | 2618 Handle<Object> result(isolate()->heap()->ToBoolean(!condition)); |
| 2614 return new(zone()) Literal(result); | 2619 return NewLiteral(result); |
| 2615 } else if (literal->IsNumber()) { | 2620 } else if (literal->IsNumber()) { |
| 2616 // Compute some expressions involving only number literals. | 2621 // Compute some expressions involving only number literals. |
| 2617 double value = literal->Number(); | 2622 double value = literal->Number(); |
| 2618 switch (op) { | 2623 switch (op) { |
| 2619 case Token::ADD: | 2624 case Token::ADD: |
| 2620 return expression; | 2625 return expression; |
| 2621 case Token::SUB: | 2626 case Token::SUB: |
| 2622 return NewNumberLiteral(-value); | 2627 return NewNumberLiteral(-value); |
| 2623 case Token::BIT_NOT: | 2628 case Token::BIT_NOT: |
| 2624 return NewNumberLiteral(~DoubleToInt32(value)); | 2629 return NewNumberLiteral(~DoubleToInt32(value)); |
| 2625 default: | 2630 default: |
| 2626 break; | 2631 break; |
| 2627 } | 2632 } |
| 2628 } | 2633 } |
| 2629 } | 2634 } |
| 2630 | 2635 |
| 2631 // "delete identifier" is a syntax error in strict mode. | 2636 // "delete identifier" is a syntax error in strict mode. |
| 2632 if (op == Token::DELETE && top_scope_->is_strict_mode()) { | 2637 if (op == Token::DELETE && top_scope_->is_strict_mode()) { |
| 2633 VariableProxy* operand = expression->AsVariableProxy(); | 2638 VariableProxy* operand = expression->AsVariableProxy(); |
| 2634 if (operand != NULL && !operand->is_this()) { | 2639 if (operand != NULL && !operand->is_this()) { |
| 2635 ReportMessage("strict_delete", Vector<const char*>::empty()); | 2640 ReportMessage("strict_delete", Vector<const char*>::empty()); |
| 2636 *ok = false; | 2641 *ok = false; |
| 2637 return NULL; | 2642 return NULL; |
| 2638 } | 2643 } |
| 2639 } | 2644 } |
| 2640 | 2645 |
| 2641 return new(zone()) UnaryOperation(op, expression, position); | 2646 return new(zone()) UnaryOperation(isolate(), op, expression, position); |
| 2642 | 2647 |
| 2643 } else if (Token::IsCountOp(op)) { | 2648 } else if (Token::IsCountOp(op)) { |
| 2644 op = Next(); | 2649 op = Next(); |
| 2645 Expression* expression = ParseUnaryExpression(CHECK_OK); | 2650 Expression* expression = ParseUnaryExpression(CHECK_OK); |
| 2646 // Signal a reference error if the expression is an invalid | 2651 // Signal a reference error if the expression is an invalid |
| 2647 // left-hand side expression. We could report this as a syntax | 2652 // left-hand side expression. We could report this as a syntax |
| 2648 // error here but for compatibility with JSC we choose to report the | 2653 // error here but for compatibility with JSC we choose to report the |
| 2649 // error at runtime. | 2654 // error at runtime. |
| 2650 if (expression == NULL || !expression->IsValidLeftHandSide()) { | 2655 if (expression == NULL || !expression->IsValidLeftHandSide()) { |
| 2651 Handle<String> type = | 2656 Handle<String> type = |
| 2652 isolate()->factory()->invalid_lhs_in_prefix_op_symbol(); | 2657 isolate()->factory()->invalid_lhs_in_prefix_op_symbol(); |
| 2653 expression = NewThrowReferenceError(type); | 2658 expression = NewThrowReferenceError(type); |
| 2654 } | 2659 } |
| 2655 | 2660 |
| 2656 if (top_scope_->is_strict_mode()) { | 2661 if (top_scope_->is_strict_mode()) { |
| 2657 // Prefix expression operand in strict mode may not be eval or arguments. | 2662 // Prefix expression operand in strict mode may not be eval or arguments. |
| 2658 CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK); | 2663 CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK); |
| 2659 } | 2664 } |
| 2660 | 2665 |
| 2661 int position = scanner().location().beg_pos; | 2666 int position = scanner().location().beg_pos; |
| 2662 return new(zone()) CountOperation(op, | 2667 return new(zone()) CountOperation(isolate(), |
| 2668 op, |
| 2663 true /* prefix */, | 2669 true /* prefix */, |
| 2664 expression, | 2670 expression, |
| 2665 position); | 2671 position); |
| 2666 | 2672 |
| 2667 } else { | 2673 } else { |
| 2668 return ParsePostfixExpression(ok); | 2674 return ParsePostfixExpression(ok); |
| 2669 } | 2675 } |
| 2670 } | 2676 } |
| 2671 | 2677 |
| 2672 | 2678 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2688 } | 2694 } |
| 2689 | 2695 |
| 2690 if (top_scope_->is_strict_mode()) { | 2696 if (top_scope_->is_strict_mode()) { |
| 2691 // Postfix expression operand in strict mode may not be eval or arguments. | 2697 // Postfix expression operand in strict mode may not be eval or arguments. |
| 2692 CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK); | 2698 CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK); |
| 2693 } | 2699 } |
| 2694 | 2700 |
| 2695 Token::Value next = Next(); | 2701 Token::Value next = Next(); |
| 2696 int position = scanner().location().beg_pos; | 2702 int position = scanner().location().beg_pos; |
| 2697 expression = | 2703 expression = |
| 2698 new(zone()) CountOperation(next, | 2704 new(zone()) CountOperation(isolate(), |
| 2705 next, |
| 2699 false /* postfix */, | 2706 false /* postfix */, |
| 2700 expression, | 2707 expression, |
| 2701 position); | 2708 position); |
| 2702 } | 2709 } |
| 2703 return expression; | 2710 return expression; |
| 2704 } | 2711 } |
| 2705 | 2712 |
| 2706 | 2713 |
| 2707 Expression* Parser::ParseLeftHandSideExpression(bool* ok) { | 2714 Expression* Parser::ParseLeftHandSideExpression(bool* ok) { |
| 2708 // LeftHandSideExpression :: | 2715 // LeftHandSideExpression :: |
| 2709 // (NewExpression | MemberExpression) ... | 2716 // (NewExpression | MemberExpression) ... |
| 2710 | 2717 |
| 2711 Expression* result; | 2718 Expression* result; |
| 2712 if (peek() == Token::NEW) { | 2719 if (peek() == Token::NEW) { |
| 2713 result = ParseNewExpression(CHECK_OK); | 2720 result = ParseNewExpression(CHECK_OK); |
| 2714 } else { | 2721 } else { |
| 2715 result = ParseMemberExpression(CHECK_OK); | 2722 result = ParseMemberExpression(CHECK_OK); |
| 2716 } | 2723 } |
| 2717 | 2724 |
| 2718 while (true) { | 2725 while (true) { |
| 2719 switch (peek()) { | 2726 switch (peek()) { |
| 2720 case Token::LBRACK: { | 2727 case Token::LBRACK: { |
| 2721 Consume(Token::LBRACK); | 2728 Consume(Token::LBRACK); |
| 2722 int pos = scanner().location().beg_pos; | 2729 int pos = scanner().location().beg_pos; |
| 2723 Expression* index = ParseExpression(true, CHECK_OK); | 2730 Expression* index = ParseExpression(true, CHECK_OK); |
| 2724 result = new(zone()) Property(result, index, pos); | 2731 result = new(zone()) Property(isolate(), result, index, pos); |
| 2725 Expect(Token::RBRACK, CHECK_OK); | 2732 Expect(Token::RBRACK, CHECK_OK); |
| 2726 break; | 2733 break; |
| 2727 } | 2734 } |
| 2728 | 2735 |
| 2729 case Token::LPAREN: { | 2736 case Token::LPAREN: { |
| 2730 int pos = scanner().location().beg_pos; | 2737 int pos = scanner().location().beg_pos; |
| 2731 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); | 2738 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); |
| 2732 | 2739 |
| 2733 // Keep track of eval() calls since they disable all local variable | 2740 // Keep track of eval() calls since they disable all local variable |
| 2734 // optimizations. | 2741 // optimizations. |
| 2735 // The calls that need special treatment are the | 2742 // The calls that need special treatment are the |
| 2736 // direct (i.e. not aliased) eval calls. These calls are all of the | 2743 // direct (i.e. not aliased) eval calls. These calls are all of the |
| 2737 // form eval(...) with no explicit receiver object where eval is not | 2744 // form eval(...) with no explicit receiver object where eval is not |
| 2738 // declared in the current scope chain. | 2745 // declared in the current scope chain. |
| 2739 // These calls are marked as potentially direct eval calls. Whether | 2746 // These calls are marked as potentially direct eval calls. Whether |
| 2740 // they are actually direct calls to eval is determined at run time. | 2747 // they are actually direct calls to eval is determined at run time. |
| 2741 // TODO(994): In ES5, it doesn't matter if the "eval" var is declared | 2748 // TODO(994): In ES5, it doesn't matter if the "eval" var is declared |
| 2742 // in the local scope chain. It only matters that it's called "eval", | 2749 // in the local scope chain. It only matters that it's called "eval", |
| 2743 // is called without a receiver and it refers to the original eval | 2750 // is called without a receiver and it refers to the original eval |
| 2744 // function. | 2751 // function. |
| 2745 VariableProxy* callee = result->AsVariableProxy(); | 2752 VariableProxy* callee = result->AsVariableProxy(); |
| 2746 if (callee != NULL && | 2753 if (callee != NULL && |
| 2747 callee->IsVariable(isolate()->factory()->eval_symbol())) { | 2754 callee->IsVariable(isolate()->factory()->eval_symbol())) { |
| 2748 Handle<String> name = callee->name(); | 2755 Handle<String> name = callee->name(); |
| 2749 Variable* var = top_scope_->Lookup(name); | 2756 Variable* var = top_scope_->Lookup(name); |
| 2750 if (var == NULL) { | 2757 if (var == NULL) { |
| 2751 top_scope_->RecordEvalCall(); | 2758 top_scope_->DeclarationScope()->RecordEvalCall(); |
| 2752 } | 2759 } |
| 2753 } | 2760 } |
| 2754 result = NewCall(result, args, pos); | 2761 result = NewCall(result, args, pos); |
| 2755 break; | 2762 break; |
| 2756 } | 2763 } |
| 2757 | 2764 |
| 2758 case Token::PERIOD: { | 2765 case Token::PERIOD: { |
| 2759 Consume(Token::PERIOD); | 2766 Consume(Token::PERIOD); |
| 2760 int pos = scanner().location().beg_pos; | 2767 int pos = scanner().location().beg_pos; |
| 2761 Handle<String> name = ParseIdentifierName(CHECK_OK); | 2768 Handle<String> name = ParseIdentifierName(CHECK_OK); |
| 2762 result = new(zone()) Property(result, new(zone()) Literal(name), pos); | 2769 result = new(zone()) Property(isolate(), |
| 2770 result, |
| 2771 NewLiteral(name), |
| 2772 pos); |
| 2763 if (fni_ != NULL) fni_->PushLiteralName(name); | 2773 if (fni_ != NULL) fni_->PushLiteralName(name); |
| 2764 break; | 2774 break; |
| 2765 } | 2775 } |
| 2766 | 2776 |
| 2767 default: | 2777 default: |
| 2768 return result; | 2778 return result; |
| 2769 } | 2779 } |
| 2770 } | 2780 } |
| 2771 } | 2781 } |
| 2772 | 2782 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2788 | 2798 |
| 2789 Expression* result; | 2799 Expression* result; |
| 2790 if (peek() == Token::NEW) { | 2800 if (peek() == Token::NEW) { |
| 2791 result = ParseNewPrefix(stack, CHECK_OK); | 2801 result = ParseNewPrefix(stack, CHECK_OK); |
| 2792 } else { | 2802 } else { |
| 2793 result = ParseMemberWithNewPrefixesExpression(stack, CHECK_OK); | 2803 result = ParseMemberWithNewPrefixesExpression(stack, CHECK_OK); |
| 2794 } | 2804 } |
| 2795 | 2805 |
| 2796 if (!stack->is_empty()) { | 2806 if (!stack->is_empty()) { |
| 2797 int last = stack->pop(); | 2807 int last = stack->pop(); |
| 2798 result = new(zone()) CallNew(result, | 2808 result = new(zone()) CallNew(isolate(), |
| 2809 result, |
| 2799 new(zone()) ZoneList<Expression*>(0), | 2810 new(zone()) ZoneList<Expression*>(0), |
| 2800 last); | 2811 last); |
| 2801 } | 2812 } |
| 2802 return result; | 2813 return result; |
| 2803 } | 2814 } |
| 2804 | 2815 |
| 2805 | 2816 |
| 2806 Expression* Parser::ParseNewExpression(bool* ok) { | 2817 Expression* Parser::ParseNewExpression(bool* ok) { |
| 2807 PositionStack stack(ok); | 2818 PositionStack stack(ok); |
| 2808 return ParseNewPrefix(&stack, ok); | 2819 return ParseNewPrefix(&stack, ok); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2836 } else { | 2847 } else { |
| 2837 result = ParsePrimaryExpression(CHECK_OK); | 2848 result = ParsePrimaryExpression(CHECK_OK); |
| 2838 } | 2849 } |
| 2839 | 2850 |
| 2840 while (true) { | 2851 while (true) { |
| 2841 switch (peek()) { | 2852 switch (peek()) { |
| 2842 case Token::LBRACK: { | 2853 case Token::LBRACK: { |
| 2843 Consume(Token::LBRACK); | 2854 Consume(Token::LBRACK); |
| 2844 int pos = scanner().location().beg_pos; | 2855 int pos = scanner().location().beg_pos; |
| 2845 Expression* index = ParseExpression(true, CHECK_OK); | 2856 Expression* index = ParseExpression(true, CHECK_OK); |
| 2846 result = new(zone()) Property(result, index, pos); | 2857 result = new(zone()) Property(isolate(), result, index, pos); |
| 2847 if (fni_ != NULL) { | 2858 if (fni_ != NULL) { |
| 2848 if (index->IsPropertyName()) { | 2859 if (index->IsPropertyName()) { |
| 2849 fni_->PushLiteralName(index->AsLiteral()->AsPropertyName()); | 2860 fni_->PushLiteralName(index->AsLiteral()->AsPropertyName()); |
| 2850 } else { | 2861 } else { |
| 2851 fni_->PushLiteralName( | 2862 fni_->PushLiteralName( |
| 2852 isolate()->factory()->anonymous_function_symbol()); | 2863 isolate()->factory()->anonymous_function_symbol()); |
| 2853 } | 2864 } |
| 2854 } | 2865 } |
| 2855 Expect(Token::RBRACK, CHECK_OK); | 2866 Expect(Token::RBRACK, CHECK_OK); |
| 2856 break; | 2867 break; |
| 2857 } | 2868 } |
| 2858 case Token::PERIOD: { | 2869 case Token::PERIOD: { |
| 2859 Consume(Token::PERIOD); | 2870 Consume(Token::PERIOD); |
| 2860 int pos = scanner().location().beg_pos; | 2871 int pos = scanner().location().beg_pos; |
| 2861 Handle<String> name = ParseIdentifierName(CHECK_OK); | 2872 Handle<String> name = ParseIdentifierName(CHECK_OK); |
| 2862 result = new(zone()) Property(result, new(zone()) Literal(name), pos); | 2873 result = new(zone()) Property(isolate(), |
| 2874 result, |
| 2875 NewLiteral(name), |
| 2876 pos); |
| 2863 if (fni_ != NULL) fni_->PushLiteralName(name); | 2877 if (fni_ != NULL) fni_->PushLiteralName(name); |
| 2864 break; | 2878 break; |
| 2865 } | 2879 } |
| 2866 case Token::LPAREN: { | 2880 case Token::LPAREN: { |
| 2867 if ((stack == NULL) || stack->is_empty()) return result; | 2881 if ((stack == NULL) || stack->is_empty()) return result; |
| 2868 // Consume one of the new prefixes (already parsed). | 2882 // Consume one of the new prefixes (already parsed). |
| 2869 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); | 2883 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); |
| 2870 int last = stack->pop(); | 2884 int last = stack->pop(); |
| 2871 result = new CallNew(result, args, last); | 2885 result = new(zone()) CallNew(isolate(), result, args, last); |
| 2872 break; | 2886 break; |
| 2873 } | 2887 } |
| 2874 default: | 2888 default: |
| 2875 return result; | 2889 return result; |
| 2876 } | 2890 } |
| 2877 } | 2891 } |
| 2878 } | 2892 } |
| 2879 | 2893 |
| 2880 | 2894 |
| 2881 DebuggerStatement* Parser::ParseDebuggerStatement(bool* ok) { | 2895 DebuggerStatement* Parser::ParseDebuggerStatement(bool* ok) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2945 // String | 2959 // String |
| 2946 // ArrayLiteral | 2960 // ArrayLiteral |
| 2947 // ObjectLiteral | 2961 // ObjectLiteral |
| 2948 // RegExpLiteral | 2962 // RegExpLiteral |
| 2949 // '(' Expression ')' | 2963 // '(' Expression ')' |
| 2950 | 2964 |
| 2951 Expression* result = NULL; | 2965 Expression* result = NULL; |
| 2952 switch (peek()) { | 2966 switch (peek()) { |
| 2953 case Token::THIS: { | 2967 case Token::THIS: { |
| 2954 Consume(Token::THIS); | 2968 Consume(Token::THIS); |
| 2955 result = new(zone()) VariableProxy(top_scope_->receiver()); | 2969 result = new(zone()) VariableProxy(isolate(), top_scope_->receiver()); |
| 2956 break; | 2970 break; |
| 2957 } | 2971 } |
| 2958 | 2972 |
| 2959 case Token::NULL_LITERAL: | 2973 case Token::NULL_LITERAL: |
| 2960 Consume(Token::NULL_LITERAL); | 2974 Consume(Token::NULL_LITERAL); |
| 2961 result = new(zone()) Literal(isolate()->factory()->null_value()); | 2975 result = new(zone()) Literal( |
| 2976 isolate(), isolate()->factory()->null_value()); |
| 2962 break; | 2977 break; |
| 2963 | 2978 |
| 2964 case Token::TRUE_LITERAL: | 2979 case Token::TRUE_LITERAL: |
| 2965 Consume(Token::TRUE_LITERAL); | 2980 Consume(Token::TRUE_LITERAL); |
| 2966 result = new(zone()) Literal(isolate()->factory()->true_value()); | 2981 result = new(zone()) Literal( |
| 2982 isolate(), isolate()->factory()->true_value()); |
| 2967 break; | 2983 break; |
| 2968 | 2984 |
| 2969 case Token::FALSE_LITERAL: | 2985 case Token::FALSE_LITERAL: |
| 2970 Consume(Token::FALSE_LITERAL); | 2986 Consume(Token::FALSE_LITERAL); |
| 2971 result = new(zone()) Literal(isolate()->factory()->false_value()); | 2987 result = new(zone()) Literal( |
| 2988 isolate(), isolate()->factory()->false_value()); |
| 2972 break; | 2989 break; |
| 2973 | 2990 |
| 2974 case Token::IDENTIFIER: | 2991 case Token::IDENTIFIER: |
| 2975 case Token::FUTURE_STRICT_RESERVED_WORD: { | 2992 case Token::FUTURE_STRICT_RESERVED_WORD: { |
| 2976 Handle<String> name = ParseIdentifier(CHECK_OK); | 2993 Handle<String> name = ParseIdentifier(CHECK_OK); |
| 2977 if (fni_ != NULL) fni_->PushVariableName(name); | 2994 if (fni_ != NULL) fni_->PushVariableName(name); |
| 2978 result = top_scope_->NewUnresolved(name, | 2995 result = top_scope_->NewUnresolved(name, |
| 2979 inside_with(), | 2996 inside_with(), |
| 2980 scanner().location().beg_pos); | 2997 scanner().location().beg_pos); |
| 2981 break; | 2998 break; |
| 2982 } | 2999 } |
| 2983 | 3000 |
| 2984 case Token::NUMBER: { | 3001 case Token::NUMBER: { |
| 2985 Consume(Token::NUMBER); | 3002 Consume(Token::NUMBER); |
| 2986 ASSERT(scanner().is_literal_ascii()); | 3003 ASSERT(scanner().is_literal_ascii()); |
| 2987 double value = StringToDouble(isolate()->unicode_cache(), | 3004 double value = StringToDouble(isolate()->unicode_cache(), |
| 2988 scanner().literal_ascii_string(), | 3005 scanner().literal_ascii_string(), |
| 2989 ALLOW_HEX | ALLOW_OCTALS); | 3006 ALLOW_HEX | ALLOW_OCTALS); |
| 2990 result = NewNumberLiteral(value); | 3007 result = NewNumberLiteral(value); |
| 2991 break; | 3008 break; |
| 2992 } | 3009 } |
| 2993 | 3010 |
| 2994 case Token::STRING: { | 3011 case Token::STRING: { |
| 2995 Consume(Token::STRING); | 3012 Consume(Token::STRING); |
| 2996 Handle<String> symbol = GetSymbol(CHECK_OK); | 3013 Handle<String> symbol = GetSymbol(CHECK_OK); |
| 2997 result = new(zone()) Literal(symbol); | 3014 result = NewLiteral(symbol); |
| 2998 if (fni_ != NULL) fni_->PushLiteralName(symbol); | 3015 if (fni_ != NULL) fni_->PushLiteralName(symbol); |
| 2999 break; | 3016 break; |
| 3000 } | 3017 } |
| 3001 | 3018 |
| 3002 case Token::ASSIGN_DIV: | 3019 case Token::ASSIGN_DIV: |
| 3003 result = ParseRegExpLiteral(true, CHECK_OK); | 3020 result = ParseRegExpLiteral(true, CHECK_OK); |
| 3004 break; | 3021 break; |
| 3005 | 3022 |
| 3006 case Token::DIV: | 3023 case Token::DIV: |
| 3007 result = ParseRegExpLiteral(false, CHECK_OK); | 3024 result = ParseRegExpLiteral(false, CHECK_OK); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3114 literals->set(i, *boilerplate_value); | 3131 literals->set(i, *boilerplate_value); |
| 3115 } | 3132 } |
| 3116 } | 3133 } |
| 3117 | 3134 |
| 3118 // Simple and shallow arrays can be lazily copied, we transform the | 3135 // Simple and shallow arrays can be lazily copied, we transform the |
| 3119 // elements array to a copy-on-write array. | 3136 // elements array to a copy-on-write array. |
| 3120 if (is_simple && depth == 1 && values->length() > 0) { | 3137 if (is_simple && depth == 1 && values->length() > 0) { |
| 3121 literals->set_map(isolate()->heap()->fixed_cow_array_map()); | 3138 literals->set_map(isolate()->heap()->fixed_cow_array_map()); |
| 3122 } | 3139 } |
| 3123 | 3140 |
| 3124 return new(zone()) ArrayLiteral(literals, values, | 3141 return new(zone()) ArrayLiteral( |
| 3125 literal_index, is_simple, depth); | 3142 isolate(), literals, values, literal_index, is_simple, depth); |
| 3126 } | 3143 } |
| 3127 | 3144 |
| 3128 | 3145 |
| 3129 bool Parser::IsBoilerplateProperty(ObjectLiteral::Property* property) { | 3146 bool Parser::IsBoilerplateProperty(ObjectLiteral::Property* property) { |
| 3130 return property != NULL && | 3147 return property != NULL && |
| 3131 property->kind() != ObjectLiteral::Property::PROTOTYPE; | 3148 property->kind() != ObjectLiteral::Property::PROTOTYPE; |
| 3132 } | 3149 } |
| 3133 | 3150 |
| 3134 | 3151 |
| 3135 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { | 3152 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3418 // )*[','] '}' | 3435 // )*[','] '}' |
| 3419 | 3436 |
| 3420 ZoneList<ObjectLiteral::Property*>* properties = | 3437 ZoneList<ObjectLiteral::Property*>* properties = |
| 3421 new(zone()) ZoneList<ObjectLiteral::Property*>(4); | 3438 new(zone()) ZoneList<ObjectLiteral::Property*>(4); |
| 3422 int number_of_boilerplate_properties = 0; | 3439 int number_of_boilerplate_properties = 0; |
| 3423 bool has_function = false; | 3440 bool has_function = false; |
| 3424 | 3441 |
| 3425 ObjectLiteralPropertyChecker checker(this, top_scope_->is_strict_mode()); | 3442 ObjectLiteralPropertyChecker checker(this, top_scope_->is_strict_mode()); |
| 3426 | 3443 |
| 3427 Expect(Token::LBRACE, CHECK_OK); | 3444 Expect(Token::LBRACE, CHECK_OK); |
| 3428 Scanner::Location loc = scanner().location(); | |
| 3429 | 3445 |
| 3430 while (peek() != Token::RBRACE) { | 3446 while (peek() != Token::RBRACE) { |
| 3431 if (fni_ != NULL) fni_->Enter(); | 3447 if (fni_ != NULL) fni_->Enter(); |
| 3432 | 3448 |
| 3433 Literal* key = NULL; | 3449 Literal* key = NULL; |
| 3434 Token::Value next = peek(); | 3450 Token::Value next = peek(); |
| 3435 | 3451 |
| 3436 // Location of the property name token | 3452 // Location of the property name token |
| 3437 Scanner::Location loc = scanner().peek_location(); | 3453 Scanner::Location loc = scanner().peek_location(); |
| 3438 | 3454 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3460 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); | 3476 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); |
| 3461 | 3477 |
| 3462 if (fni_ != NULL) { | 3478 if (fni_ != NULL) { |
| 3463 fni_->Infer(); | 3479 fni_->Infer(); |
| 3464 fni_->Leave(); | 3480 fni_->Leave(); |
| 3465 } | 3481 } |
| 3466 continue; // restart the while | 3482 continue; // restart the while |
| 3467 } | 3483 } |
| 3468 // Failed to parse as get/set property, so it's just a property | 3484 // Failed to parse as get/set property, so it's just a property |
| 3469 // called "get" or "set". | 3485 // called "get" or "set". |
| 3470 key = new(zone()) Literal(id); | 3486 key = NewLiteral(id); |
| 3471 break; | 3487 break; |
| 3472 } | 3488 } |
| 3473 case Token::STRING: { | 3489 case Token::STRING: { |
| 3474 Consume(Token::STRING); | 3490 Consume(Token::STRING); |
| 3475 Handle<String> string = GetSymbol(CHECK_OK); | 3491 Handle<String> string = GetSymbol(CHECK_OK); |
| 3476 if (fni_ != NULL) fni_->PushLiteralName(string); | 3492 if (fni_ != NULL) fni_->PushLiteralName(string); |
| 3477 uint32_t index; | 3493 uint32_t index; |
| 3478 if (!string.is_null() && string->AsArrayIndex(&index)) { | 3494 if (!string.is_null() && string->AsArrayIndex(&index)) { |
| 3479 key = NewNumberLiteral(index); | 3495 key = NewNumberLiteral(index); |
| 3480 break; | 3496 break; |
| 3481 } | 3497 } |
| 3482 key = new(zone()) Literal(string); | 3498 key = NewLiteral(string); |
| 3483 break; | 3499 break; |
| 3484 } | 3500 } |
| 3485 case Token::NUMBER: { | 3501 case Token::NUMBER: { |
| 3486 Consume(Token::NUMBER); | 3502 Consume(Token::NUMBER); |
| 3487 ASSERT(scanner().is_literal_ascii()); | 3503 ASSERT(scanner().is_literal_ascii()); |
| 3488 double value = StringToDouble(isolate()->unicode_cache(), | 3504 double value = StringToDouble(isolate()->unicode_cache(), |
| 3489 scanner().literal_ascii_string(), | 3505 scanner().literal_ascii_string(), |
| 3490 ALLOW_HEX | ALLOW_OCTALS); | 3506 ALLOW_HEX | ALLOW_OCTALS); |
| 3491 key = NewNumberLiteral(value); | 3507 key = NewNumberLiteral(value); |
| 3492 break; | 3508 break; |
| 3493 } | 3509 } |
| 3494 default: | 3510 default: |
| 3495 if (Token::IsKeyword(next)) { | 3511 if (Token::IsKeyword(next)) { |
| 3496 Consume(next); | 3512 Consume(next); |
| 3497 Handle<String> string = GetSymbol(CHECK_OK); | 3513 Handle<String> string = GetSymbol(CHECK_OK); |
| 3498 key = new(zone()) Literal(string); | 3514 key = NewLiteral(string); |
| 3499 } else { | 3515 } else { |
| 3500 // Unexpected token. | 3516 // Unexpected token. |
| 3501 Token::Value next = Next(); | 3517 Token::Value next = Next(); |
| 3502 ReportUnexpectedToken(next); | 3518 ReportUnexpectedToken(next); |
| 3503 *ok = false; | 3519 *ok = false; |
| 3504 return NULL; | 3520 return NULL; |
| 3505 } | 3521 } |
| 3506 } | 3522 } |
| 3507 | 3523 |
| 3508 Expect(Token::COLON, CHECK_OK); | 3524 Expect(Token::COLON, CHECK_OK); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3541 number_of_boilerplate_properties * 2, TENURED); | 3557 number_of_boilerplate_properties * 2, TENURED); |
| 3542 | 3558 |
| 3543 bool is_simple = true; | 3559 bool is_simple = true; |
| 3544 bool fast_elements = true; | 3560 bool fast_elements = true; |
| 3545 int depth = 1; | 3561 int depth = 1; |
| 3546 BuildObjectLiteralConstantProperties(properties, | 3562 BuildObjectLiteralConstantProperties(properties, |
| 3547 constant_properties, | 3563 constant_properties, |
| 3548 &is_simple, | 3564 &is_simple, |
| 3549 &fast_elements, | 3565 &fast_elements, |
| 3550 &depth); | 3566 &depth); |
| 3551 return new(zone()) ObjectLiteral(constant_properties, | 3567 return new(zone()) ObjectLiteral(isolate(), |
| 3552 properties, | 3568 constant_properties, |
| 3553 literal_index, | 3569 properties, |
| 3554 is_simple, | 3570 literal_index, |
| 3555 fast_elements, | 3571 is_simple, |
| 3556 depth, | 3572 fast_elements, |
| 3557 has_function); | 3573 depth, |
| 3574 has_function); |
| 3558 } | 3575 } |
| 3559 | 3576 |
| 3560 | 3577 |
| 3561 Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) { | 3578 Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) { |
| 3562 if (!scanner().ScanRegExpPattern(seen_equal)) { | 3579 if (!scanner().ScanRegExpPattern(seen_equal)) { |
| 3563 Next(); | 3580 Next(); |
| 3564 ReportMessage("unterminated_regexp", Vector<const char*>::empty()); | 3581 ReportMessage("unterminated_regexp", Vector<const char*>::empty()); |
| 3565 *ok = false; | 3582 *ok = false; |
| 3566 return NULL; | 3583 return NULL; |
| 3567 } | 3584 } |
| 3568 | 3585 |
| 3569 int literal_index = lexical_scope_->NextMaterializedLiteralIndex(); | 3586 int literal_index = lexical_scope_->NextMaterializedLiteralIndex(); |
| 3570 | 3587 |
| 3571 Handle<String> js_pattern = NextLiteralString(TENURED); | 3588 Handle<String> js_pattern = NextLiteralString(TENURED); |
| 3572 scanner().ScanRegExpFlags(); | 3589 scanner().ScanRegExpFlags(); |
| 3573 Handle<String> js_flags = NextLiteralString(TENURED); | 3590 Handle<String> js_flags = NextLiteralString(TENURED); |
| 3574 Next(); | 3591 Next(); |
| 3575 | 3592 |
| 3576 return new(zone()) RegExpLiteral(js_pattern, js_flags, literal_index); | 3593 return new(zone()) RegExpLiteral( |
| 3594 isolate(), js_pattern, js_flags, literal_index); |
| 3577 } | 3595 } |
| 3578 | 3596 |
| 3579 | 3597 |
| 3580 ZoneList<Expression*>* Parser::ParseArguments(bool* ok) { | 3598 ZoneList<Expression*>* Parser::ParseArguments(bool* ok) { |
| 3581 // Arguments :: | 3599 // Arguments :: |
| 3582 // '(' (AssignmentExpression)*[','] ')' | 3600 // '(' (AssignmentExpression)*[','] ')' |
| 3583 | 3601 |
| 3584 ZoneList<Expression*>* result = new(zone()) ZoneList<Expression*>(4); | 3602 ZoneList<Expression*>* result = new(zone()) ZoneList<Expression*>(4); |
| 3585 Expect(Token::LPAREN, CHECK_OK); | 3603 Expect(Token::LPAREN, CHECK_OK); |
| 3586 bool done = (peek() == Token::RPAREN); | 3604 bool done = (peek() == Token::RPAREN); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3683 // function and let it refer to the function itself (closure). | 3701 // function and let it refer to the function itself (closure). |
| 3684 // NOTE: We create a proxy and resolve it here so that in the | 3702 // NOTE: We create a proxy and resolve it here so that in the |
| 3685 // future we can change the AST to only refer to VariableProxies | 3703 // future we can change the AST to only refer to VariableProxies |
| 3686 // instead of Variables and Proxis as is the case now. | 3704 // instead of Variables and Proxis as is the case now. |
| 3687 if (!function_name.is_null() && function_name->length() > 0) { | 3705 if (!function_name.is_null() && function_name->length() > 0) { |
| 3688 Variable* fvar = top_scope_->DeclareFunctionVar(function_name); | 3706 Variable* fvar = top_scope_->DeclareFunctionVar(function_name); |
| 3689 VariableProxy* fproxy = | 3707 VariableProxy* fproxy = |
| 3690 top_scope_->NewUnresolved(function_name, inside_with()); | 3708 top_scope_->NewUnresolved(function_name, inside_with()); |
| 3691 fproxy->BindTo(fvar); | 3709 fproxy->BindTo(fvar); |
| 3692 body->Add(new(zone()) ExpressionStatement( | 3710 body->Add(new(zone()) ExpressionStatement( |
| 3693 new(zone()) Assignment(Token::INIT_CONST, fproxy, | 3711 new(zone()) Assignment(isolate(), |
| 3694 new(zone()) ThisFunction(), | 3712 Token::INIT_CONST, |
| 3695 RelocInfo::kNoPosition))); | 3713 fproxy, |
| 3714 new(zone()) ThisFunction(isolate()), |
| 3715 RelocInfo::kNoPosition))); |
| 3696 } | 3716 } |
| 3697 | 3717 |
| 3698 // Determine if the function will be lazily compiled. The mode can | 3718 // Determine if the function will be lazily compiled. The mode can |
| 3699 // only be PARSE_LAZILY if the --lazy flag is true. | 3719 // only be PARSE_LAZILY if the --lazy flag is true. |
| 3700 bool is_lazily_compiled = (mode() == PARSE_LAZILY && | 3720 bool is_lazily_compiled = (mode() == PARSE_LAZILY && |
| 3701 top_scope_->outer_scope()->is_global_scope() && | 3721 top_scope_->outer_scope()->is_global_scope() && |
| 3702 top_scope_->HasTrivialOuterContext() && | 3722 top_scope_->HasTrivialOuterContext() && |
| 3703 !parenthesized_function_); | 3723 !parenthesized_function_); |
| 3704 parenthesized_function_ = false; // The bit was set for this function only. | 3724 parenthesized_function_ = false; // The bit was set for this function only. |
| 3705 | 3725 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3775 ReportMessageAt(reserved_loc, "strict_reserved_word", | 3795 ReportMessageAt(reserved_loc, "strict_reserved_word", |
| 3776 Vector<const char*>::empty()); | 3796 Vector<const char*>::empty()); |
| 3777 *ok = false; | 3797 *ok = false; |
| 3778 return NULL; | 3798 return NULL; |
| 3779 } | 3799 } |
| 3780 CheckOctalLiteral(start_pos, end_pos, CHECK_OK); | 3800 CheckOctalLiteral(start_pos, end_pos, CHECK_OK); |
| 3781 } | 3801 } |
| 3782 } | 3802 } |
| 3783 | 3803 |
| 3784 FunctionLiteral* function_literal = | 3804 FunctionLiteral* function_literal = |
| 3785 new(zone()) FunctionLiteral(name, | 3805 new(zone()) FunctionLiteral(isolate(), |
| 3806 name, |
| 3786 scope, | 3807 scope, |
| 3787 body, | 3808 body, |
| 3788 materialized_literal_count, | 3809 materialized_literal_count, |
| 3789 expected_property_count, | 3810 expected_property_count, |
| 3790 only_simple_this_property_assignments, | 3811 only_simple_this_property_assignments, |
| 3791 this_property_assignments, | 3812 this_property_assignments, |
| 3792 num_parameters, | 3813 num_parameters, |
| 3793 start_pos, | 3814 start_pos, |
| 3794 end_pos, | 3815 end_pos, |
| 3795 (function_name->length() > 0), | 3816 (function_name->length() > 0), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3836 // Check that the expected number of arguments are being passed. | 3857 // Check that the expected number of arguments are being passed. |
| 3837 if (function != NULL && | 3858 if (function != NULL && |
| 3838 function->nargs != -1 && | 3859 function->nargs != -1 && |
| 3839 function->nargs != args->length()) { | 3860 function->nargs != args->length()) { |
| 3840 ReportMessage("illegal_access", Vector<const char*>::empty()); | 3861 ReportMessage("illegal_access", Vector<const char*>::empty()); |
| 3841 *ok = false; | 3862 *ok = false; |
| 3842 return NULL; | 3863 return NULL; |
| 3843 } | 3864 } |
| 3844 | 3865 |
| 3845 // We have a valid intrinsics call or a call to a builtin. | 3866 // We have a valid intrinsics call or a call to a builtin. |
| 3846 return new(zone()) CallRuntime(name, function, args); | 3867 return new(zone()) CallRuntime(isolate(), name, function, args); |
| 3847 } | 3868 } |
| 3848 | 3869 |
| 3849 | 3870 |
| 3850 bool Parser::peek_any_identifier() { | 3871 bool Parser::peek_any_identifier() { |
| 3851 Token::Value next = peek(); | 3872 Token::Value next = peek(); |
| 3852 return next == Token::IDENTIFIER || | 3873 return next == Token::IDENTIFIER || |
| 3853 next == Token::FUTURE_RESERVED_WORD || | 3874 next == Token::FUTURE_RESERVED_WORD || |
| 3854 next == Token::FUTURE_STRICT_RESERVED_WORD; | 3875 next == Token::FUTURE_STRICT_RESERVED_WORD; |
| 3855 } | 3876 } |
| 3856 | 3877 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3892 if (scanner().HasAnyLineTerminatorBeforeNext() || | 3913 if (scanner().HasAnyLineTerminatorBeforeNext() || |
| 3893 tok == Token::RBRACE || | 3914 tok == Token::RBRACE || |
| 3894 tok == Token::EOS) { | 3915 tok == Token::EOS) { |
| 3895 return; | 3916 return; |
| 3896 } | 3917 } |
| 3897 Expect(Token::SEMICOLON, ok); | 3918 Expect(Token::SEMICOLON, ok); |
| 3898 } | 3919 } |
| 3899 | 3920 |
| 3900 | 3921 |
| 3901 Literal* Parser::GetLiteralUndefined() { | 3922 Literal* Parser::GetLiteralUndefined() { |
| 3902 return new(zone()) Literal(isolate()->factory()->undefined_value()); | 3923 return NewLiteral(isolate()->factory()->undefined_value()); |
| 3903 } | 3924 } |
| 3904 | 3925 |
| 3905 | 3926 |
| 3906 Literal* Parser::GetLiteralTheHole() { | 3927 Literal* Parser::GetLiteralTheHole() { |
| 3907 return new(zone()) Literal(isolate()->factory()->the_hole_value()); | 3928 return NewLiteral(isolate()->factory()->the_hole_value()); |
| 3908 } | 3929 } |
| 3909 | 3930 |
| 3910 | 3931 |
| 3911 Literal* Parser::GetLiteralNumber(double value) { | 3932 Literal* Parser::GetLiteralNumber(double value) { |
| 3912 return NewNumberLiteral(value); | 3933 return NewNumberLiteral(value); |
| 3913 } | 3934 } |
| 3914 | 3935 |
| 3915 | 3936 |
| 3916 // Parses and identifier that is valid for the current scope, in particular it | 3937 // Parses and identifier that is valid for the current scope, in particular it |
| 3917 // fails on strict mode future reserved keywords in a strict scope. | 3938 // fails on strict mode future reserved keywords in a strict scope. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4053 // target stack has been used from the top of the target stack. Add | 4074 // target stack has been used from the top of the target stack. Add |
| 4054 // the break target to any TargetCollectors passed on the stack. | 4075 // the break target to any TargetCollectors passed on the stack. |
| 4055 for (Target* t = target_stack_; t != stop; t = t->previous()) { | 4076 for (Target* t = target_stack_; t != stop; t = t->previous()) { |
| 4056 TargetCollector* collector = t->node()->AsTargetCollector(); | 4077 TargetCollector* collector = t->node()->AsTargetCollector(); |
| 4057 if (collector != NULL) collector->AddTarget(target); | 4078 if (collector != NULL) collector->AddTarget(target); |
| 4058 } | 4079 } |
| 4059 } | 4080 } |
| 4060 | 4081 |
| 4061 | 4082 |
| 4062 Literal* Parser::NewNumberLiteral(double number) { | 4083 Literal* Parser::NewNumberLiteral(double number) { |
| 4063 return new(zone()) Literal(isolate()->factory()->NewNumber(number, TENURED)); | 4084 return NewLiteral(isolate()->factory()->NewNumber(number, TENURED)); |
| 4064 } | 4085 } |
| 4065 | 4086 |
| 4066 | 4087 |
| 4067 Expression* Parser::NewThrowReferenceError(Handle<String> type) { | 4088 Expression* Parser::NewThrowReferenceError(Handle<String> type) { |
| 4068 return NewThrowError(isolate()->factory()->MakeReferenceError_symbol(), | 4089 return NewThrowError(isolate()->factory()->MakeReferenceError_symbol(), |
| 4069 type, HandleVector<Object>(NULL, 0)); | 4090 type, HandleVector<Object>(NULL, 0)); |
| 4070 } | 4091 } |
| 4071 | 4092 |
| 4072 | 4093 |
| 4073 Expression* Parser::NewThrowSyntaxError(Handle<String> type, | 4094 Expression* Parser::NewThrowSyntaxError(Handle<String> type, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4100 for (int i = 0; i < argc; i++) { | 4121 for (int i = 0; i < argc; i++) { |
| 4101 Handle<Object> element = arguments[i]; | 4122 Handle<Object> element = arguments[i]; |
| 4102 if (!element.is_null()) { | 4123 if (!element.is_null()) { |
| 4103 elements->set(i, *element); | 4124 elements->set(i, *element); |
| 4104 } | 4125 } |
| 4105 } | 4126 } |
| 4106 Handle<JSArray> array = isolate()->factory()->NewJSArrayWithElements(elements, | 4127 Handle<JSArray> array = isolate()->factory()->NewJSArrayWithElements(elements, |
| 4107 TENURED); | 4128 TENURED); |
| 4108 | 4129 |
| 4109 ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2); | 4130 ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2); |
| 4110 args->Add(new(zone()) Literal(type)); | 4131 args->Add(NewLiteral(type)); |
| 4111 args->Add(new(zone()) Literal(array)); | 4132 args->Add(NewLiteral(array)); |
| 4112 return new(zone()) Throw(new(zone()) CallRuntime(constructor, NULL, args), | 4133 CallRuntime* call_constructor = new(zone()) CallRuntime(isolate(), |
| 4113 scanner().location().beg_pos); | 4134 constructor, |
| 4135 NULL, |
| 4136 args); |
| 4137 return new(zone()) Throw(isolate(), |
| 4138 call_constructor, |
| 4139 scanner().location().beg_pos); |
| 4114 } | 4140 } |
| 4115 | 4141 |
| 4116 // ---------------------------------------------------------------------------- | 4142 // ---------------------------------------------------------------------------- |
| 4117 // Regular expressions | 4143 // Regular expressions |
| 4118 | 4144 |
| 4119 | 4145 |
| 4120 RegExpParser::RegExpParser(FlatStringReader* in, | 4146 RegExpParser::RegExpParser(FlatStringReader* in, |
| 4121 Handle<String>* error, | 4147 Handle<String>* error, |
| 4122 bool multiline) | 4148 bool multiline) |
| 4123 : isolate_(Isolate::Current()), | 4149 : isolate_(Isolate::Current()), |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5085 info->is_global(), | 5111 info->is_global(), |
| 5086 info->StrictMode()); | 5112 info->StrictMode()); |
| 5087 } | 5113 } |
| 5088 } | 5114 } |
| 5089 | 5115 |
| 5090 info->SetFunction(result); | 5116 info->SetFunction(result); |
| 5091 return (result != NULL); | 5117 return (result != NULL); |
| 5092 } | 5118 } |
| 5093 | 5119 |
| 5094 } } // namespace v8::internal | 5120 } } // namespace v8::internal |
| OLD | NEW |