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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart

Issue 19754002: Rewrite how we handle synthesized constructors in the compiler. This was motivated by issue https:/… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 dart_backend; 5 part of dart_backend;
6 6
7 // TODO(ahe): This class is simply wrong. This backend should use 7 // TODO(ahe): This class is simply wrong. This backend should use
8 // elements when it can, not AST nodes. Perhaps a [Map<Element, 8 // elements when it can, not AST nodes. Perhaps a [Map<Element,
9 // TreeElements>] is what is needed. 9 // TreeElements>] is what is needed.
10 class ElementAst { 10 class ElementAst {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 for (Element member in classMembers[classElement]) { 349 for (Element member in classMembers[classElement]) {
350 if (member.isConstructor()) continue NextClassElement; 350 if (member.isConstructor()) continue NextClassElement;
351 } 351 }
352 if (classElement.constructors.isEmpty) continue NextClassElement; 352 if (classElement.constructors.isEmpty) continue NextClassElement;
353 353
354 // TODO(antonm): check with AAR team if there is better approach. 354 // TODO(antonm): check with AAR team if there is better approach.
355 // As an idea: provide template as a Dart code---class C { C.name(); }--- 355 // As an idea: provide template as a Dart code---class C { C.name(); }---
356 // and then overwrite necessary parts. 356 // and then overwrite necessary parts.
357 var classNode = classElement.parseNode(compiler); 357 var classNode = classElement.parseNode(compiler);
358 SynthesizedConstructorElementX constructor = 358 SynthesizedConstructorElementX constructor =
359 new SynthesizedConstructorElementX(classElement); 359 new SynthesizedConstructorElementX(
360 classElement.name, null, classElement);
360 constructor.type = new FunctionType( 361 constructor.type = new FunctionType(
361 constructor, 362 constructor,
362 compiler.types.voidType, 363 compiler.types.voidType,
363 const Link<DartType>(), 364 const Link<DartType>(),
364 const Link<DartType>(), 365 const Link<DartType>(),
365 const Link<SourceString>(), 366 const Link<SourceString>(),
366 const Link<DartType>() 367 const Link<DartType>()
367 ); 368 );
368 constructor.cachedNode = new FunctionExpression( 369 constructor.cachedNode = new FunctionExpression(
369 new Send(classNode.name, synthesizedIdentifier), 370 new Send(classNode.name, synthesizedIdentifier),
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 } 546 }
546 547
547 compareElements(e0, e1) { 548 compareElements(e0, e1) {
548 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); 549 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1);
549 if (result != 0) return result; 550 if (result != 0) return result;
550 return compareBy((e) => e.position().charOffset)(e0, e1); 551 return compareBy((e) => e.position().charOffset)(e0, e1);
551 } 552 }
552 553
553 List<Element> sortElements(Iterable<Element> elements) => 554 List<Element> sortElements(Iterable<Element> elements) =>
554 sorted(elements, compareElements); 555 sorted(elements, compareElements);
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | sdk/lib/_internal/compiler/implementation/deferred_load.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698