Chromium Code Reviews| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 /** | 127 /** |
| 128 * True if this class (or some related class that is not Object) overrides | 128 * True if this class (or some related class that is not Object) overrides |
| 129 * noSuchMethod. If it does we suppress warnings about unknown members. | 129 * noSuchMethod. If it does we suppress warnings about unknown members. |
| 130 */ | 130 */ |
| 131 // TODO(jmesserly): should we be doing this? | 131 // TODO(jmesserly): should we be doing this? |
| 132 bool _hasOverriddenNoSuchMethod() { | 132 bool _hasOverriddenNoSuchMethod() { |
| 133 if (isSuper) { | 133 if (isSuper) { |
| 134 var m = type.getMember('noSuchMethod'); | 134 var m = type.getMember('noSuchMethod'); |
| 135 return m != null && !m.declaringType.isObject; | 135 return m != null && !m.declaringType.isObject; |
| 136 } else { | 136 } else { |
| 137 return type.resolveMember('noSuchMethod').members.length > 1; | 137 var m = type.resolveMember('noSuchMethod'); |
|
jimhug
2011/11/18 17:05:29
Funny, I have this same change sitting in my curre
| |
| 138 return m != null && m.members.length > 1; | |
| 138 } | 139 } |
| 139 } | 140 } |
| 140 | 141 |
| 141 _tryResolveMember(MethodGenerator context, String name) { | 142 _tryResolveMember(MethodGenerator context, String name) { |
| 142 if (isSuper) { | 143 if (isSuper) { |
| 143 return type.getMember(name); | 144 return type.getMember(name); |
| 144 } else { | 145 } else { |
| 145 return type.resolveMember(name); | 146 return type.resolveMember(name); |
| 146 } | 147 } |
| 147 } | 148 } |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 677 * of resolving members. | 678 * of resolving members. |
| 678 */ | 679 */ |
| 679 class BareValue extends Value { | 680 class BareValue extends Value { |
| 680 MethodGenerator home; | 681 MethodGenerator home; |
| 681 | 682 |
| 682 BareValue(this.home, MethodGenerator outermost, SourceSpan span) | 683 BareValue(this.home, MethodGenerator outermost, SourceSpan span) |
| 683 : super(outermost.method.declaringType, null, span, false) { | 684 : super(outermost.method.declaringType, null, span, false) { |
| 684 isType = outermost.isStatic; | 685 isType = outermost.isStatic; |
| 685 } | 686 } |
| 686 | 687 |
| 688 // TODO(jimhug): Lazy initialization here is weird! | |
| 689 _ensureCode() { | |
| 690 if (code != null) return; | |
| 691 if (isType) { | |
| 692 code = type.jsname; | |
| 693 } else { | |
| 694 code = home._makeThisCode(); | |
| 695 } | |
| 696 } | |
| 697 | |
| 687 _tryResolveMember(MethodGenerator context, String name) { | 698 _tryResolveMember(MethodGenerator context, String name) { |
| 688 assert(context == home); | 699 assert(context == home); |
| 689 | 700 |
| 690 // First look for members directly defined on my type. | 701 // First look for members directly defined on my type. |
| 691 var member = type.resolveMember(name); | 702 var member = type.resolveMember(name); |
| 692 if (member != null) { | 703 if (member != null) { |
| 693 assert(code == null); | 704 _ensureCode(); |
| 694 // TODO(jimhug): Lazy initialization here is weird! | |
| 695 if (isType) { | |
| 696 code = type.jsname; | |
| 697 } else { | |
| 698 code = home._makeThisCode(); | |
| 699 } | |
| 700 return member; | 705 return member; |
| 701 } | 706 } |
| 702 | 707 |
| 703 // Then look for members in my library. | 708 // Then look for members in my library. |
| 704 member = home.library.lookup(name, span); | 709 member = home.library.lookup(name, span); |
| 705 if (member != null) { | 710 if (member != null) { |
| 706 return member; | 711 return member; |
| 707 } | 712 } |
| 708 | 713 |
| 714 _ensureCode(); | |
| 709 return null; | 715 return null; |
| 710 } | 716 } |
| 711 } | 717 } |
| OLD | NEW |