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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 1637843002: typeInformation in CreateInstance is a kind of TypeExpression (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months 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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library dart2js.ir_nodes; 4 library dart2js.ir_nodes;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'cps_fragment.dart' show CpsFragment; 7 import 'cps_fragment.dart' show CpsFragment;
8 import '../constants/values.dart' as values; 8 import '../constants/values.dart' as values;
9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 1439
1440 /// Initial values for the fields on the class. 1440 /// Initial values for the fields on the class.
1441 /// The order corresponds to the order of fields on the class. 1441 /// The order corresponds to the order of fields on the class.
1442 final List<Reference<Primitive>> arguments; 1442 final List<Reference<Primitive>> arguments;
1443 1443
1444 /// The runtime type information structure which contains the type arguments. 1444 /// The runtime type information structure which contains the type arguments.
1445 /// 1445 ///
1446 /// May be `null` to indicate that no type information is needed because the 1446 /// May be `null` to indicate that no type information is needed because the
1447 /// compiler determined that the type information for instances of this class 1447 /// compiler determined that the type information for instances of this class
1448 /// is not needed at runtime. 1448 /// is not needed at runtime.
1449 final List<Reference<Primitive>> typeInformation; 1449 final Reference<Primitive> typeInformation;
1450 1450
1451 final SourceInformation sourceInformation; 1451 final SourceInformation sourceInformation;
1452 1452
1453 CreateInstance(this.classElement, List<Primitive> arguments, 1453 CreateInstance(this.classElement, List<Primitive> arguments,
1454 List<Primitive> typeInformation, 1454 Primitive typeInformation,
1455 this.sourceInformation) 1455 this.sourceInformation)
1456 : this.arguments = _referenceList(arguments), 1456 : this.arguments = _referenceList(arguments),
1457 this.typeInformation = _referenceList(typeInformation); 1457 this.typeInformation = typeInformation == null
1458 ? null
1459 : new Reference<Primitive>(typeInformation);
1458 1460
1459 accept(Visitor visitor) => visitor.visitCreateInstance(this); 1461 accept(Visitor visitor) => visitor.visitCreateInstance(this);
1460 1462
1461 bool get hasValue => true; 1463 bool get hasValue => true;
1462 bool get isSafeForElimination => true; 1464 bool get isSafeForElimination => true;
1463 bool get isSafeForReordering => true; 1465 bool get isSafeForReordering => true;
1464 1466
1465 toString() => 'CreateInstance($classElement)'; 1467 toString() => 'CreateInstance($classElement)';
1466 1468
1467 void setParentPointers() { 1469 void setParentPointers() {
1468 _setParentsOnList(arguments, this); 1470 _setParentsOnList(arguments, this);
1469 if (typeInformation != null) _setParentsOnList(typeInformation, this); 1471 if (typeInformation != null) typeInformation.parent = this;
1470 } 1472 }
1471 } 1473 }
1472 1474
1473 /// Obtains the interceptor for the given value. This is a method table 1475 /// Obtains the interceptor for the given value. This is a method table
1474 /// corresponding to the Dart class of the value. 1476 /// corresponding to the Dart class of the value.
1475 /// 1477 ///
1476 /// All values are either intercepted or self-intercepted. The interceptor for 1478 /// All values are either intercepted or self-intercepted. The interceptor for
1477 /// an "intercepted value" is one of the subclasses of Interceptor. 1479 /// an "intercepted value" is one of the subclasses of Interceptor.
1478 /// The interceptor for a "self-intercepted value" is the value itself. 1480 /// The interceptor for a "self-intercepted value" is the value itself.
1479 /// 1481 ///
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 /// 1750 ///
1749 /// The resulting value is constructed from [dartType] by replacing the type 1751 /// The resulting value is constructed from [dartType] by replacing the type
1750 /// variables with consecutive values from [arguments], in the order generated 1752 /// variables with consecutive values from [arguments], in the order generated
1751 /// by [DartType.forEachTypeVariable]. The type variables in [dartType] are 1753 /// by [DartType.forEachTypeVariable]. The type variables in [dartType] are
1752 /// treated as 'holes' in the term, which means that it must be ensured at 1754 /// treated as 'holes' in the term, which means that it must be ensured at
1753 /// construction, that duplicate occurences of a type variable in [dartType] 1755 /// construction, that duplicate occurences of a type variable in [dartType]
1754 /// are assigned the same value. 1756 /// are assigned the same value.
1755 class TypeExpression extends Primitive { 1757 class TypeExpression extends Primitive {
1756 final DartType dartType; 1758 final DartType dartType;
1757 final List<Reference<Primitive>> arguments; 1759 final List<Reference<Primitive>> arguments;
1760 final bool isForInstance; // Expression on instance has 'headless' form.
asgerf 2016/01/26 10:30:00 The name and comment are obscure without more deta
sra1 2016/01/26 22:21:08 It is flat because the dartType is always the 'thi
asgerf 2016/01/27 14:53:26 CreateInstance is not always going to create the '
sra1 2016/01/27 19:20:03 After inlining, the TypeExpression(INSTANCE) will
1758 1761
1759 TypeExpression(this.dartType, 1762 TypeExpression(this.dartType,
1760 [List<Primitive> arguments = const <Primitive>[]]) 1763 List<Primitive> arguments,
1764 this.isForInstance)
1761 : this.arguments = _referenceList(arguments); 1765 : this.arguments = _referenceList(arguments);
1762 1766
1763 @override 1767 @override
1764 accept(Visitor visitor) { 1768 accept(Visitor visitor) {
1765 return visitor.visitTypeExpression(this); 1769 return visitor.visitTypeExpression(this);
1766 } 1770 }
1767 1771
1768 bool get hasValue => true; 1772 bool get hasValue => true;
1769 bool get isSafeForElimination => true; 1773 bool get isSafeForElimination => true;
1770 bool get isSafeForReordering => true; 1774 bool get isSafeForReordering => true;
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 processInterceptor(Interceptor node) {} 2144 processInterceptor(Interceptor node) {}
2141 visitInterceptor(Interceptor node) { 2145 visitInterceptor(Interceptor node) {
2142 processInterceptor(node); 2146 processInterceptor(node);
2143 processReference(node.input); 2147 processReference(node.input);
2144 } 2148 }
2145 2149
2146 processCreateInstance(CreateInstance node) {} 2150 processCreateInstance(CreateInstance node) {}
2147 visitCreateInstance(CreateInstance node) { 2151 visitCreateInstance(CreateInstance node) {
2148 processCreateInstance(node); 2152 processCreateInstance(node);
2149 node.arguments.forEach(processReference); 2153 node.arguments.forEach(processReference);
2150 node.typeInformation.forEach(processReference); 2154 if (node.typeInformation != null) processReference(node.typeInformation);
2151 } 2155 }
2152 2156
2153 processSetField(SetField node) {} 2157 processSetField(SetField node) {}
2154 visitSetField(SetField node) { 2158 visitSetField(SetField node) {
2155 processSetField(node); 2159 processSetField(node);
2156 processReference(node.object); 2160 processReference(node.object);
2157 processReference(node.value); 2161 processReference(node.value);
2158 } 2162 }
2159 2163
2160 processGetField(GetField node) {} 2164 processGetField(GetField node) {}
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 Definition visitGetStatic(GetStatic node) { 2556 Definition visitGetStatic(GetStatic node) {
2553 return new GetStatic(node.element, node.sourceInformation); 2557 return new GetStatic(node.element, node.sourceInformation);
2554 } 2558 }
2555 2559
2556 Definition visitInterceptor(Interceptor node) { 2560 Definition visitInterceptor(Interceptor node) {
2557 return new Interceptor(getCopy(node.input), node.sourceInformation) 2561 return new Interceptor(getCopy(node.input), node.sourceInformation)
2558 ..interceptedClasses.addAll(node.interceptedClasses); 2562 ..interceptedClasses.addAll(node.interceptedClasses);
2559 } 2563 }
2560 2564
2561 Definition visitCreateInstance(CreateInstance node) { 2565 Definition visitCreateInstance(CreateInstance node) {
2562 return new CreateInstance(node.classElement, getList(node.arguments), 2566 return new CreateInstance(
2563 getList(node.typeInformation), 2567 node.classElement,
2568 getList(node.arguments),
2569 node.typeInformation == null ? null : getCopy(node.typeInformation),
2564 node.sourceInformation); 2570 node.sourceInformation);
2565 } 2571 }
2566 2572
2567 Definition visitGetField(GetField node) { 2573 Definition visitGetField(GetField node) {
2568 return new GetField(getCopy(node.object), node.field); 2574 return new GetField(getCopy(node.object), node.field);
2569 } 2575 }
2570 2576
2571 Definition visitCreateBox(CreateBox node) { 2577 Definition visitCreateBox(CreateBox node) {
2572 return new CreateBox(); 2578 return new CreateBox();
2573 } 2579 }
2574 2580
2575 Definition visitReifyRuntimeType(ReifyRuntimeType node) { 2581 Definition visitReifyRuntimeType(ReifyRuntimeType node) {
2576 return new ReifyRuntimeType(getCopy(node.value), node.sourceInformation); 2582 return new ReifyRuntimeType(getCopy(node.value), node.sourceInformation);
2577 } 2583 }
2578 2584
2579 Definition visitReadTypeVariable(ReadTypeVariable node) { 2585 Definition visitReadTypeVariable(ReadTypeVariable node) {
2580 return new ReadTypeVariable(node.variable, getCopy(node.target), 2586 return new ReadTypeVariable(node.variable, getCopy(node.target),
2581 node.sourceInformation); 2587 node.sourceInformation);
2582 } 2588 }
2583 2589
2584 Definition visitTypeExpression(TypeExpression node) { 2590 Definition visitTypeExpression(TypeExpression node) {
2585 return new TypeExpression(node.dartType, getList(node.arguments)); 2591 return new TypeExpression(
2592 node.dartType, getList(node.arguments), node.isForInstance);
2586 } 2593 }
2587 2594
2588 Definition visitCreateInvocationMirror(CreateInvocationMirror node) { 2595 Definition visitCreateInvocationMirror(CreateInvocationMirror node) {
2589 return new CreateInvocationMirror(node.selector, getList(node.arguments)); 2596 return new CreateInvocationMirror(node.selector, getList(node.arguments));
2590 } 2597 }
2591 2598
2592 Definition visitTypeTest(TypeTest node) { 2599 Definition visitTypeTest(TypeTest node) {
2593 return new TypeTest(getCopy(node.value), node.dartType, 2600 return new TypeTest(getCopy(node.value), node.dartType,
2594 getList(node.typeArguments)); 2601 getList(node.typeArguments));
2595 } 2602 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 plug(new Branch.loose(_definitions.getCopy(node.condition), 2794 plug(new Branch.loose(_definitions.getCopy(node.condition),
2788 _copies[node.trueContinuation.definition], 2795 _copies[node.trueContinuation.definition],
2789 _copies[node.falseContinuation.definition]) 2796 _copies[node.falseContinuation.definition])
2790 ..isStrictCheck = node.isStrictCheck); 2797 ..isStrictCheck = node.isStrictCheck);
2791 } 2798 }
2792 2799
2793 visitUnreachable(Unreachable node) { 2800 visitUnreachable(Unreachable node) {
2794 plug(new Unreachable()); 2801 plug(new Unreachable());
2795 } 2802 }
2796 } 2803 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698