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 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 int pos) { | 1142 int pos) { |
1143 return PreParserExpression::Default(); | 1143 return PreParserExpression::Default(); |
1144 } | 1144 } |
1145 | 1145 |
1146 PreParserStatementList PreParser::ParseEagerFunctionBody( | 1146 PreParserStatementList PreParser::ParseEagerFunctionBody( |
1147 PreParserIdentifier function_name, int pos, | 1147 PreParserIdentifier function_name, int pos, |
1148 const PreParserFormalParameters& parameters, FunctionKind kind, | 1148 const PreParserFormalParameters& parameters, FunctionKind kind, |
1149 FunctionLiteral::FunctionType function_type, bool* ok) { | 1149 FunctionLiteral::FunctionType function_type, bool* ok) { |
1150 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 1150 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
1151 | 1151 |
1152 ParseStatementList(Token::RBRACE, ok); | 1152 Scope* inner_scope = scope_; |
1153 if (!*ok) return PreParserStatementList(); | 1153 if (!parameters.is_simple) inner_scope = NewScope(scope_, BLOCK_SCOPE); |
| 1154 |
| 1155 { |
| 1156 BlockState block_state(&scope_, inner_scope); |
| 1157 ParseStatementList(Token::RBRACE, ok); |
| 1158 if (!*ok) return PreParserStatementList(); |
| 1159 } |
1154 | 1160 |
1155 Expect(Token::RBRACE, ok); | 1161 Expect(Token::RBRACE, ok); |
1156 return PreParserStatementList(); | 1162 return PreParserStatementList(); |
1157 } | 1163 } |
1158 | 1164 |
1159 | 1165 |
1160 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( | 1166 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( |
1161 PreParserIdentifier function_name, int pos, | 1167 PreParserIdentifier function_name, int pos, |
1162 const PreParserFormalParameters& parameters, FunctionKind kind, | 1168 const PreParserFormalParameters& parameters, FunctionKind kind, |
1163 FunctionLiteral::FunctionType function_type, bool* ok) { | 1169 FunctionLiteral::FunctionType function_type, bool* ok) { |
1164 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, | 1170 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
1165 kind, function_type, ok); | 1171 kind, function_type, ok); |
1166 } | 1172 } |
1167 | 1173 |
1168 } // namespace internal | 1174 } // namespace internal |
1169 } // namespace v8 | 1175 } // namespace v8 |
1170 | 1176 |
1171 #endif // V8_PARSING_PREPARSER_H | 1177 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |