Rename klass getter on InstanceConstant to classNode

This achieves consistency with similar getters in the API.

This is technically a breaking change, since it changes a published
part of the Kernel API. Since the constants API is relatively new and
so far only used internally in the AOT compiler, the change is
expected to be unproblematic.

Closes https://github.com/dart-lang/sdk/issues/35696

Change-Id: I3ca30922580d226ccbdb6f77496983c21ef2102b
Reviewed-on: https://dart-review.googlesource.com/c/90220
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
This commit is contained in:
Aske Simon Christensen 2019-01-28 13:31:05 +00:00 committed by commit-bot@chromium.org
parent 42be4083bd
commit f066c05319
11 changed files with 23 additions and 16 deletions

View file

@ -47,6 +47,13 @@
[29554]: https://github.com/dart-lang/sdk/issues/29554
### Other library changes
#### `package:kernel`
* **Breaking change:** The `klass` getter on the `InstanceConstant` class in
the Kernel AST API has been renamed to `classNode` for consistency.
### Dart VM
### Tool Changes

View file

@ -240,10 +240,10 @@ class TypeLabeler implements DartTypeVisitor<void>, ConstantVisitor<void> {
}
void visitInstanceConstant(InstanceConstant node) {
new InterfaceType(node.klass, node.typeArguments).accept(this);
new InterfaceType(node.classNode, node.typeArguments).accept(this);
result.add(" {");
bool first = true;
for (Field field in node.klass.fields) {
for (Field field in node.classNode.fields) {
if (field.isStatic) continue;
if (!first) result.add(", ");
result.add("${field.name}: ");

View file

@ -5306,7 +5306,7 @@ class InstanceConstant extends Constant {
InstanceConstant(this.classReference, this.typeArguments, this.fieldValues);
Class get klass => classReference.asClass;
Class get classNode => classReference.asClass;
visitChildren(Visitor v) {
classReference.asClass.acceptReference(v);
@ -5354,7 +5354,7 @@ class InstanceConstant extends Constant {
}
DartType getType(TypeEnvironment types) =>
new InterfaceType(klass, typeArguments);
new InterfaceType(classNode, typeArguments);
}
class PartialInstantiationConstant extends Constant {

View file

@ -221,7 +221,7 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
constant.entries.forEach(writeConstantReference);
} else if (constant is InstanceConstant) {
writeByte(ConstantTag.InstanceConstant);
writeClassReference(constant.klass);
writeClassReference(constant.classNode);
writeUInt30(constant.typeArguments.length);
constant.typeArguments.forEach(writeDartType);
writeUInt30(constant.fieldValues.length);

View file

@ -27,7 +27,7 @@ String getExternalName(Member procedure) {
} else if (annotation is ConstantExpression) {
final constant = annotation.constant;
if (constant is InstanceConstant) {
if (_isExternalName(constant.klass)) {
if (_isExternalName(constant.classNode)) {
return (constant.fieldValues.values.single as StringConstant).value;
}
}

View file

@ -1959,8 +1959,8 @@ class Printer extends Visitor<Null> {
final String name = syntheticNames.nameConstant(node);
write(' $name = ');
final sb = new StringBuffer();
sb.write('${node.klass}');
if (!node.klass.typeParameters.isEmpty) {
sb.write('${node.classNode}');
if (!node.classNode.typeParameters.isEmpty) {
sb.write('<');
sb.write(node.typeArguments.map((type) => type.toString()).join(', '));
sb.write('>');

View file

@ -566,7 +566,7 @@ class ConstantEvaluator extends RecursiveVisitor {
// Special case the dart:core's Symbol class here and convert it to a
// [SymbolConstant]. For invalid values we report a compile-time error.
if (result.klass == coreTypes.internalSymbolClass) {
if (result.classNode == coreTypes.internalSymbolClass) {
// The dart:_internal's Symbol class has only the name field.
assert(coreTypes.internalSymbolClass.fields
.where((f) => !f.isStatic)

View file

@ -977,7 +977,7 @@ class _TreeShakerVisitor extends RecursiveVisitor {
@override
visitInstanceConstant(InstanceConstant node) {
shaker._addInstantiatedClass(node.klass);
shaker._addInstantiatedClass(node.classNode);
super.visitInstanceConstant(node);
}

View file

@ -3040,10 +3040,10 @@ class ConstantEmitter extends ConstantVisitor<int> {
@override
int visitInstanceConstant(InstanceConstant node) => cp.addInstance(
node.klass,
hasInstantiatorTypeArguments(node.klass)
node.classNode,
hasInstantiatorTypeArguments(node.classNode)
? cp.addTypeArgumentsForInstanceAllocation(
node.klass, node.typeArguments)
node.classNode, node.typeArguments)
: cp.addNull(),
node.fieldValues.map<Field, int>((Reference fieldRef, Constant value) =>
new MapEntry(fieldRef.asField, value.accept(this))));

View file

@ -1629,8 +1629,8 @@ class ConstantAllocationCollector extends ConstantVisitor<Type> {
@override
Type visitInstanceConstant(InstanceConstant constant) {
final resultType =
summaryCollector._entryPointsListener.addAllocatedClass(constant.klass);
final resultType = summaryCollector._entryPointsListener
.addAllocatedClass(constant.classNode);
constant.fieldValues.forEach((Reference fieldReference, Constant value) {
summaryCollector._entryPointsListener
.addDirectFieldAccess(fieldReference.asField, typeFor(value));

View file

@ -1050,7 +1050,7 @@ class _TreeShakerConstantVisitor extends ConstantVisitor<Null> {
@override
visitInstanceConstant(InstanceConstant constant) {
instanceConstants.add(constant);
shaker.addClassUsedInType(constant.klass);
shaker.addClassUsedInType(constant.classNode);
visitList(constant.typeArguments, typeVisitor);
constant.fieldValues.forEach((Reference fieldRef, Constant value) {
shaker.addUsedMember(fieldRef.asField);