| Index: lib/compiler/implementation/typechecker.dart
|
| diff --git a/lib/compiler/implementation/typechecker.dart b/lib/compiler/implementation/typechecker.dart
|
| index 8d1f39921c4e6d91cab5c851389455741352a299..5baf2eca7fb29f9a93c72455b6b70e6042cb8f0f 100644
|
| --- a/lib/compiler/implementation/typechecker.dart
|
| +++ b/lib/compiler/implementation/typechecker.dart
|
| @@ -24,9 +24,24 @@ class TypeCheckerTask extends CompilerTask {
|
| }
|
| }
|
|
|
| +class TypeKind {
|
| + final String id;
|
| +
|
| + const TypeKind(String this.id);
|
| +
|
| + static const TypeKind FUNCTION = const TypeKind('function');
|
| + static const TypeKind INTERFACE = const TypeKind('interface');
|
| + static const TypeKind STATEMENT = const TypeKind('statement');
|
| + static const TypeKind TYPEDEF = const TypeKind('typedef');
|
| + static const TypeKind TYPE_VARIABLE = const TypeKind('type variable');
|
| + static const TypeKind VOID = const TypeKind('void');
|
| +}
|
| +
|
| abstract class DartType {
|
| abstract SourceString get name;
|
|
|
| + abstract TypeKind get kind;
|
| +
|
| /**
|
| * Returns the [Element] which declared this type.
|
| *
|
| @@ -58,6 +73,8 @@ class TypeVariableType implements DartType {
|
|
|
| TypeVariableType(this.element);
|
|
|
| + TypeKind get kind => TypeKind.TYPE_VARIABLE;
|
| +
|
| SourceString get name => element.name;
|
|
|
| DartType unalias(Compiler compiler) => this;
|
| @@ -77,8 +94,11 @@ class TypeVariableType implements DartType {
|
| */
|
| class StatementType implements DartType {
|
| final String stringName;
|
| +
|
| Element get element => null;
|
|
|
| + TypeKind get kind => TypeKind.STATEMENT;
|
| +
|
| SourceString get name => new SourceString(stringName);
|
|
|
| const StatementType(this.stringName);
|
| @@ -106,7 +126,11 @@ class StatementType implements DartType {
|
|
|
| class VoidType implements DartType {
|
| const VoidType(this.element);
|
| +
|
| + TypeKind get kind => TypeKind.VOID;
|
| +
|
| SourceString get name => element.name;
|
| +
|
| final VoidElement element;
|
|
|
| DartType unalias(Compiler compiler) => this;
|
| @@ -125,6 +149,8 @@ class InterfaceType implements DartType {
|
| const InterfaceType(this.element,
|
| [this.arguments = const Link<DartType>()]);
|
|
|
| + TypeKind get kind => TypeKind.INTERFACE;
|
| +
|
| SourceString get name => element.name;
|
|
|
| DartType unalias(Compiler compiler) => this;
|
| @@ -168,6 +194,8 @@ class FunctionType implements DartType {
|
| assert(element == null || invariant(element, element.isDeclaration));
|
| }
|
|
|
| + TypeKind get kind => TypeKind.FUNCTION;
|
| +
|
| DartType unalias(Compiler compiler) => this;
|
|
|
| String toString() {
|
| @@ -218,6 +246,8 @@ class TypedefType implements DartType {
|
| const TypedefType(this.element,
|
| [this.typeArguments = const Link<DartType>()]);
|
|
|
| + TypeKind get kind => TypeKind.TYPEDEF;
|
| +
|
| SourceString get name => element.name;
|
|
|
| DartType unalias(Compiler compiler) {
|
|
|