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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 177963002: Use List instead of Link in the type system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 69e3b45b9d02d08514b558f3b894906b061ee331..173b23333a9dbe6c8b05f1332c8d2ce97d0e2c6f 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -1170,32 +1170,26 @@ class ResolverTask extends CompilerTask {
FunctionType computeFunctionType(Element element,
FunctionSignature signature) {
- var parameterTypes = new LinkBuilder<DartType>();
+ List<DartType> parameterTypes = <DartType>[];
for (Element parameter in signature.requiredParameters) {
- parameterTypes.addLast(parameter.computeType(compiler));
+ parameterTypes.add(parameter.computeType(compiler));
}
- var optionalParameterTypes = const Link<DartType>();
- var namedParameters = const Link<String>();
- var namedParameterTypes = const Link<DartType>();
+ List<DartType> optionalParameterTypes = <DartType>[];
+ List<String> namedParameters = <String>[];
+ List<DartType> namedParameterTypes = <DartType>[];
if (signature.optionalParametersAreNamed) {
- var namedParametersBuilder = new LinkBuilder<String>();
- var namedParameterTypesBuilder = new LinkBuilder<DartType>();
for (Element parameter in signature.orderedOptionalParameters) {
- namedParametersBuilder.addLast(parameter.name);
- namedParameterTypesBuilder.addLast(parameter.computeType(compiler));
+ namedParameters.add(parameter.name);
+ namedParameterTypes.add(parameter.computeType(compiler));
}
- namedParameters = namedParametersBuilder.toLink();
- namedParameterTypes = namedParameterTypesBuilder.toLink();
} else {
- var optionalParameterTypesBuilder = new LinkBuilder<DartType>();
for (Element parameter in signature.optionalParameters) {
- optionalParameterTypesBuilder.addLast(parameter.computeType(compiler));
+ optionalParameterTypes.add(parameter.computeType(compiler));
}
- optionalParameterTypes = optionalParameterTypesBuilder.toLink();
}
return new FunctionType(element,
signature.returnType,
- parameterTypes.toLink(),
+ parameterTypes,
optionalParameterTypes,
namedParameters,
namedParameterTypes);
@@ -1719,21 +1713,21 @@ class TypeResolver {
Element erroneousElement = new ErroneousElementX(
messageKind, messageArguments, typeName.source,
visitor.enclosingElement);
- LinkBuilder<DartType> arguments = new LinkBuilder<DartType>();
+ List<DartType> arguments = <DartType>[];
resolveTypeArguments(visitor, node, null, arguments);
return new MalformedType(erroneousElement,
- userProvidedBadType, arguments.toLink());
+ userProvidedBadType, arguments);
}
DartType checkNoTypeArguments(DartType type) {
- LinkBuilder<DartType> arguments = new LinkBuilder<DartType>();
+ List<DartType> arguments = <DartType>[];
bool hasTypeArgumentMismatch = resolveTypeArguments(
- visitor, node, const Link<DartType>(), arguments);
+ visitor, node, <DartType>[], arguments);
if (hasTypeArgumentMismatch) {
return new MalformedType(
new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH,
{'type': node}, typeName.source, visitor.enclosingElement),
- type, arguments.toLink());
+ type, arguments);
}
return type;
}
@@ -1759,18 +1753,18 @@ class TypeResolver {
ClassElement cls = element;
compiler.resolver._ensureClassWillBeResolved(cls);
element.computeType(compiler);
- var arguments = new LinkBuilder<DartType>();
+ List<DartType> arguments = <DartType>[];
bool hasTypeArgumentMismatch = resolveTypeArguments(
visitor, node, cls.typeVariables, arguments);
if (hasTypeArgumentMismatch) {
type = new BadInterfaceType(cls.declaration,
new InterfaceType.forUserProvidedBadType(cls.declaration,
- arguments.toLink()));
+ arguments));
} else {
if (arguments.isEmpty) {
type = cls.rawType;
} else {
- type = new InterfaceType(cls.declaration, arguments.toLink());
+ type = new InterfaceType(cls.declaration, arguments);
addTypeVariableBoundsCheck = true;
}
}
@@ -1778,18 +1772,17 @@ class TypeResolver {
TypedefElement typdef = element;
// TODO(ahe): Should be [ensureResolved].
compiler.resolveTypedef(typdef);
- var arguments = new LinkBuilder<DartType>();
+ List<DartType> arguments = <DartType>[];
bool hasTypeArgumentMismatch = resolveTypeArguments(
visitor, node, typdef.typeVariables, arguments);
if (hasTypeArgumentMismatch) {
type = new BadTypedefType(typdef,
- new TypedefType.forUserProvidedBadType(typdef,
- arguments.toLink()));
+ new TypedefType.forUserProvidedBadType(typdef, arguments));
} else {
if (arguments.isEmpty) {
type = typdef.rawType;
} else {
- type = new TypedefType(typdef, arguments.toLink());
+ type = new TypedefType(typdef, arguments);
addTypeVariableBoundsCheck = true;
}
}
@@ -1855,30 +1848,29 @@ class TypeResolver {
* Returns [: true :] if the number of type arguments did not match the
* number of type variables.
*/
- bool resolveTypeArguments(
- MappingVisitor visitor,
- TypeAnnotation node,
- Link<DartType> typeVariables,
- LinkBuilder<DartType> arguments) {
+ bool resolveTypeArguments(MappingVisitor visitor,
+ TypeAnnotation node,
+ List<DartType> typeVariables,
+ List<DartType> arguments) {
if (node.typeArguments == null) {
return false;
}
+ int expectedVariables =
+ typeVariables != null ? typeVariables.length : arguments.length;
+ int index = 0;
bool typeArgumentCountMismatch = false;
for (Link<Node> typeArguments = node.typeArguments.nodes;
!typeArguments.isEmpty;
- typeArguments = typeArguments.tail) {
- if (typeVariables != null && typeVariables.isEmpty) {
+ typeArguments = typeArguments.tail, index++) {
+ if (index > expectedVariables - 1) {
visitor.warning(
typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
typeArgumentCountMismatch = true;
}
DartType argType = resolveTypeAnnotation(visitor, typeArguments.head);
- arguments.addLast(argType);
- if (typeVariables != null && !typeVariables.isEmpty) {
- typeVariables = typeVariables.tail;
- }
+ arguments.add(argType);
}
- if (typeVariables != null && !typeVariables.isEmpty) {
+ if (index < expectedVariables) {
visitor.warning(node.typeArguments,
MessageKind.MISSING_TYPE_ARGUMENT);
typeArgumentCountMismatch = true;
@@ -3197,8 +3189,7 @@ class ResolverVisitor extends MappingVisitor<Element> {
compiler.reportError(arguments.nodes.head,
MessageKind.TYPE_VARIABLE_IN_CONSTANT);
}
- listType = new InterfaceType(compiler.listClass,
- new Link<DartType>.fromList([typeArgument]));
+ listType = new InterfaceType(compiler.listClass, [typeArgument]);
} else {
compiler.listClass.computeType(compiler);
listType = compiler.listClass.rawType;
@@ -3415,7 +3406,7 @@ class ResolverVisitor extends MappingVisitor<Element> {
DartType mapType;
if (valueTypeArgument != null) {
mapType = new InterfaceType(compiler.mapClass,
- new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument]));
+ [keyTypeArgument, valueTypeArgument]);
} else {
compiler.mapClass.computeType(compiler);
mapType = compiler.mapClass.rawType;
@@ -3623,12 +3614,13 @@ class TypeDefinitionVisitor extends MappingVisitor<DartType> {
void resolveTypeVariableBounds(NodeList node) {
if (node == null) return;
- var nameSet = new Setlet<String>();
+ Setlet<String> nameSet = new Setlet<String>();
// Resolve the bounds of type variables.
- Link<DartType> typeLink = element.typeVariables;
+ Iterator<DartType> types = element.typeVariables.iterator;
Link<Node> nodeLink = node.nodes;
while (!nodeLink.isEmpty) {
- TypeVariableType typeVariable = typeLink.head;
+ types.moveNext();
+ TypeVariableType typeVariable = types.current;
String typeName = typeVariable.name;
TypeVariable typeNode = nodeLink.head;
if (nameSet.contains(typeName)) {
@@ -3668,9 +3660,8 @@ class TypeDefinitionVisitor extends MappingVisitor<DartType> {
variableElement.bound = objectType;
}
nodeLink = nodeLink.tail;
- typeLink = typeLink.tail;
}
- assert(typeLink.isEmpty);
+ assert(!types.moveNext());
}
}
@@ -3948,23 +3939,22 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
node,
new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT));
// Create synthetic type variables for the mixin application.
- LinkBuilder<DartType> typeVariablesBuilder = new LinkBuilder<DartType>();
+ List<DartType> typeVariables = <DartType>[];
element.typeVariables.forEach((TypeVariableType type) {
TypeVariableElementX typeVariableElement = new TypeVariableElementX(
type.name, mixinApplication, type.element.parseNode(compiler));
TypeVariableType typeVariable = new TypeVariableType(typeVariableElement);
- typeVariablesBuilder.addLast(typeVariable);
+ typeVariables.add(typeVariable);
});
- Link<DartType> typeVariables = typeVariablesBuilder.toLink();
// Setup bounds on the synthetic type variables.
- Link<DartType> link = typeVariables;
+ List<DartType> link = typeVariables;
+ int index = 0;
element.typeVariables.forEach((TypeVariableType type) {
- TypeVariableType typeVariable = link.head;
+ TypeVariableType typeVariable = typeVariables[index++];
TypeVariableElement typeVariableElement = typeVariable.element;
typeVariableElement.type = typeVariable;
typeVariableElement.bound =
type.element.bound.subst(typeVariables, element.typeVariables);
- link = link.tail;
});
// Setup this and raw type for the mixin application.
mixinApplication.computeThisAndRawType(compiler, typeVariables);

Powered by Google App Engine
This is Rietveld 408576698