| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 info->script_scope()->DeclareDynamicGlobal( | 997 info->script_scope()->DeclareDynamicGlobal( |
| 998 ast_value_factory()->this_string(), Variable::THIS); | 998 ast_value_factory()->this_string(), Variable::THIS); |
| 999 } | 999 } |
| 1000 DCHECK(outer); | 1000 DCHECK(outer); |
| 1001 if (info->is_eval()) { | 1001 if (info->is_eval()) { |
| 1002 if (!outer->is_script_scope() || is_strict(info->language_mode())) { | 1002 if (!outer->is_script_scope() || is_strict(info->language_mode())) { |
| 1003 parsing_mode = PARSE_EAGERLY; | 1003 parsing_mode = PARSE_EAGERLY; |
| 1004 } | 1004 } |
| 1005 outer = NewEvalScope(outer); | 1005 outer = NewEvalScope(outer); |
| 1006 } else if (info->is_module()) { | 1006 } else if (info->is_module()) { |
| 1007 outer = NewModuleScope(outer); | 1007 DCHECK_EQ(outer, info->script_scope()); |
| 1008 outer = NewModuleScope(info->script_scope()); |
| 1008 } | 1009 } |
| 1009 | 1010 |
| 1010 DeclarationScope* scope = outer->AsDeclarationScope(); | 1011 DeclarationScope* scope = outer->AsDeclarationScope(); |
| 1011 | 1012 |
| 1012 scope->set_start_position(0); | 1013 scope->set_start_position(0); |
| 1013 | 1014 |
| 1014 // Enter 'scope' with the given parsing mode. | 1015 // Enter 'scope' with the given parsing mode. |
| 1015 ParsingModeScope parsing_mode_scope(this, parsing_mode); | 1016 ParsingModeScope parsing_mode_scope(this, parsing_mode); |
| 1016 FunctionState function_state(&function_state_, &scope_state_, scope, | 1017 FunctionState function_state(&function_state_, &scope_state_, scope, |
| 1017 kNormalFunction); | 1018 kNormalFunction); |
| 1018 | 1019 |
| 1019 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); | 1020 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); |
| 1020 bool ok = true; | 1021 bool ok = true; |
| 1021 int beg_pos = scanner()->location().beg_pos; | 1022 int beg_pos = scanner()->location().beg_pos; |
| 1022 parsing_module_ = info->is_module(); | 1023 parsing_module_ = info->is_module(); |
| 1023 if (parsing_module_) { | 1024 if (parsing_module_) { |
| 1024 ParseModuleItemList(body, &ok); | 1025 ParseModuleItemList(body, &ok); |
| 1025 ok = ok && | 1026 ok = ok && |
| 1026 module()->Validate(this->scope()->AsDeclarationScope(), | 1027 module()->Validate(this->scope()->AsModuleScope(), |
| 1027 &pending_error_handler_, zone()); | 1028 &pending_error_handler_, zone()); |
| 1028 } else { | 1029 } else { |
| 1029 // Don't count the mode in the use counters--give the program a chance | 1030 // Don't count the mode in the use counters--give the program a chance |
| 1030 // to enable script-wide strict mode below. | 1031 // to enable script-wide strict mode below. |
| 1031 this->scope()->SetLanguageMode(info->language_mode()); | 1032 this->scope()->SetLanguageMode(info->language_mode()); |
| 1032 ParseStatementList(body, Token::EOS, &ok); | 1033 ParseStatementList(body, Token::EOS, &ok); |
| 1033 } | 1034 } |
| 1034 | 1035 |
| 1035 // The parser will peek but not consume EOS. Our scope logically goes all | 1036 // The parser will peek but not consume EOS. Our scope logically goes all |
| 1036 // the way to the EOS, though. | 1037 // the way to the EOS, though. |
| (...skipping 6050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7087 node->Print(Isolate::Current()); | 7088 node->Print(Isolate::Current()); |
| 7088 } | 7089 } |
| 7089 #endif // DEBUG | 7090 #endif // DEBUG |
| 7090 | 7091 |
| 7091 #undef CHECK_OK | 7092 #undef CHECK_OK |
| 7092 #undef CHECK_OK_VOID | 7093 #undef CHECK_OK_VOID |
| 7093 #undef CHECK_FAILED | 7094 #undef CHECK_FAILED |
| 7094 | 7095 |
| 7095 } // namespace internal | 7096 } // namespace internal |
| 7096 } // namespace v8 | 7097 } // namespace v8 |
| OLD | NEW |