| 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/parser.h" | 5 #include "src/parser.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/ast-literal-reindexer.h" | 9 #include "src/ast-literal-reindexer.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| 11 #include "src/base/platform/platform.h" | 11 #include "src/base/platform/platform.h" |
| 12 #include "src/bootstrapper.h" | 12 #include "src/bootstrapper.h" |
| 13 #include "src/char-predicates-inl.h" | 13 #include "src/char-predicates-inl.h" |
| 14 #include "src/codegen.h" | 14 #include "src/codegen.h" |
| 15 #include "src/compiler.h" | 15 #include "src/compiler.h" |
| 16 #include "src/messages.h" | 16 #include "src/messages.h" |
| 17 #include "src/parameter-initializer-rewriter.h" |
| 17 #include "src/preparser.h" | 18 #include "src/preparser.h" |
| 18 #include "src/runtime/runtime.h" | 19 #include "src/runtime/runtime.h" |
| 19 #include "src/scanner-character-streams.h" | 20 #include "src/scanner-character-streams.h" |
| 20 #include "src/scopeinfo.h" | 21 #include "src/scopeinfo.h" |
| 21 #include "src/string-stream.h" | 22 #include "src/string-stream.h" |
| 22 | 23 |
| 23 namespace v8 { | 24 namespace v8 { |
| 24 namespace internal { | 25 namespace internal { |
| 25 | 26 |
| 26 ScriptData::ScriptData(const byte* data, int length) | 27 ScriptData::ScriptData(const byte* data, int length) |
| (...skipping 4013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4040 // parse-time side-effect for parameters that are single-names (not | 4041 // parse-time side-effect for parameters that are single-names (not |
| 4041 // patterns; for patterns that happens uniformly in | 4042 // patterns; for patterns that happens uniformly in |
| 4042 // PatternRewriter::VisitVariableProxy). | 4043 // PatternRewriter::VisitVariableProxy). |
| 4043 parser_->scope_->RemoveUnresolved(expr->AsVariableProxy()); | 4044 parser_->scope_->RemoveUnresolved(expr->AsVariableProxy()); |
| 4044 } else if (expr->IsAssignment()) { | 4045 } else if (expr->IsAssignment()) { |
| 4045 Assignment* assignment = expr->AsAssignment(); | 4046 Assignment* assignment = expr->AsAssignment(); |
| 4046 DCHECK(parser_->allow_harmony_default_parameters()); | 4047 DCHECK(parser_->allow_harmony_default_parameters()); |
| 4047 DCHECK(!assignment->is_compound()); | 4048 DCHECK(!assignment->is_compound()); |
| 4048 initializer = assignment->value(); | 4049 initializer = assignment->value(); |
| 4049 expr = assignment->target(); | 4050 expr = assignment->target(); |
| 4051 |
| 4052 // TODO(adamk): Only call this if necessary. |
| 4053 RewriteParameterInitializerScope(parser_->stack_limit(), initializer, |
| 4054 parser_->scope_, parameters->scope); |
| 4050 } | 4055 } |
| 4051 | 4056 |
| 4052 AddFormalParameter(parameters, expr, initializer, is_rest); | 4057 AddFormalParameter(parameters, expr, initializer, is_rest); |
| 4053 } | 4058 } |
| 4054 | 4059 |
| 4055 | 4060 |
| 4056 void ParserTraits::ParseArrowFunctionFormalParameterList( | 4061 void ParserTraits::ParseArrowFunctionFormalParameterList( |
| 4057 ParserFormalParameters* parameters, Expression* expr, | 4062 ParserFormalParameters* parameters, Expression* expr, |
| 4058 const Scanner::Location& params_loc, | 4063 const Scanner::Location& params_loc, |
| 4059 Scanner::Location* duplicate_loc, bool* ok) { | 4064 Scanner::Location* duplicate_loc, bool* ok) { |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4896 } | 4901 } |
| 4897 | 4902 |
| 4898 block_scope->set_end_position(end_pos); | 4903 block_scope->set_end_position(end_pos); |
| 4899 | 4904 |
| 4900 if (name != NULL) { | 4905 if (name != NULL) { |
| 4901 DCHECK_NOT_NULL(proxy); | 4906 DCHECK_NOT_NULL(proxy); |
| 4902 proxy->var()->set_initializer_position(end_pos); | 4907 proxy->var()->set_initializer_position(end_pos); |
| 4903 } else { | 4908 } else { |
| 4904 // Unnamed classes should not have scopes (the scope will be empty). | 4909 // Unnamed classes should not have scopes (the scope will be empty). |
| 4905 DCHECK_EQ(block_scope->num_var_or_const(), 0); | 4910 DCHECK_EQ(block_scope->num_var_or_const(), 0); |
| 4906 block_scope = nullptr; | 4911 block_scope = block_scope->FinalizeBlockScope(); |
| 4907 } | 4912 } |
| 4908 | 4913 |
| 4909 return factory()->NewClassLiteral(name, block_scope, proxy, extends, | 4914 return factory()->NewClassLiteral(name, block_scope, proxy, extends, |
| 4910 constructor, properties, pos, end_pos); | 4915 constructor, properties, pos, end_pos); |
| 4911 } | 4916 } |
| 4912 | 4917 |
| 4913 | 4918 |
| 4914 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 4919 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
| 4915 // CallRuntime :: | 4920 // CallRuntime :: |
| 4916 // '%' Identifier Arguments | 4921 // '%' Identifier Arguments |
| (...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6363 | 6368 |
| 6364 Expression* Parser::SpreadCallNew(Expression* function, | 6369 Expression* Parser::SpreadCallNew(Expression* function, |
| 6365 ZoneList<v8::internal::Expression*>* args, | 6370 ZoneList<v8::internal::Expression*>* args, |
| 6366 int pos) { | 6371 int pos) { |
| 6367 args->InsertAt(0, function, zone()); | 6372 args->InsertAt(0, function, zone()); |
| 6368 | 6373 |
| 6369 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); | 6374 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); |
| 6370 } | 6375 } |
| 6371 } // namespace internal | 6376 } // namespace internal |
| 6372 } // namespace v8 | 6377 } // namespace v8 |
| OLD | NEW |