Index: lib/compiler/implementation/typechecker.dart |
diff --git a/lib/compiler/implementation/typechecker.dart b/lib/compiler/implementation/typechecker.dart |
index 11ba1ee98ed0a6b5b955afa72898735a494c67ed..b0f2e6966955459e70f24376d787427385f53db0 100644 |
--- a/lib/compiler/implementation/typechecker.dart |
+++ b/lib/compiler/implementation/typechecker.dart |
@@ -33,6 +33,8 @@ class TypeVariableType implements Type { |
final SourceString name; |
Element element; |
TypeVariableType(this.name, [this.element]); |
+ |
+ toString() => name.toString(); |
} |
/** |
@@ -58,12 +60,29 @@ class StatementType implements Type { |
String toString() => stringName; |
} |
-class SimpleType implements Type { |
+class InterfaceType implements Type { |
final SourceString name; |
ahe
2012/04/12 15:05:23
This field seems redundant.
|
- final Element element; |
+ final ClassElement element; |
+ final Link<Type> arguments; |
+ |
+ const InterfaceType(this.name, this.element, this.arguments); |
- const SimpleType(SourceString this.name, Element this.element); |
+ toString() { |
+ StringBuffer sb = new StringBuffer(); |
+ sb.add(name.slowToString()); |
+ if (!arguments.isEmpty()) { |
+ sb.add('<'); |
+ arguments.printOn(sb); |
ahe
2012/04/12 15:05:23
Add argument: ', '
|
+ sb.add('>'); |
+ } |
+ return sb.toString(); |
+ } |
+} |
+// TODO(karlklose): merge into InterfaceType as a named constructor. |
+class SimpleType extends InterfaceType { |
+ const SimpleType(SourceString name, Element element) |
+ : super(name, element, const EmptyLink<Type>()); |
String toString() => name.slowToString(); |
} |
@@ -101,9 +120,10 @@ class Types { |
final SimpleType dynamicType; |
Types() : this.with(new LibraryElement(new Script(null, null))); |
+ |
Types.with(LibraryElement library) |
: voidType = new SimpleType(VOID, new ClassElement(VOID, library)), |
- dynamicType = new SimpleType(DYNAMIC, new ClassElement(DYNAMIC, library)); |
+ dynamicType = new SimpleType(VOID, new ClassElement(DYNAMIC, library)); |
ahe
2012/04/12 15:05:23
VOID?
|
Type lookup(SourceString s) { |
if (VOID == s) { |
@@ -172,9 +192,9 @@ Type lookupType(SourceString name, Compiler compiler, types) { |
class TypeCheckerVisitor implements Visitor<Type> { |
final Compiler compiler; |
final TreeElements elements; |
- Node lastSeenNode; |
final Types types; |
+ Node lastSeenNode; |
Type expectedReturnType; |
ClassElement currentClass; |
@@ -185,8 +205,7 @@ class TypeCheckerVisitor implements Visitor<Type> { |
Type objectType; |
Type listType; |
- TypeCheckerVisitor(Compiler this.compiler, TreeElements this.elements, |
- Types this.types) { |
+ TypeCheckerVisitor(this.compiler, this.elements, this.types) { |
intType = lookupType(Types.INT, compiler, types); |
doubleType = lookupType(Types.DOUBLE, compiler, types); |
boolType = lookupType(Types.BOOL, compiler, types); |