| OLD | NEW |
| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } | 402 } |
| 403 if (classElement.constructors.isEmpty) continue NextClassElement; | 403 if (classElement.constructors.isEmpty) continue NextClassElement; |
| 404 | 404 |
| 405 // TODO(antonm): check with AAR team if there is better approach. | 405 // TODO(antonm): check with AAR team if there is better approach. |
| 406 // As an idea: provide template as a Dart code---class C { C.name(); }--- | 406 // As an idea: provide template as a Dart code---class C { C.name(); }--- |
| 407 // and then overwrite necessary parts. | 407 // and then overwrite necessary parts. |
| 408 var classNode = classElement.parseNode(compiler); | 408 var classNode = classElement.parseNode(compiler); |
| 409 SynthesizedConstructorElementX constructor = | 409 SynthesizedConstructorElementX constructor = |
| 410 new SynthesizedConstructorElementX( | 410 new SynthesizedConstructorElementX( |
| 411 classElement.name, null, classElement, false); | 411 classElement.name, null, classElement, false); |
| 412 constructor.type = new FunctionType( | 412 constructor.type = new FunctionType(constructor, compiler.types.voidType); |
| 413 constructor, | |
| 414 compiler.types.voidType, | |
| 415 const Link<DartType>(), | |
| 416 const Link<DartType>(), | |
| 417 const Link<String>(), | |
| 418 const Link<DartType>() | |
| 419 ); | |
| 420 constructor.cachedNode = new FunctionExpression( | 413 constructor.cachedNode = new FunctionExpression( |
| 421 new Send(classNode.name, synthesizedIdentifier), | 414 new Send(classNode.name, synthesizedIdentifier), |
| 422 new NodeList(new StringToken.fromString(OPEN_PAREN_INFO, '(', -1), | 415 new NodeList(new StringToken.fromString(OPEN_PAREN_INFO, '(', -1), |
| 423 const Link<Node>(), | 416 const Link<Node>(), |
| 424 new StringToken.fromString(CLOSE_PAREN_INFO, ')', -1)), | 417 new StringToken.fromString(CLOSE_PAREN_INFO, ')', -1)), |
| 425 new EmptyStatement( | 418 new EmptyStatement( |
| 426 new StringToken.fromString(SEMICOLON_INFO, ';', -1)), | 419 new StringToken.fromString(SEMICOLON_INFO, ';', -1)), |
| 427 null, Modifiers.EMPTY, null, null); | 420 null, Modifiers.EMPTY, null, null); |
| 428 | 421 |
| 429 if (!constructor.isSynthesized) { | 422 if (!constructor.isSynthesized) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 } | 637 } |
| 645 | 638 |
| 646 compareElements(e0, e1) { | 639 compareElements(e0, e1) { |
| 647 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); | 640 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); |
| 648 if (result != 0) return result; | 641 if (result != 0) return result; |
| 649 return compareBy((e) => e.position().charOffset)(e0, e1); | 642 return compareBy((e) => e.position().charOffset)(e0, e1); |
| 650 } | 643 } |
| 651 | 644 |
| 652 List<Element> sortElements(Iterable<Element> elements) => | 645 List<Element> sortElements(Iterable<Element> elements) => |
| 653 sorted(elements, compareElements); | 646 sorted(elements, compareElements); |
| OLD | NEW |