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

Side by Side Diff: pkg/compiler/lib/src/resolution/class_hierarchy.dart

Issue 1192103002: Support serialization of the compiler backbone. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of resolution; 5 part of resolution;
6 6
7 class TypeDefinitionVisitor extends MappingVisitor<DartType> { 7 class TypeDefinitionVisitor extends MappingVisitor<DartType> {
8 Scope scope; 8 Scope scope;
9 final TypeDeclarationElement enclosingElement; 9 final TypeDeclarationElement enclosingElement;
10 TypeDeclarationElement get element => enclosingElement; 10 TypeDeclarationElement get element => enclosingElement;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 String superName = supertype.name; 263 String superName = supertype.name;
264 String mixinName = mixinType.name; 264 String mixinName = mixinType.name;
265 MixinApplicationElementX mixinApplication = new MixinApplicationElementX( 265 MixinApplicationElementX mixinApplication = new MixinApplicationElementX(
266 "${superName}+${mixinName}", 266 "${superName}+${mixinName}",
267 element.compilationUnit, 267 element.compilationUnit,
268 compiler.getNextFreeClassId(), 268 compiler.getNextFreeClassId(),
269 node, 269 node,
270 new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT)); 270 new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT));
271 // Create synthetic type variables for the mixin application. 271 // Create synthetic type variables for the mixin application.
272 List<DartType> typeVariables = <DartType>[]; 272 List<DartType> typeVariables = <DartType>[];
273 int index = 0;
273 element.typeVariables.forEach((TypeVariableType type) { 274 element.typeVariables.forEach((TypeVariableType type) {
floitsch 2015/06/26 20:54:04 Since this closure captures something I would slig
Johnni Winther 2015/07/03 12:13:44 Done.
274 TypeVariableElementX typeVariableElement = new TypeVariableElementX( 275 TypeVariableElementX typeVariableElement = new TypeVariableElementX(
275 type.name, mixinApplication, type.element.node); 276 type.name, mixinApplication, index, type.element.node);
276 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); 277 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement);
277 typeVariables.add(typeVariable); 278 typeVariables.add(typeVariable);
279 index++;
278 }); 280 });
279 // Setup bounds on the synthetic type variables. 281 // Setup bounds on the synthetic type variables.
280 int index = 0;
281 element.typeVariables.forEach((TypeVariableType type) { 282 element.typeVariables.forEach((TypeVariableType type) {
282 TypeVariableType typeVariable = typeVariables[index++]; 283 TypeVariableType typeVariable = typeVariables[type.element.index];
283 TypeVariableElementX typeVariableElement = typeVariable.element; 284 TypeVariableElementX typeVariableElement = typeVariable.element;
284 typeVariableElement.typeCache = typeVariable; 285 typeVariableElement.typeCache = typeVariable;
285 typeVariableElement.boundCache = 286 typeVariableElement.boundCache =
286 type.element.bound.subst(typeVariables, element.typeVariables); 287 type.element.bound.subst(typeVariables, element.typeVariables);
287 }); 288 });
288 // Setup this and raw type for the mixin application. 289 // Setup this and raw type for the mixin application.
289 mixinApplication.computeThisAndRawType(compiler, typeVariables); 290 mixinApplication.computeThisAndRawType(compiler, typeVariables);
290 // Substitute in synthetic type variables in super and mixin types. 291 // Substitute in synthetic type variables in super and mixin types.
291 supertype = supertype.subst(typeVariables, element.typeVariables); 292 supertype = supertype.subst(typeVariables, element.typeVariables);
292 mixinType = mixinType.subst(typeVariables, element.typeVariables); 293 mixinType = mixinType.subst(typeVariables, element.typeVariables);
293 294
294 doApplyMixinTo(mixinApplication, supertype, mixinType); 295 doApplyMixinTo(mixinApplication, supertype, mixinType);
295 mixinApplication.resolutionState = STATE_DONE; 296 mixinApplication.resolutionState = STATE_DONE;
296 mixinApplication.supertypeLoadState = STATE_DONE; 297 mixinApplication.supertypeLoadState = STATE_DONE;
297 // Replace the synthetic type variables by the original type variables in 298 // Replace the synthetic type variables by the original type variables in
298 // the returned type (which should be the type actually extended). 299 // the returned type (which should be the type actually extended).
299 InterfaceType mixinThisType = mixinApplication.thisType; 300 InterfaceType mixinThisType = mixinApplication.thisType;
300 return mixinThisType.subst(element.typeVariables, 301 return mixinThisType.subst(element.typeVariables,
301 mixinThisType.typeArguments); 302 mixinThisType.typeArguments);
302 } 303 }
303 304
304 bool isDefaultConstructor(FunctionElement constructor) { 305 bool isDefaultConstructor(FunctionElement constructor) {
305 if (constructor.name != '') return false; 306 if (constructor.name != '') return false;
306 constructor.computeType(compiler); 307 constructor.computeType(compiler);
307 return constructor.functionSignature.parameterCount == 0; 308 return constructor.functionSignature.parameterCount == 0;
308 } 309 }
309 310
310 FunctionElement createForwardingConstructor(ConstructorElement target, 311 FunctionElement createForwardingConstructor(ConstructorElement target,
311 ClassElement enclosing) { 312 ClassElement enclosing) {
312 return new SynthesizedConstructorElementX.notForDefault( 313 FunctionElement constructor =
313 target.name, target, enclosing); 314 new SynthesizedConstructorElementX.notForDefault(
315 target.name, target, enclosing);
316 constructor.computeType(compiler);
317 return constructor;
314 } 318 }
315 319
316 void doApplyMixinTo(MixinApplicationElementX mixinApplication, 320 void doApplyMixinTo(MixinApplicationElementX mixinApplication,
317 DartType supertype, 321 DartType supertype,
318 DartType mixinType) { 322 DartType mixinType) {
319 Node node = mixinApplication.parseNode(compiler); 323 Node node = mixinApplication.parseNode(compiler);
320 324
321 if (mixinApplication.supertype != null) { 325 if (mixinApplication.supertype != null) {
322 // [supertype] is not null if there was a cycle. 326 // [supertype] is not null if there was a cycle.
323 assert(invariant(node, compiler.compilationFailed)); 327 assert(invariant(node, compiler.compilationFailed));
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 class ClassSupertypeResolver extends CommonResolverVisitor { 563 class ClassSupertypeResolver extends CommonResolverVisitor {
560 Scope context; 564 Scope context;
561 ClassElement classElement; 565 ClassElement classElement;
562 566
563 ClassSupertypeResolver(Compiler compiler, ClassElement cls) 567 ClassSupertypeResolver(Compiler compiler, ClassElement cls)
564 : context = Scope.buildEnclosingScope(cls), 568 : context = Scope.buildEnclosingScope(cls),
565 this.classElement = cls, 569 this.classElement = cls,
566 super(compiler); 570 super(compiler);
567 571
568 void loadSupertype(ClassElement element, Node from) { 572 void loadSupertype(ClassElement element, Node from) {
569 compiler.resolver.loadSupertypes(element, from); 573 if (!element.isResolved) {
570 element.ensureResolved(compiler); 574 compiler.resolver.loadSupertypes(element, from);
575 element.ensureResolved(compiler);
576 }
571 } 577 }
572 578
573 void visitNodeList(NodeList node) { 579 void visitNodeList(NodeList node) {
574 if (node != null) { 580 if (node != null) {
575 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { 581 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) {
576 link.head.accept(this); 582 link.head.accept(this);
577 } 583 }
578 } 584 }
579 } 585 }
580 586
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 Identifier selector = node.selector.asIdentifier(); 636 Identifier selector = node.selector.asIdentifier();
631 var e = prefixElement.lookupLocalMember(selector.source); 637 var e = prefixElement.lookupLocalMember(selector.source);
632 if (e == null || !e.impliesType) { 638 if (e == null || !e.impliesType) {
633 error(node.selector, MessageKind.CANNOT_RESOLVE_TYPE, 639 error(node.selector, MessageKind.CANNOT_RESOLVE_TYPE,
634 {'typeName': node.selector}); 640 {'typeName': node.selector});
635 return; 641 return;
636 } 642 }
637 loadSupertype(e, node); 643 loadSupertype(e, node);
638 } 644 }
639 } 645 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698