| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * Represents a meta-value for code generation. | 6 * Represents a meta-value for code generation. |
| 7 */ | 7 */ |
| 8 class Value { | 8 class Value { |
| 9 /** The [Type] of the [Value]. */ | 9 /** The [Type] of the [Value]. */ |
| 10 Type type; | 10 Type type; |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 var name = "const\$$uniqueId"; | 638 var name = "const\$$uniqueId"; |
| 639 var codeWithComment = "$name/*${exp.span.text}*/"; | 639 var codeWithComment = "$name/*${exp.span.text}*/"; |
| 640 return new GlobalValue( | 640 return new GlobalValue( |
| 641 exp.type, codeWithComment, true, null, name, exp, name, | 641 exp.type, codeWithComment, true, null, name, exp, name, |
| 642 exp.span, | 642 exp.span, |
| 643 dependencies.filter((d) => d is GlobalValue)); | 643 dependencies.filter((d) => d is GlobalValue)); |
| 644 } | 644 } |
| 645 | 645 |
| 646 GlobalValue(Type type, String code, bool isConst, | 646 GlobalValue(Type type, String code, bool isConst, |
| 647 this.field, this.name, this.exp, this.canonicalCode, | 647 this.field, this.name, this.exp, this.canonicalCode, |
| 648 SourceSpan span, this.dependencies) | 648 SourceSpan span, List<GlobalValue> _dependencies) |
| 649 : super(type, code, span, !isConst); | 649 : super(type, code, span, !isConst), dependencies = [] { |
| 650 // store transitive-dependencies so sorting algorithm works correctly. |
| 651 for (final dep in _dependencies) { |
| 652 dependencies.add(dep); |
| 653 dependencies.addAll(dep.dependencies); |
| 654 } |
| 655 } |
| 650 | 656 |
| 651 int compareTo(GlobalValue other) { | 657 int compareTo(GlobalValue other) { |
| 652 // order by dependencies, o.w. by name | 658 // order by dependencies, o.w. by name |
| 653 if (other == this) { | 659 if (other == this) { |
| 654 return 0; | 660 return 0; |
| 655 } else if (dependencies.indexOf(other, 0) >= 0) { | 661 } else if (dependencies.indexOf(other, 0) >= 0) { |
| 656 return 1; | 662 return 1; |
| 657 } else if (other.dependencies.indexOf(this, 0) >= 0) { | 663 } else if (other.dependencies.indexOf(this, 0) >= 0) { |
| 658 return -1; | 664 return -1; |
| 659 } else if (dependencies.length > other.dependencies.length) { | 665 } else if (dependencies.length > other.dependencies.length) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 // Then look for members in my library. | 714 // Then look for members in my library. |
| 709 member = home.library.lookup(name, span); | 715 member = home.library.lookup(name, span); |
| 710 if (member != null) { | 716 if (member != null) { |
| 711 return member; | 717 return member; |
| 712 } | 718 } |
| 713 | 719 |
| 714 _ensureCode(); | 720 _ensureCode(); |
| 715 return null; | 721 return null; |
| 716 } | 722 } |
| 717 } | 723 } |
| OLD | NEW |