From c30a4331b8ff02c0fb4dcdddc0471ea54a75cebd Mon Sep 17 00:00:00 2001 From: "johnniwinther@google.com" Date: Fri, 3 Aug 2012 12:43:21 +0000 Subject: [PATCH] Move TypeDefinitionVisitor. Review URL: https://chromiumcodereview.appspot.com//10832131 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10228 260f80e4-7a28-3924-810f-c04153c831b5 --- lib/compiler/implementation/resolver.dart | 104 +++++++++++----------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart index 8f6842d9a23..246a546edf7 100644 --- a/lib/compiler/implementation/resolver.dart +++ b/lib/compiler/implementation/resolver.dart @@ -1657,6 +1657,58 @@ class ResolverVisitor extends CommonResolverVisitor { } } +class TypeDefinitionVisitor extends CommonResolverVisitor { + Scope scope; + TypeDeclarationElement element; + TypeResolver typeResolver; + + TypeDefinitionVisitor(Compiler compiler, TypeDeclarationElement element) + : this.element = element, + scope = element.enclosingElement.buildScope(), + typeResolver = new TypeResolver(compiler), + super(compiler); + + void resolveTypeVariableBounds(NodeList node) { + if (node === null) return; + + var nameSet = new Set(); + // Resolve the bounds of type variables. + Link typeLink = element.typeVariables; + Link nodeLink = node.nodes; + while (!nodeLink.isEmpty()) { + TypeVariableType typeVariable = typeLink.head; + SourceString typeName = typeVariable.name; + TypeVariable typeNode = nodeLink.head; + if (nameSet.contains(typeName)) { + error(typeNode, MessageKind.DUPLICATE_TYPE_VARIABLE_NAME, [typeName]); + } + nameSet.add(typeName); + + TypeVariableElement variableElement = typeVariable.element; + if (typeNode.bound !== null) { + Type boundType = typeResolver.resolveTypeAnnotation( + typeNode.bound, inScope: scope, onFailure: warning); + if (boundType !== null && boundType.element == variableElement) { + // TODO(johnniwinther): Check for more general cycles, like + // [: :]. + warning(node, MessageKind.CYCLIC_TYPE_VARIABLE, + [variableElement.name]); + } else if (boundType !== null) { + variableElement.bound = boundType; + } else { + // TODO(johnniwinther): Should be an erroneous type. + variableElement.bound = compiler.objectClass.computeType(compiler); + } + } else { + variableElement.bound = compiler.objectClass.computeType(compiler); + } + nodeLink = nodeLink.tail; + typeLink = typeLink.tail; + } + assert(typeLink.isEmpty()); + } +} + class ClassResolverVisitor extends TypeDefinitionVisitor { ClassElement get element() => super.element; @@ -1854,58 +1906,6 @@ class ClassResolverVisitor extends TypeDefinitionVisitor { } } -class TypeDefinitionVisitor extends CommonResolverVisitor { - Scope scope; - TypeDeclarationElement element; - TypeResolver typeResolver; - - TypeDefinitionVisitor(Compiler compiler, TypeDeclarationElement element) - : this.element = element, - scope = element.enclosingElement.buildScope(), - typeResolver = new TypeResolver(compiler), - super(compiler); - - void resolveTypeVariableBounds(NodeList node) { - if (node === null) return; - - var nameSet = new Set(); - // Resolve the bounds of type variables. - Link typeLink = element.typeVariables; - Link nodeLink = node.nodes; - while (!nodeLink.isEmpty()) { - TypeVariableType typeVariable = typeLink.head; - SourceString typeName = typeVariable.name; - TypeVariable typeNode = nodeLink.head; - if (nameSet.contains(typeName)) { - error(typeNode, MessageKind.DUPLICATE_TYPE_VARIABLE_NAME, [typeName]); - } - nameSet.add(typeName); - - TypeVariableElement variableElement = typeVariable.element; - if (typeNode.bound !== null) { - Type boundType = typeResolver.resolveTypeAnnotation( - typeNode.bound, inScope: scope, onFailure: warning); - if (boundType !== null && boundType.element == variableElement) { - // TODO(johnniwinther): Check for more general cycles, like - // [: :]. - warning(node, MessageKind.CYCLIC_TYPE_VARIABLE, - [variableElement.name]); - } else if (boundType !== null) { - variableElement.bound = boundType; - } else { - // TODO(johnniwinther): Should be an erroneous type. - variableElement.bound = compiler.objectClass.computeType(compiler); - } - } else { - variableElement.bound = compiler.objectClass.computeType(compiler); - } - nodeLink = nodeLink.tail; - typeLink = typeLink.tail; - } - assert(typeLink.isEmpty()); - } -} - class VariableDefinitionsVisitor extends CommonResolverVisitor { VariableDefinitions definitions; ResolverVisitor resolver;