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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 10832136: Skeleton typedef type implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased and updated cf. comments Created 8 years, 4 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
« no previous file with comments | « lib/compiler/implementation/native_handler.dart ('k') | lib/compiler/implementation/typechecker.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 7b043fa1d85182488b67a8fae719e8a1fbe0f236..6ac1473a816ec5e709987bae1f39bb68294130c7 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -368,12 +368,20 @@ class ResolverTask extends CompilerTask {
compiler, node.parameters, node.returnType, element));
}
- FunctionSignature resolveTypedef(TypedefElement element) {
+ void resolveTypedef(TypedefElement element) {
+ if (element.isResolved || element.isBeingResolved) return;
+ element.isBeingResolved = true;
return compiler.withCurrentElement(element, () {
- Typedef node =
+ measure(() {
+ Typedef node =
compiler.parser.measure(() => element.parseNode(compiler));
- return measure(() => SignatureResolver.analyze(
- compiler, node.formals, node.returnType, element));
+ TypedefResolverVisitor visitor =
+ new TypedefResolverVisitor(compiler, element);
+ visitor.visit(node);
+
+ element.isBeingResolved = false;
+ element.isResolved = true;
+ });
});
}
@@ -809,7 +817,19 @@ class TypeResolver {
type = new InterfaceType(cls, arguments);
}
} else if (element.isTypedef()) {
- type = element.computeType(compiler);
+ TypedefElement typdef = element;
+ // TODO(ahe): Should be [ensureResolved].
+ compiler.resolveTypedef(typdef);
+ typdef.computeType(compiler);
+ Link<Type> arguments = resolveTypeArguments(
+ node, typdef.typeVariables,
+ scope, onFailure, whenResolved);
+ if (typdef.typeVariables.isEmpty() && arguments.isEmpty()) {
+ // Return the canonical type if it has no type parameters.
+ type = typdef.computeType(compiler);
+ } else {
+ type = new TypedefType(typdef, arguments);
+ }
} else if (element.isTypeVariable()) {
type = element.computeType(compiler);
} else {
@@ -1782,6 +1802,27 @@ class TypeDefinitionVisitor extends CommonResolverVisitor<Type> {
}
}
+class TypedefResolverVisitor extends TypeDefinitionVisitor {
+ TypedefElement get element() => super.element;
+
+ TypedefResolverVisitor(Compiler compiler, TypedefElement typedefElement)
+ : super(compiler, typedefElement);
+
+ visitTypedef(Typedef node) {
+ TypedefType type = element.computeType(compiler);
+ scope = new TypeDeclarationScope(scope, element);
+ resolveTypeVariableBounds(node.typeParameters);
+
+ element.functionSignature = SignatureResolver.analyze(
+ compiler, node.formals, node.returnType, element);
+
+ element.alias = compiler.computeFunctionType(
+ element, element.functionSignature);
+
+ // TODO(johnniwinther): Check for cyclic references in the typedef alias.
+ }
+}
+
/**
* The implementation of [ResolverTask.resolveClass].
*
« no previous file with comments | « lib/compiler/implementation/native_handler.dart ('k') | lib/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698