Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 Target** variable_; | 456 Target** variable_; |
| 457 Target* previous_; | 457 Target* previous_; |
| 458 }; | 458 }; |
| 459 | 459 |
| 460 | 460 |
| 461 // ---------------------------------------------------------------------------- | 461 // ---------------------------------------------------------------------------- |
| 462 // LexicalScope is a support class to facilitate manipulation of the | 462 // LexicalScope is a support class to facilitate manipulation of the |
| 463 // Parser's scope stack. The constructor sets the parser's top scope | 463 // Parser's scope stack. The constructor sets the parser's top scope |
| 464 // to the incoming scope, and the destructor resets it. | 464 // to the incoming scope, and the destructor resets it. |
| 465 // | 465 // |
| 466 // Additionlaly, it stores transient information used during parsing. | 466 // Additionally, it stores transient information used during parsing. |
| 467 // These scopes are not kept around after parsing or referenced by syntax | 467 // These scopes are not kept around after parsing or referenced by syntax |
| 468 // trees so they can be stack-allocated and hence used by the pre-parser. | 468 // trees so they can be stack-allocated and hence used by the pre-parser. |
| 469 | 469 |
| 470 class LexicalScope BASE_EMBEDDED { | 470 class LexicalScope BASE_EMBEDDED { |
| 471 public: | 471 public: |
| 472 LexicalScope(Parser* parser, Scope* scope, Isolate* isolate); | 472 LexicalScope(Parser* parser, Scope* scope, Isolate* isolate); |
| 473 ~LexicalScope(); | 473 ~LexicalScope(); |
| 474 | 474 |
| 475 int NextMaterializedLiteralIndex() { | 475 int NextMaterializedLiteralIndex() { |
| 476 int next_index = | 476 int next_index = |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 490 bool only_simple_this_property_assignments() { | 490 bool only_simple_this_property_assignments() { |
| 491 return only_simple_this_property_assignments_; | 491 return only_simple_this_property_assignments_; |
| 492 } | 492 } |
| 493 Handle<FixedArray> this_property_assignments() { | 493 Handle<FixedArray> this_property_assignments() { |
| 494 return this_property_assignments_; | 494 return this_property_assignments_; |
| 495 } | 495 } |
| 496 | 496 |
| 497 void AddProperty() { expected_property_count_++; } | 497 void AddProperty() { expected_property_count_++; } |
| 498 int expected_property_count() { return expected_property_count_; } | 498 int expected_property_count() { return expected_property_count_; } |
| 499 | 499 |
| 500 void AddLoop() { loop_count_++; } | |
| 501 bool ContainsLoops() const { return loop_count_ > 0; } | |
| 502 | |
| 503 private: | 500 private: |
| 504 // Captures the number of literals that need materialization in the | 501 // Captures the number of literals that need materialization in the |
| 505 // function. Includes regexp literals, and boilerplate for object | 502 // function. Includes regexp literals, and boilerplate for object |
| 506 // and array literals. | 503 // and array literals. |
| 507 int materialized_literal_count_; | 504 int materialized_literal_count_; |
| 508 | 505 |
| 509 // Properties count estimation. | 506 // Properties count estimation. |
| 510 int expected_property_count_; | 507 int expected_property_count_; |
| 511 | 508 |
| 512 // Keeps track of assignments to properties of this. Used for | 509 // Keeps track of assignments to properties of this. Used for |
| 513 // optimizing constructors. | 510 // optimizing constructors. |
| 514 bool only_simple_this_property_assignments_; | 511 bool only_simple_this_property_assignments_; |
| 515 Handle<FixedArray> this_property_assignments_; | 512 Handle<FixedArray> this_property_assignments_; |
| 516 | 513 |
| 517 // Captures the number of loops inside the scope. | |
| 518 int loop_count_; | |
| 519 | |
| 520 // Bookkeeping | 514 // Bookkeeping |
| 521 Parser* parser_; | 515 Parser* parser_; |
| 522 // Previous values | 516 // Previous values |
| 523 LexicalScope* lexical_scope_parent_; | 517 LexicalScope* lexical_scope_parent_; |
| 524 Scope* previous_scope_; | 518 Scope* previous_scope_; |
| 525 int previous_with_nesting_level_; | 519 int previous_with_nesting_level_; |
| 520 unsigned previous_ast_node_id_; | |
| 526 }; | 521 }; |
| 527 | 522 |
| 528 | 523 |
| 529 LexicalScope::LexicalScope(Parser* parser, Scope* scope, Isolate* isolate) | 524 LexicalScope::LexicalScope(Parser* parser, Scope* scope, Isolate* isolate) |
| 530 : materialized_literal_count_(0), | 525 : materialized_literal_count_(0), |
| 531 expected_property_count_(0), | 526 expected_property_count_(0), |
| 532 only_simple_this_property_assignments_(false), | 527 only_simple_this_property_assignments_(false), |
| 533 this_property_assignments_(isolate->factory()->empty_fixed_array()), | 528 this_property_assignments_(isolate->factory()->empty_fixed_array()), |
| 534 loop_count_(0), | |
| 535 parser_(parser), | 529 parser_(parser), |
| 536 lexical_scope_parent_(parser->lexical_scope_), | 530 lexical_scope_parent_(parser->lexical_scope_), |
| 537 previous_scope_(parser->top_scope_), | 531 previous_scope_(parser->top_scope_), |
| 538 previous_with_nesting_level_(parser->with_nesting_level_) { | 532 previous_with_nesting_level_(parser->with_nesting_level_), |
| 533 previous_ast_node_id_(isolate->ast_node_id()) { | |
| 539 parser->top_scope_ = scope; | 534 parser->top_scope_ = scope; |
| 540 parser->lexical_scope_ = this; | 535 parser->lexical_scope_ = this; |
| 541 parser->with_nesting_level_ = 0; | 536 parser->with_nesting_level_ = 0; |
| 537 isolate->set_ast_node_id(AstNode::kRootAstId + 1); | |
| 542 } | 538 } |
| 543 | 539 |
| 544 | 540 |
| 545 LexicalScope::~LexicalScope() { | 541 LexicalScope::~LexicalScope() { |
| 546 parser_->top_scope_->Leave(); | 542 parser_->top_scope_->Leave(); |
| 547 parser_->top_scope_ = previous_scope_; | 543 parser_->top_scope_ = previous_scope_; |
| 548 parser_->lexical_scope_ = lexical_scope_parent_; | 544 parser_->lexical_scope_ = lexical_scope_parent_; |
| 549 parser_->with_nesting_level_ = previous_with_nesting_level_; | 545 parser_->with_nesting_level_ = previous_with_nesting_level_; |
| 546 parser_->isolate()->set_ast_node_id(previous_ast_node_id_); | |
| 550 } | 547 } |
| 551 | 548 |
| 552 | 549 |
| 553 // ---------------------------------------------------------------------------- | 550 // ---------------------------------------------------------------------------- |
| 554 // The CHECK_OK macro is a convenient macro to enforce error | 551 // The CHECK_OK macro is a convenient macro to enforce error |
| 555 // handling for functions that may fail (by returning !*ok). | 552 // handling for functions that may fail (by returning !*ok). |
| 556 // | 553 // |
| 557 // CAUTION: This macro appends extra statements after a call, | 554 // CAUTION: This macro appends extra statements after a call, |
| 558 // thus it must never be used where only a single statement | 555 // thus it must never be used where only a single statement |
| 559 // is correct (e.g. an if statement branch w/o braces)! | 556 // is correct (e.g. an if statement branch w/o braces)! |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 no_name, | 654 no_name, |
| 658 top_scope_, | 655 top_scope_, |
| 659 body, | 656 body, |
| 660 lexical_scope.materialized_literal_count(), | 657 lexical_scope.materialized_literal_count(), |
| 661 lexical_scope.expected_property_count(), | 658 lexical_scope.expected_property_count(), |
| 662 lexical_scope.only_simple_this_property_assignments(), | 659 lexical_scope.only_simple_this_property_assignments(), |
| 663 lexical_scope.this_property_assignments(), | 660 lexical_scope.this_property_assignments(), |
| 664 0, | 661 0, |
| 665 0, | 662 0, |
| 666 source->length(), | 663 source->length(), |
| 667 false, | 664 false); |
| 668 lexical_scope.ContainsLoops()); | |
| 669 } else if (stack_overflow_) { | 665 } else if (stack_overflow_) { |
| 670 isolate()->StackOverflow(); | 666 isolate()->StackOverflow(); |
| 671 } | 667 } |
| 672 } | 668 } |
| 673 | 669 |
| 674 // Make sure the target stack is empty. | 670 // Make sure the target stack is empty. |
| 675 ASSERT(target_stack_ == NULL); | 671 ASSERT(target_stack_ == NULL); |
| 676 | 672 |
| 677 // If there was a syntax error we have to get rid of the AST | 673 // If there was a syntax error we have to get rid of the AST |
| 678 // and it is not safe to do so before the scope has been deleted. | 674 // and it is not safe to do so before the scope has been deleted. |
| (...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2156 | 2152 |
| 2157 return result; | 2153 return result; |
| 2158 } | 2154 } |
| 2159 | 2155 |
| 2160 | 2156 |
| 2161 DoWhileStatement* Parser::ParseDoWhileStatement(ZoneStringList* labels, | 2157 DoWhileStatement* Parser::ParseDoWhileStatement(ZoneStringList* labels, |
| 2162 bool* ok) { | 2158 bool* ok) { |
| 2163 // DoStatement :: | 2159 // DoStatement :: |
| 2164 // 'do' Statement 'while' '(' Expression ')' ';' | 2160 // 'do' Statement 'while' '(' Expression ')' ';' |
| 2165 | 2161 |
| 2166 lexical_scope_->AddLoop(); | |
| 2167 DoWhileStatement* loop = new(zone()) DoWhileStatement(labels); | 2162 DoWhileStatement* loop = new(zone()) DoWhileStatement(labels); |
| 2168 Target target(&this->target_stack_, loop); | 2163 Target target(&this->target_stack_, loop); |
| 2169 | 2164 |
| 2170 Expect(Token::DO, CHECK_OK); | 2165 Expect(Token::DO, CHECK_OK); |
| 2171 Statement* body = ParseStatement(NULL, CHECK_OK); | 2166 Statement* body = ParseStatement(NULL, CHECK_OK); |
| 2172 Expect(Token::WHILE, CHECK_OK); | 2167 Expect(Token::WHILE, CHECK_OK); |
| 2173 Expect(Token::LPAREN, CHECK_OK); | 2168 Expect(Token::LPAREN, CHECK_OK); |
| 2174 | 2169 |
| 2175 if (loop != NULL) { | 2170 if (loop != NULL) { |
| 2176 int position = scanner().location().beg_pos; | 2171 int position = scanner().location().beg_pos; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2189 | 2184 |
| 2190 if (loop != NULL) loop->Initialize(cond, body); | 2185 if (loop != NULL) loop->Initialize(cond, body); |
| 2191 return loop; | 2186 return loop; |
| 2192 } | 2187 } |
| 2193 | 2188 |
| 2194 | 2189 |
| 2195 WhileStatement* Parser::ParseWhileStatement(ZoneStringList* labels, bool* ok) { | 2190 WhileStatement* Parser::ParseWhileStatement(ZoneStringList* labels, bool* ok) { |
| 2196 // WhileStatement :: | 2191 // WhileStatement :: |
| 2197 // 'while' '(' Expression ')' Statement | 2192 // 'while' '(' Expression ')' Statement |
| 2198 | 2193 |
| 2199 lexical_scope_->AddLoop(); | |
| 2200 WhileStatement* loop = new(zone()) WhileStatement(labels); | 2194 WhileStatement* loop = new(zone()) WhileStatement(labels); |
| 2201 Target target(&this->target_stack_, loop); | 2195 Target target(&this->target_stack_, loop); |
| 2202 | 2196 |
| 2203 Expect(Token::WHILE, CHECK_OK); | 2197 Expect(Token::WHILE, CHECK_OK); |
| 2204 Expect(Token::LPAREN, CHECK_OK); | 2198 Expect(Token::LPAREN, CHECK_OK); |
| 2205 Expression* cond = ParseExpression(true, CHECK_OK); | 2199 Expression* cond = ParseExpression(true, CHECK_OK); |
| 2206 if (cond != NULL) cond->set_is_loop_condition(true); | 2200 if (cond != NULL) cond->set_is_loop_condition(true); |
| 2207 Expect(Token::RPAREN, CHECK_OK); | 2201 Expect(Token::RPAREN, CHECK_OK); |
| 2208 Statement* body = ParseStatement(NULL, CHECK_OK); | 2202 Statement* body = ParseStatement(NULL, CHECK_OK); |
| 2209 | 2203 |
| 2210 if (loop != NULL) loop->Initialize(cond, body); | 2204 if (loop != NULL) loop->Initialize(cond, body); |
| 2211 return loop; | 2205 return loop; |
| 2212 } | 2206 } |
| 2213 | 2207 |
| 2214 | 2208 |
| 2215 Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { | 2209 Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
| 2216 // ForStatement :: | 2210 // ForStatement :: |
| 2217 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement | 2211 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement |
| 2218 | 2212 |
| 2219 lexical_scope_->AddLoop(); | |
| 2220 Statement* init = NULL; | 2213 Statement* init = NULL; |
| 2221 | 2214 |
| 2222 Expect(Token::FOR, CHECK_OK); | 2215 Expect(Token::FOR, CHECK_OK); |
| 2223 Expect(Token::LPAREN, CHECK_OK); | 2216 Expect(Token::LPAREN, CHECK_OK); |
| 2224 if (peek() != Token::SEMICOLON) { | 2217 if (peek() != Token::SEMICOLON) { |
| 2225 if (peek() == Token::VAR || peek() == Token::CONST) { | 2218 if (peek() == Token::VAR || peek() == Token::CONST) { |
| 2226 Expression* each = NULL; | 2219 Expression* each = NULL; |
| 2227 Block* variable_statement = | 2220 Block* variable_statement = |
| 2228 ParseVariableDeclarations(false, &each, CHECK_OK); | 2221 ParseVariableDeclarations(false, &each, CHECK_OK); |
| 2229 if (peek() == Token::IN && each != NULL) { | 2222 if (peek() == Token::IN && each != NULL) { |
| (...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3525 // that case, we don't have a function name (it's empty). | 3518 // that case, we don't have a function name (it's empty). |
| 3526 Handle<String> name = | 3519 Handle<String> name = |
| 3527 is_named ? var_name : isolate()->factory()->empty_symbol(); | 3520 is_named ? var_name : isolate()->factory()->empty_symbol(); |
| 3528 // The function name, if any. | 3521 // The function name, if any. |
| 3529 Handle<String> function_name = isolate()->factory()->empty_symbol(); | 3522 Handle<String> function_name = isolate()->factory()->empty_symbol(); |
| 3530 if (is_named && (type == EXPRESSION || type == NESTED)) { | 3523 if (is_named && (type == EXPRESSION || type == NESTED)) { |
| 3531 function_name = name; | 3524 function_name = name; |
| 3532 } | 3525 } |
| 3533 | 3526 |
| 3534 int num_parameters = 0; | 3527 int num_parameters = 0; |
| 3528 Scope* scope = NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with()); | |
| 3529 ZoneList<Statement*>* body = new ZoneList<Statement*>(8); | |
| 3530 int materialized_literal_count; | |
| 3531 int expected_property_count; | |
| 3532 int start_pos; | |
| 3533 int end_pos; | |
| 3534 bool only_simple_this_property_assignments; | |
| 3535 Handle<FixedArray> this_property_assignments; | |
| 3535 // Parse function body. | 3536 // Parse function body. |
| 3536 { Scope* scope = | 3537 { LexicalScope lexical_scope(this, scope, isolate()); |
| 3537 NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with()); | |
| 3538 LexicalScope lexical_scope(this, scope, isolate()); | |
| 3539 top_scope_->SetScopeName(name); | 3538 top_scope_->SetScopeName(name); |
| 3540 | 3539 |
| 3541 // FormalParameterList :: | 3540 // FormalParameterList :: |
| 3542 // '(' (Identifier)*[','] ')' | 3541 // '(' (Identifier)*[','] ')' |
| 3543 Expect(Token::LPAREN, CHECK_OK); | 3542 Expect(Token::LPAREN, CHECK_OK); |
| 3544 int start_pos = scanner().location().beg_pos; | 3543 start_pos = scanner().location().beg_pos; |
| 3545 Scanner::Location name_loc = Scanner::NoLocation(); | 3544 Scanner::Location name_loc = Scanner::NoLocation(); |
| 3546 Scanner::Location dupe_loc = Scanner::NoLocation(); | 3545 Scanner::Location dupe_loc = Scanner::NoLocation(); |
| 3547 Scanner::Location reserved_loc = Scanner::NoLocation(); | 3546 Scanner::Location reserved_loc = Scanner::NoLocation(); |
| 3548 | 3547 |
| 3549 bool done = (peek() == Token::RPAREN); | 3548 bool done = (peek() == Token::RPAREN); |
| 3550 while (!done) { | 3549 while (!done) { |
| 3551 bool is_reserved = false; | 3550 bool is_reserved = false; |
| 3552 Handle<String> param_name = | 3551 Handle<String> param_name = |
| 3553 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); | 3552 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); |
| 3554 | 3553 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 3571 Vector<const char*>::empty()); | 3570 Vector<const char*>::empty()); |
| 3572 *ok = false; | 3571 *ok = false; |
| 3573 return NULL; | 3572 return NULL; |
| 3574 } | 3573 } |
| 3575 done = (peek() == Token::RPAREN); | 3574 done = (peek() == Token::RPAREN); |
| 3576 if (!done) Expect(Token::COMMA, CHECK_OK); | 3575 if (!done) Expect(Token::COMMA, CHECK_OK); |
| 3577 } | 3576 } |
| 3578 Expect(Token::RPAREN, CHECK_OK); | 3577 Expect(Token::RPAREN, CHECK_OK); |
| 3579 | 3578 |
| 3580 Expect(Token::LBRACE, CHECK_OK); | 3579 Expect(Token::LBRACE, CHECK_OK); |
| 3581 ZoneList<Statement*>* body = new ZoneList<Statement*>(8); | |
| 3582 | 3580 |
| 3583 // If we have a named function expression, we add a local variable | 3581 // If we have a named function expression, we add a local variable |
| 3584 // declaration to the body of the function with the name of the | 3582 // declaration to the body of the function with the name of the |
| 3585 // function and let it refer to the function itself (closure). | 3583 // function and let it refer to the function itself (closure). |
| 3586 // NOTE: We create a proxy and resolve it here so that in the | 3584 // NOTE: We create a proxy and resolve it here so that in the |
| 3587 // future we can change the AST to only refer to VariableProxies | 3585 // future we can change the AST to only refer to VariableProxies |
| 3588 // instead of Variables and Proxis as is the case now. | 3586 // instead of Variables and Proxis as is the case now. |
| 3589 if (!function_name.is_null() && function_name->length() > 0) { | 3587 if (!function_name.is_null() && function_name->length() > 0) { |
| 3590 Variable* fvar = top_scope_->DeclareFunctionVar(function_name); | 3588 Variable* fvar = top_scope_->DeclareFunctionVar(function_name); |
| 3591 VariableProxy* fproxy = | 3589 VariableProxy* fproxy = |
| 3592 top_scope_->NewUnresolved(function_name, inside_with()); | 3590 top_scope_->NewUnresolved(function_name, inside_with()); |
| 3593 fproxy->BindTo(fvar); | 3591 fproxy->BindTo(fvar); |
| 3594 body->Add(new(zone()) ExpressionStatement( | 3592 body->Add(new(zone()) ExpressionStatement( |
| 3595 new(zone()) Assignment(Token::INIT_CONST, fproxy, | 3593 new(zone()) Assignment(Token::INIT_CONST, fproxy, |
| 3596 new(zone()) ThisFunction(), | 3594 new(zone()) ThisFunction(), |
| 3597 RelocInfo::kNoPosition))); | 3595 RelocInfo::kNoPosition))); |
| 3598 } | 3596 } |
| 3599 | 3597 |
| 3600 // Determine if the function will be lazily compiled. The mode can | 3598 // Determine if the function will be lazily compiled. The mode can |
| 3601 // only be PARSE_LAZILY if the --lazy flag is true. | 3599 // only be PARSE_LAZILY if the --lazy flag is true. |
| 3602 bool is_lazily_compiled = (mode() == PARSE_LAZILY && | 3600 bool is_lazily_compiled = (mode() == PARSE_LAZILY && |
| 3603 top_scope_->outer_scope()->is_global_scope() && | 3601 top_scope_->outer_scope()->is_global_scope() && |
| 3604 top_scope_->HasTrivialOuterContext() && | 3602 top_scope_->HasTrivialOuterContext() && |
| 3605 !parenthesized_function_); | 3603 !parenthesized_function_); |
| 3606 parenthesized_function_ = false; // The bit was set for this function only. | 3604 parenthesized_function_ = false; // The bit was set for this function only. |
| 3607 | 3605 |
| 3608 int function_block_pos = scanner().location().beg_pos; | 3606 int function_block_pos = scanner().location().beg_pos; |
| 3609 int materialized_literal_count; | |
| 3610 int expected_property_count; | |
| 3611 int end_pos; | |
| 3612 bool only_simple_this_property_assignments; | |
| 3613 Handle<FixedArray> this_property_assignments; | |
| 3614 if (is_lazily_compiled && pre_data() != NULL) { | 3607 if (is_lazily_compiled && pre_data() != NULL) { |
| 3615 FunctionEntry entry = pre_data()->GetFunctionEntry(function_block_pos); | 3608 FunctionEntry entry = pre_data()->GetFunctionEntry(function_block_pos); |
| 3616 if (!entry.is_valid()) { | 3609 if (!entry.is_valid()) { |
| 3617 ReportInvalidPreparseData(name, CHECK_OK); | 3610 ReportInvalidPreparseData(name, CHECK_OK); |
| 3618 } | 3611 } |
| 3619 end_pos = entry.end_pos(); | 3612 end_pos = entry.end_pos(); |
| 3620 if (end_pos <= function_block_pos) { | 3613 if (end_pos <= function_block_pos) { |
| 3621 // End position greater than end of stream is safe, and hard to check. | 3614 // End position greater than end of stream is safe, and hard to check. |
| 3622 ReportInvalidPreparseData(name, CHECK_OK); | 3615 ReportInvalidPreparseData(name, CHECK_OK); |
| 3623 } | 3616 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3678 return NULL; | 3671 return NULL; |
| 3679 } | 3672 } |
| 3680 if (reserved_loc.IsValid()) { | 3673 if (reserved_loc.IsValid()) { |
| 3681 ReportMessageAt(reserved_loc, "strict_reserved_word", | 3674 ReportMessageAt(reserved_loc, "strict_reserved_word", |
| 3682 Vector<const char*>::empty()); | 3675 Vector<const char*>::empty()); |
| 3683 *ok = false; | 3676 *ok = false; |
| 3684 return NULL; | 3677 return NULL; |
| 3685 } | 3678 } |
| 3686 CheckOctalLiteral(start_pos, end_pos, CHECK_OK); | 3679 CheckOctalLiteral(start_pos, end_pos, CHECK_OK); |
| 3687 } | 3680 } |
| 3681 } | |
| 3688 | 3682 |
| 3689 FunctionLiteral* function_literal = | 3683 FunctionLiteral* function_literal = new(zone()) FunctionLiteral( |
|
Kevin Millikin (Chromium)
2011/04/07 13:42:51
I sort of prefer breaking at the lowest precedence
| |
| 3690 new(zone()) FunctionLiteral(name, | 3684 name, |
| 3691 top_scope_, | 3685 scope, |
| 3692 body, | 3686 body, |
| 3693 materialized_literal_count, | 3687 materialized_literal_count, |
| 3694 expected_property_count, | 3688 expected_property_count, |
| 3695 only_simple_this_property_assignments, | 3689 only_simple_this_property_assignments, |
| 3696 this_property_assignments, | 3690 this_property_assignments, |
| 3697 num_parameters, | 3691 num_parameters, |
| 3698 start_pos, | 3692 start_pos, |
| 3699 end_pos, | 3693 end_pos, |
| 3700 function_name->length() > 0, | 3694 function_name->length() > 0); |
| 3701 lexical_scope.ContainsLoops()); | 3695 function_literal->set_function_token_position(function_token_position); |
| 3702 function_literal->set_function_token_position(function_token_position); | |
| 3703 | 3696 |
| 3704 if (fni_ != NULL && !is_named) fni_->AddFunction(function_literal); | 3697 if (fni_ != NULL && !is_named) fni_->AddFunction(function_literal); |
| 3705 return function_literal; | 3698 return function_literal; |
| 3706 } | |
| 3707 } | 3699 } |
| 3708 | 3700 |
| 3709 | 3701 |
| 3710 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 3702 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
| 3711 // CallRuntime :: | 3703 // CallRuntime :: |
| 3712 // '%' Identifier Arguments | 3704 // '%' Identifier Arguments |
| 3713 | 3705 |
| 3714 Expect(Token::MOD, CHECK_OK); | 3706 Expect(Token::MOD, CHECK_OK); |
| 3715 Handle<String> name = ParseIdentifier(CHECK_OK); | 3707 Handle<String> name = ParseIdentifier(CHECK_OK); |
| 3716 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); | 3708 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); |
| (...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5159 info->is_global(), | 5151 info->is_global(), |
| 5160 info->StrictMode()); | 5152 info->StrictMode()); |
| 5161 } | 5153 } |
| 5162 } | 5154 } |
| 5163 | 5155 |
| 5164 info->SetFunction(result); | 5156 info->SetFunction(result); |
| 5165 return (result != NULL); | 5157 return (result != NULL); |
| 5166 } | 5158 } |
| 5167 | 5159 |
| 5168 } } // namespace v8::internal | 5160 } } // namespace v8::internal |
| OLD | NEW |