Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index 6e1838170a5dcf1ff4e19a04234022efd1a42df6..0253ed640d4bf59f0e57a99ae4f7320dd7a53a95 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -614,11 +614,6 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
| ASSERT(target_stack_ == NULL); |
| if (pre_data_ != NULL) pre_data_->Initialize(); |
| - // Compute the parsing mode. |
| - Mode mode = (FLAG_lazy && allow_lazy_) ? PARSE_LAZILY : PARSE_EAGERLY; |
| - if (allow_natives_syntax_ || extension_ != NULL) mode = PARSE_EAGERLY; |
| - ParsingModeScope parsing_mode(this, mode); |
| - |
| Handle<String> no_name = isolate()->factory()->empty_symbol(); |
| FunctionLiteral* result = NULL; |
| @@ -637,6 +632,12 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
| scope->set_start_position(0); |
| scope->set_end_position(source->length()); |
| + // Compute the parsing mode. |
| + Mode mode = (FLAG_lazy && allow_lazy_) ? PARSE_LAZILY : PARSE_EAGERLY; |
| + if (allow_natives_syntax_ || extension_ != NULL || scope->is_eval_scope()) |
| + mode = PARSE_EAGERLY; |
|
Michael Starzinger
2012/12/07 09:50:17
Curly braces around body.
rossberg
2012/12/07 10:23:33
Done.
|
| + ParsingModeScope parsing_mode(this, mode); |
| + |
| FunctionState function_state(this, scope, isolate()); // Enters 'scope'. |
| top_scope_->SetLanguageMode(info->language_mode()); |
| ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); |
| @@ -1059,12 +1060,14 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor, |
| // as specified in ES5 10.4.2(3). The correct fix would be to always |
| // add this scope in DoParseProgram(), but that requires adaptations |
| // all over the code base, so we go with a quick-fix for now. |
| + // In the same manner, we have to patch the parsing mode. |
| if (is_eval && !top_scope_->is_eval_scope()) { |
| ASSERT(top_scope_->is_global_scope()); |
| Scope* scope = NewScope(top_scope_, EVAL_SCOPE); |
| scope->set_start_position(top_scope_->start_position()); |
| scope->set_end_position(top_scope_->end_position()); |
| top_scope_ = scope; |
| + mode_ = PARSE_EAGERLY; |
| } |
| // TODO(ES6): Fix entering extended mode, once it is specified. |
| top_scope_->SetLanguageMode(FLAG_harmony_scoping |