| OLD | NEW |
| 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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/compiler/ast-loop-assignment-analyzer.h" | 9 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 10 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
| (...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 VisitDeclarations(expr->scope()->declarations()); | 1551 VisitDeclarations(expr->scope()->declarations()); |
| 1552 VisitClassLiteralContents(expr); | 1552 VisitClassLiteralContents(expr); |
| 1553 } else { | 1553 } else { |
| 1554 VisitDeclarations(expr->scope()->declarations()); | 1554 VisitDeclarations(expr->scope()->declarations()); |
| 1555 VisitClassLiteralContents(expr); | 1555 VisitClassLiteralContents(expr); |
| 1556 } | 1556 } |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 | 1559 |
| 1560 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) { | 1560 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) { |
| 1561 Node* class_name = expr->raw_name() ? jsgraph()->Constant(expr->name()) | |
| 1562 : jsgraph()->UndefinedConstant(); | |
| 1563 | |
| 1564 // The class name is expected on the operand stack. | |
| 1565 environment()->Push(class_name); | |
| 1566 VisitForValueOrTheHole(expr->extends()); | 1561 VisitForValueOrTheHole(expr->extends()); |
| 1567 VisitForValue(expr->constructor()); | 1562 VisitForValue(expr->constructor()); |
| 1568 | 1563 |
| 1569 // Create node to instantiate a new class. | 1564 // Create node to instantiate a new class. |
| 1570 Node* constructor = environment()->Pop(); | 1565 Node* constructor = environment()->Pop(); |
| 1571 Node* extends = environment()->Pop(); | 1566 Node* extends = environment()->Pop(); |
| 1572 Node* name = environment()->Pop(); | |
| 1573 Node* start = jsgraph()->Constant(expr->start_position()); | 1567 Node* start = jsgraph()->Constant(expr->start_position()); |
| 1574 Node* end = jsgraph()->Constant(expr->end_position()); | 1568 Node* end = jsgraph()->Constant(expr->end_position()); |
| 1575 const Operator* opc = javascript()->CallRuntime(Runtime::kDefineClass); | 1569 const Operator* opc = javascript()->CallRuntime(Runtime::kDefineClass); |
| 1576 Node* literal = NewNode(opc, name, extends, constructor, start, end); | 1570 Node* literal = NewNode(opc, extends, constructor, start, end); |
| 1577 PrepareFrameState(literal, expr->CreateLiteralId(), | 1571 PrepareFrameState(literal, expr->CreateLiteralId(), |
| 1578 OutputFrameStateCombine::Push()); | 1572 OutputFrameStateCombine::Push()); |
| 1579 | 1573 |
| 1580 // The prototype is ensured to exist by Runtime_DefineClass. No access check | 1574 // The prototype is ensured to exist by Runtime_DefineClass. No access check |
| 1581 // is needed here since the constructor is created by the class literal. | 1575 // is needed here since the constructor is created by the class literal. |
| 1582 Node* prototype = | 1576 Node* prototype = |
| 1583 BuildLoadObjectField(literal, JSFunction::kPrototypeOrInitialMapOffset); | 1577 BuildLoadObjectField(literal, JSFunction::kPrototypeOrInitialMapOffset); |
| 1584 | 1578 |
| 1585 // The class literal and the prototype are both expected on the operand stack | 1579 // The class literal and the prototype are both expected on the operand stack |
| 1586 // during evaluation of the method values. | 1580 // during evaluation of the method values. |
| (...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4340 // Phi does not exist yet, introduce one. | 4334 // Phi does not exist yet, introduce one. |
| 4341 value = NewPhi(inputs, value, control); | 4335 value = NewPhi(inputs, value, control); |
| 4342 value->ReplaceInput(inputs - 1, other); | 4336 value->ReplaceInput(inputs - 1, other); |
| 4343 } | 4337 } |
| 4344 return value; | 4338 return value; |
| 4345 } | 4339 } |
| 4346 | 4340 |
| 4347 } // namespace compiler | 4341 } // namespace compiler |
| 4348 } // namespace internal | 4342 } // namespace internal |
| 4349 } // namespace v8 | 4343 } // namespace v8 |
| OLD | NEW |