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

Unified Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.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/elements/modelx.dart
diff --git a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
index 9a226bced08a8f416c977aaca4b04923f261fcf1..70f993f50a99a4cb7034d48344738ebe5af9bd86 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
@@ -1084,24 +1084,22 @@ class TypedefElementX extends ElementX implements TypedefElement {
TypedefType computeType(Compiler compiler) {
if (thisType != null) return thisType;
Typedef node = parseNode(compiler);
- Link<DartType> parameters =
+ List<DartType> parameters =
TypeDeclarationElementX.createTypeVariables(this, node.typeParameters);
thisType = new TypedefType(this, parameters);
if (parameters.isEmpty) {
rawType = thisType;
} else {
- var dynamicParameters = const Link<DartType>();
- parameters.forEach((_) {
- dynamicParameters =
- dynamicParameters.prepend(compiler.types.dynamicType);
- });
+ List<DartType> dynamicParameters =new List<DartType>.generate(
Johnni Winther 2014/02/26 14:01:54 Space after =
karlklose 2014/02/27 09:31:41 Done.
+ parameters.length,
+ (_) => compiler.types.dynamicType);
rawType = new TypedefType(this, dynamicParameters);
}
compiler.resolveTypedef(this);
return thisType;
}
- Link<DartType> get typeVariables => thisType.typeArguments;
+ List<DartType> get typeVariables => thisType.typeArguments;
Scope buildScope() {
return new TypeDeclarationScope(enclosingElement.buildScope(), this);
@@ -1762,12 +1760,12 @@ class TypeDeclarationElementX {
* type variables declared in [parameter] on [element]. The bounds of the type
* variables are not set until [element] has been resolved.
*/
- static Link<DartType> createTypeVariables(TypeDeclarationElement element,
+ static List<DartType> createTypeVariables(TypeDeclarationElement element,
NodeList parameters) {
- if (parameters == null) return const Link<DartType>();
+ if (parameters == null) return const <DartType>[];
// Create types and elements for type variable.
- var arguments = new LinkBuilder<DartType>();
+ List<DartType> arguments = <DartType>[];
for (Link link = parameters.nodes; !link.isEmpty; link = link.tail) {
TypeVariable node = link.head;
String variableName = node.name.source;
@@ -1775,9 +1773,9 @@ class TypeDeclarationElementX {
new TypeVariableElementX(variableName, element, node);
TypeVariableType variableType = new TypeVariableType(variableElement);
variableElement.type = variableType;
- arguments.addLast(variableType);
+ arguments.add(variableType);
}
- return arguments.toLink();
+ return arguments;
}
}
@@ -1854,19 +1852,18 @@ abstract class BaseClassElementX extends ElementX implements ClassElement {
bool get isUnnamedMixinApplication => false;
- void computeThisAndRawType(Compiler compiler, Link<DartType> typeVariables) {
+ void computeThisAndRawType(Compiler compiler, List<DartType> typeVariables) {
if (thisType == null) {
if (origin == null) {
- Link<DartType> parameters = typeVariables;
+ List<DartType> parameters = typeVariables;
thisType = new InterfaceType(this, parameters);
if (parameters.isEmpty) {
rawTypeCache = thisType;
} else {
- var dynamicParameters = const Link<DartType>();
- parameters.forEach((_) {
- dynamicParameters =
- dynamicParameters.prepend(compiler.types.dynamicType);
- });
+ // TODO(karlklose): there is similar code in another place; share.
+ List<DartType> dynamicParameters = new List<DartType>.generate(
+ parameters.length,
+ (_) => compiler.types.dynamicType);
rawTypeCache = new InterfaceType(this, dynamicParameters);
}
} else {
@@ -1890,7 +1887,7 @@ abstract class BaseClassElementX extends ElementX implements ClassElement {
return rawTypeCache;
}
- Link<DartType> computeTypeParameters(Compiler compiler);
+ List<DartType> computeTypeParameters(Compiler compiler);
/**
* Return [:true:] if this element is the [:Object:] class for the [compiler].
@@ -1898,7 +1895,7 @@ abstract class BaseClassElementX extends ElementX implements ClassElement {
bool isObject(Compiler compiler) =>
identical(declaration, compiler.objectClass);
- Link<DartType> get typeVariables => thisType.typeArguments;
+ List<DartType> get typeVariables => thisType.typeArguments;
ClassElement ensureResolved(Compiler compiler) {
if (resolutionState == STATE_NOT_STARTED) {
@@ -2286,7 +2283,7 @@ abstract class ClassElementX extends BaseClassElementX {
localMembers = localMembers.prepend(constructor);
}
- Link<DartType> computeTypeParameters(Compiler compiler) {
+ List<DartType> computeTypeParameters(Compiler compiler) {
ClassNode node = parseNode(compiler);
return TypeDeclarationElementX.createTypeVariables(
this, node.typeParameters);
@@ -2381,7 +2378,7 @@ class MixinApplicationElementX extends BaseClassElementX
addConstructor(constructor);
}
- Link<DartType> computeTypeParameters(Compiler compiler) {
+ List<DartType> computeTypeParameters(Compiler compiler) {
NamedMixinApplication named = node.asNamedMixinApplication();
if (named == null) {
throw new SpannableAssertionFailure(node,

Powered by Google App Engine
This is Rietveld 408576698