| 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 "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
| 10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 ZoneList<Statement*>* body = NULL; | 198 ZoneList<Statement*>* body = NULL; |
| 199 | 199 |
| 200 { | 200 { |
| 201 AstNodeFactory function_factory(ast_value_factory()); | 201 AstNodeFactory function_factory(ast_value_factory()); |
| 202 FunctionState function_state(&function_state_, &scope_, function_scope, | 202 FunctionState function_state(&function_state_, &scope_, function_scope, |
| 203 kind, &function_factory); | 203 kind, &function_factory); |
| 204 | 204 |
| 205 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone()); | 205 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone()); |
| 206 if (call_super) { | 206 if (call_super) { |
| 207 // $super_constructor = %_GetSuperConstructor(<this-function>) | 207 // $super_constructor = %_GetSuperConstructor(<this-function>) |
| 208 // %reflect_construct($super_constructor, arguments, new.target) | 208 // %reflect_construct( |
| 209 // $super_constructor, InternalArray(...args), new.target) |
| 210 auto constructor_args_name = ast_value_factory()->empty_string(); |
| 211 bool is_duplicate; |
| 212 bool is_rest = true; |
| 213 bool is_optional = false; |
| 214 Variable* constructor_args = |
| 215 function_scope->DeclareParameter(constructor_args_name, TEMPORARY, |
| 216 is_optional, is_rest, &is_duplicate); |
| 217 |
| 209 ZoneList<Expression*>* args = | 218 ZoneList<Expression*>* args = |
| 210 new (zone()) ZoneList<Expression*>(2, zone()); | 219 new (zone()) ZoneList<Expression*>(2, zone()); |
| 211 VariableProxy* this_function_proxy = scope_->NewUnresolved( | 220 VariableProxy* this_function_proxy = scope_->NewUnresolved( |
| 212 factory(), ast_value_factory()->this_function_string(), | 221 factory(), ast_value_factory()->this_function_string(), |
| 213 Variable::NORMAL, pos); | 222 Variable::NORMAL, pos); |
| 214 ZoneList<Expression*>* tmp = | 223 ZoneList<Expression*>* tmp = |
| 215 new (zone()) ZoneList<Expression*>(1, zone()); | 224 new (zone()) ZoneList<Expression*>(1, zone()); |
| 216 tmp->Add(this_function_proxy, zone()); | 225 tmp->Add(this_function_proxy, zone()); |
| 217 Expression* super_constructor = factory()->NewCallRuntime( | 226 Expression* super_constructor = factory()->NewCallRuntime( |
| 218 Runtime::kInlineGetSuperConstructor, tmp, pos); | 227 Runtime::kInlineGetSuperConstructor, tmp, pos); |
| 219 args->Add(super_constructor, zone()); | 228 args->Add(super_constructor, zone()); |
| 220 VariableProxy* arguments_proxy = scope_->NewUnresolved( | 229 Spread* spread_args = factory()->NewSpread( |
| 221 factory(), ast_value_factory()->arguments_string(), Variable::NORMAL, | 230 factory()->NewVariableProxy(constructor_args), pos, pos); |
| 222 pos); | 231 ZoneList<Expression*>* spread_args_expr = |
| 223 args->Add(arguments_proxy, zone()); | 232 new (zone()) ZoneList<Expression*>(1, zone()); |
| 233 spread_args_expr->Add(spread_args, zone()); |
| 234 args->AddAll(*PrepareSpreadArguments(spread_args_expr), zone()); |
| 224 VariableProxy* new_target_proxy = scope_->NewUnresolved( | 235 VariableProxy* new_target_proxy = scope_->NewUnresolved( |
| 225 factory(), ast_value_factory()->new_target_string(), Variable::NORMAL, | 236 factory(), ast_value_factory()->new_target_string(), Variable::NORMAL, |
| 226 pos); | 237 pos); |
| 227 args->Add(new_target_proxy, zone()); | 238 args->Add(new_target_proxy, zone()); |
| 228 CallRuntime* call = factory()->NewCallRuntime( | 239 CallRuntime* call = factory()->NewCallRuntime( |
| 229 Context::REFLECT_CONSTRUCT_INDEX, args, pos); | 240 Context::REFLECT_CONSTRUCT_INDEX, args, pos); |
| 230 body->Add(factory()->NewReturnStatement(call, pos), zone()); | 241 body->Add(factory()->NewReturnStatement(call, pos), zone()); |
| 231 } | 242 } |
| 232 | 243 |
| 233 materialized_literal_count = function_state.materialized_literal_count(); | 244 materialized_literal_count = function_state.materialized_literal_count(); |
| (...skipping 6731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6965 try_block, target); | 6976 try_block, target); |
| 6966 final_loop = target; | 6977 final_loop = target; |
| 6967 } | 6978 } |
| 6968 | 6979 |
| 6969 return final_loop; | 6980 return final_loop; |
| 6970 } | 6981 } |
| 6971 | 6982 |
| 6972 | 6983 |
| 6973 } // namespace internal | 6984 } // namespace internal |
| 6974 } // namespace v8 | 6985 } // namespace v8 |
| OLD | NEW |