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 #ifndef V8_PARSING_PREPARSER_H | 5 #ifndef V8_PARSING_PREPARSER_H |
6 #define V8_PARSING_PREPARSER_H | 6 #define V8_PARSING_PREPARSER_H |
7 | 7 |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/hashmap.h" | 10 #include "src/hashmap.h" |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 | 962 |
963 PreParser(Zone* zone, Scanner* scanner, AstValueFactory* ast_value_factory, | 963 PreParser(Zone* zone, Scanner* scanner, AstValueFactory* ast_value_factory, |
964 ParserRecorder* log, uintptr_t stack_limit) | 964 ParserRecorder* log, uintptr_t stack_limit) |
965 : ParserBase<PreParserTraits>(zone, scanner, stack_limit, NULL, | 965 : ParserBase<PreParserTraits>(zone, scanner, stack_limit, NULL, |
966 ast_value_factory, log, this) {} | 966 ast_value_factory, log, this) {} |
967 | 967 |
968 // Pre-parse the program from the character stream; returns true on | 968 // Pre-parse the program from the character stream; returns true on |
969 // success (even if parsing failed, the pre-parse data successfully | 969 // success (even if parsing failed, the pre-parse data successfully |
970 // captured the syntax error), and false if a stack-overflow happened | 970 // captured the syntax error), and false if a stack-overflow happened |
971 // during parsing. | 971 // during parsing. |
972 PreParseResult PreParseProgram(int* materialized_literals = 0) { | 972 PreParseResult PreParseProgram(int* materialized_literals = 0, |
973 Scope* scope = NewScope(scope_, SCRIPT_SCOPE); | 973 bool is_module = false) { |
| 974 Scope* scope = NewScope(scope_, is_module ? MODULE_SCOPE : SCRIPT_SCOPE); |
974 PreParserFactory factory(NULL); | 975 PreParserFactory factory(NULL); |
975 FunctionState top_scope(&function_state_, &scope_, scope, kNormalFunction, | 976 FunctionState top_scope(&function_state_, &scope_, scope, kNormalFunction, |
976 &factory); | 977 &factory); |
977 bool ok = true; | 978 bool ok = true; |
978 int start_position = scanner()->peek_location().beg_pos; | 979 int start_position = scanner()->peek_location().beg_pos; |
979 ParseStatementList(Token::EOS, &ok); | 980 ParseStatementList(Token::EOS, &ok); |
980 if (stack_overflow()) return kPreParseStackOverflow; | 981 if (stack_overflow()) return kPreParseStackOverflow; |
981 if (!ok) { | 982 if (!ok) { |
982 ReportUnexpectedToken(scanner()->current_token()); | 983 ReportUnexpectedToken(scanner()->current_token()); |
983 } else if (is_strict(scope_->language_mode())) { | 984 } else if (is_strict(scope_->language_mode())) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 const PreParserFormalParameters& parameters, FunctionKind kind, | 1163 const PreParserFormalParameters& parameters, FunctionKind kind, |
1163 FunctionLiteral::FunctionType function_type, bool* ok) { | 1164 FunctionLiteral::FunctionType function_type, bool* ok) { |
1164 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, | 1165 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
1165 kind, function_type, ok); | 1166 kind, function_type, ok); |
1166 } | 1167 } |
1167 | 1168 |
1168 } // namespace internal | 1169 } // namespace internal |
1169 } // namespace v8 | 1170 } // namespace v8 |
1170 | 1171 |
1171 #endif // V8_PARSING_PREPARSER_H | 1172 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |