| Index: lib/compiler/implementation/typechecker.dart
|
| diff --git a/lib/compiler/implementation/typechecker.dart b/lib/compiler/implementation/typechecker.dart
|
| index 81d0e23b79122ace3890b14866f392a2fe225bd8..36e176c17aaf4c91eb1e4ac52ad8c605ff248236 100644
|
| --- a/lib/compiler/implementation/typechecker.dart
|
| +++ b/lib/compiler/implementation/typechecker.dart
|
| @@ -26,9 +26,26 @@ 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');
|
| +
|
| + String toString() => id;
|
| +}
|
| +
|
| abstract class DartType {
|
| abstract SourceString get name;
|
|
|
| + abstract TypeKind get kind;
|
| +
|
| /**
|
| * Returns the [Element] which declared this type.
|
| *
|
| @@ -60,6 +77,8 @@ class TypeVariableType implements DartType {
|
|
|
| TypeVariableType(this.element);
|
|
|
| + TypeKind get kind => TypeKind.TYPE_VARIABLE;
|
| +
|
| SourceString get name => element.name;
|
|
|
| DartType unalias(Compiler compiler) => this;
|
| @@ -79,8 +98,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);
|
| @@ -108,7 +130,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;
|
| @@ -127,6 +153,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;
|
| @@ -170,6 +198,8 @@ class FunctionType implements DartType {
|
| assert(element == null || invariant(element, element.isDeclaration));
|
| }
|
|
|
| + TypeKind get kind => TypeKind.FUNCTION;
|
| +
|
| DartType unalias(Compiler compiler) => this;
|
|
|
| String toString() {
|
| @@ -220,6 +250,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) {
|
|
|