OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 PreParserIdentifier symbol = GetSymbolHelper(scanner()); | 77 PreParserIdentifier symbol = GetSymbolHelper(scanner()); |
78 if (track_unresolved_variables_) { | 78 if (track_unresolved_variables_) { |
79 const AstRawString* result = scanner()->CurrentSymbol(ast_value_factory()); | 79 const AstRawString* result = scanner()->CurrentSymbol(ast_value_factory()); |
80 DCHECK_NOT_NULL(result); | 80 DCHECK_NOT_NULL(result); |
81 symbol.string_ = result; | 81 symbol.string_ = result; |
82 } | 82 } |
83 return symbol; | 83 return symbol; |
84 } | 84 } |
85 | 85 |
86 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 86 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
87 DeclarationScope* function_scope, bool parsing_module, ParserRecorder* log, | 87 FunctionKind kind, DeclarationScope* function_scope, bool parsing_module, |
88 bool is_inner_function, bool may_abort, int* use_counts) { | 88 ParserRecorder* log, bool is_inner_function, bool may_abort, |
89 DCHECK_EQ(FUNCTION_SCOPE, function_scope->scope_type()); | 89 int* use_counts) { |
90 parsing_module_ = parsing_module; | 90 parsing_module_ = parsing_module; |
91 log_ = log; | 91 log_ = log; |
92 use_counts_ = use_counts; | 92 use_counts_ = use_counts; |
93 DCHECK(!track_unresolved_variables_); | 93 DCHECK(!track_unresolved_variables_); |
94 track_unresolved_variables_ = is_inner_function; | 94 track_unresolved_variables_ = is_inner_function; |
95 | 95 |
96 // The caller passes the function_scope which is not yet inserted into the | 96 // The caller passes the function_scope which is not yet inserted into the |
97 // scope_state_. All scopes above the function_scope are ignored by the | 97 // scope_state_. All scopes above the function_scope are ignored by the |
98 // PreParser. | 98 // PreParser. |
99 DCHECK_NULL(scope_state_); | 99 DCHECK_NULL(scope_state_); |
100 FunctionState function_state(&function_state_, &scope_state_, function_scope, | 100 FunctionState function_state(&function_state_, &scope_state_, function_scope, |
101 function_scope->function_kind()); | 101 kind); |
102 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 102 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
103 bool ok = true; | 103 bool ok = true; |
104 int start_position = peek_position(); | 104 int start_position = peek_position(); |
105 LazyParsingResult result = ParseLazyFunctionLiteralBody(may_abort, &ok); | 105 LazyParsingResult result = ParseLazyFunctionLiteralBody(may_abort, &ok); |
106 use_counts_ = nullptr; | 106 use_counts_ = nullptr; |
107 track_unresolved_variables_ = false; | 107 track_unresolved_variables_ = false; |
108 if (result == kLazyParsingAborted) { | 108 if (result == kLazyParsingAborted) { |
109 return kPreParseAbort; | 109 return kPreParseAbort; |
110 } else if (stack_overflow()) { | 110 } else if (stack_overflow()) { |
111 return kPreParseStackOverflow; | 111 return kPreParseStackOverflow; |
112 } else if (!ok) { | 112 } else if (!ok) { |
113 ReportUnexpectedToken(scanner()->current_token()); | 113 ReportUnexpectedToken(scanner()->current_token()); |
114 } else { | 114 } else { |
115 DCHECK_EQ(Token::RBRACE, scanner()->peek()); | 115 DCHECK_EQ(Token::RBRACE, scanner()->peek()); |
116 if (is_strict(function_scope->language_mode())) { | 116 if (is_strict(scope()->language_mode())) { |
117 int end_pos = scanner()->location().end_pos; | 117 int end_pos = scanner()->location().end_pos; |
118 CheckStrictOctalLiteral(start_position, end_pos, &ok); | 118 CheckStrictOctalLiteral(start_position, end_pos, &ok); |
119 CheckDecimalLiteralWithLeadingZero(start_position, end_pos); | 119 CheckDecimalLiteralWithLeadingZero(start_position, end_pos); |
120 } | 120 } |
121 } | 121 } |
122 return kPreParseSuccess; | 122 return kPreParseSuccess; |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 // Preparsing checks a JavaScript program and emits preparse-data that helps | 126 // Preparsing checks a JavaScript program and emits preparse-data that helps |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 369 } |
370 return PreParserExpression::FromIdentifier(name); | 370 return PreParserExpression::FromIdentifier(name); |
371 } | 371 } |
372 | 372 |
373 #undef CHECK_OK | 373 #undef CHECK_OK |
374 #undef CHECK_OK_CUSTOM | 374 #undef CHECK_OK_CUSTOM |
375 | 375 |
376 | 376 |
377 } // namespace internal | 377 } // namespace internal |
378 } // namespace v8 | 378 } // namespace v8 |
OLD | NEW |