Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1644)

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1309813007: [es6] implement destructuring assignment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: An implementation Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 Node* pattern = jsgraph()->Constant(expr->pattern()); 1690 Node* pattern = jsgraph()->Constant(expr->pattern());
1691 Node* flags = jsgraph()->Constant(expr->flags()); 1691 Node* flags = jsgraph()->Constant(expr->flags());
1692 const Operator* op = 1692 const Operator* op =
1693 javascript()->CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); 1693 javascript()->CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
1694 Node* literal = NewNode(op, literals_array, literal_index, pattern, flags); 1694 Node* literal = NewNode(op, literals_array, literal_index, pattern, flags);
1695 PrepareFrameState(literal, expr->id(), ast_context()->GetStateCombine()); 1695 PrepareFrameState(literal, expr->id(), ast_context()->GetStateCombine());
1696 ast_context()->ProduceValue(literal); 1696 ast_context()->ProduceValue(literal);
1697 } 1697 }
1698 1698
1699 1699
1700 void AstGraphBuilder::VisitAssignmentPattern(AssignmentPattern* expr) {
1701 Visit(expr->expression());
1702 }
1703
1704
1700 void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { 1705 void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
1701 Node* closure = GetFunctionClosure(); 1706 Node* closure = GetFunctionClosure();
1702 1707
1703 // Create node to deep-copy the literal boilerplate. 1708 // Create node to deep-copy the literal boilerplate.
1704 Node* literals_array = 1709 Node* literals_array =
1705 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); 1710 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset);
1706 Node* literal_index = jsgraph()->Constant(expr->literal_index()); 1711 Node* literal_index = jsgraph()->Constant(expr->literal_index());
1707 Node* constants = jsgraph()->Constant(expr->constant_properties()); 1712 Node* constants = jsgraph()->Constant(expr->constant_properties());
1708 const Operator* op = 1713 const Operator* op =
1709 javascript()->CreateLiteralObject(expr->ComputeFlags(true)); 1714 javascript()->CreateLiteralObject(expr->ComputeFlags(true));
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 Node* store = BuildKeyedSuperStore(receiver, home_object, key, value); 2054 Node* store = BuildKeyedSuperStore(receiver, home_object, key, value);
2050 states.AddToNode(store, bailout_id_after, 2055 states.AddToNode(store, bailout_id_after,
2051 OutputFrameStateCombine::Ignore()); 2056 OutputFrameStateCombine::Ignore());
2052 break; 2057 break;
2053 } 2058 }
2054 } 2059 }
2055 } 2060 }
2056 2061
2057 2062
2058 void AstGraphBuilder::VisitAssignment(Assignment* expr) { 2063 void AstGraphBuilder::VisitAssignment(Assignment* expr) {
2064 if (expr->target()->IsAssignmentPattern()) {
2065 DCHECK(expr->target()->AsAssignmentPattern()->is_rewritten());
2066 return Visit(expr->target()->AsAssignmentPattern()->expression());
2067 }
2059 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); 2068 DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
2060 2069
2061 // Left-hand side can only be a property, a global or a variable slot. 2070 // Left-hand side can only be a property, a global or a variable slot.
2062 Property* property = expr->target()->AsProperty(); 2071 Property* property = expr->target()->AsProperty();
2063 LhsKind assign_type = Property::GetAssignType(property); 2072 LhsKind assign_type = Property::GetAssignType(property);
2064 bool needs_frame_state_before = true; 2073 bool needs_frame_state_before = true;
2065 2074
2066 // Evaluate LHS expression. 2075 // Evaluate LHS expression.
2067 switch (assign_type) { 2076 switch (assign_type) {
2068 case VARIABLE: { 2077 case VARIABLE: {
(...skipping 2227 matching lines...) Expand 10 before | Expand all | Expand 10 after
4296 // Phi does not exist yet, introduce one. 4305 // Phi does not exist yet, introduce one.
4297 value = NewPhi(inputs, value, control); 4306 value = NewPhi(inputs, value, control);
4298 value->ReplaceInput(inputs - 1, other); 4307 value->ReplaceInput(inputs - 1, other);
4299 } 4308 }
4300 return value; 4309 return value;
4301 } 4310 }
4302 4311
4303 } // namespace compiler 4312 } // namespace compiler
4304 } // namespace internal 4313 } // namespace internal
4305 } // namespace v8 4314 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698