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 /** A formal parameter to a [Method]. */ | 5 /** A formal parameter to a [Method]. */ |
6 class Parameter { | 6 class Parameter { |
7 FormalNode definition; | 7 FormalNode definition; |
8 Member method; | 8 Member method; |
9 | 9 |
10 String name; | 10 String name; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 bool get hasDefaultValue() => | 80 bool get hasDefaultValue() => |
81 definition.value.span.start != definition.span.start; | 81 definition.value.span.start != definition.span.start; |
82 } | 82 } |
83 | 83 |
84 | 84 |
85 class Member extends Element { | 85 class Member extends Element { |
86 final Type declaringType; | 86 final Type declaringType; |
87 | 87 |
88 Member genericMember; | 88 Member genericMember; |
89 | 89 |
| 90 // A root string for getter and setter names. This is used e.g. to ensure |
| 91 // that fields with the same Dart name but different jsnames (due to native |
| 92 // name directives) still have a common getter name. Is null when there is no |
| 93 // renaming. |
| 94 String _jsnameRoot; |
| 95 |
90 Member(String name, Type declaringType) | 96 Member(String name, Type declaringType) |
91 : this.declaringType = declaringType, | 97 : this.declaringType = declaringType, |
92 super(name, declaringType); | 98 super(name, declaringType); |
93 | 99 |
94 String mangleJsName() { | 100 String mangleJsName() { |
95 var mangled = super.mangleJsName(); | 101 var mangled = super.mangleJsName(); |
96 if (declaringType != null && declaringType.isTop) { | 102 if (declaringType != null && declaringType.isTop) { |
97 return JsNames.getValid(mangled); | 103 return JsNames.getValid(mangled); |
98 } else { | 104 } else { |
99 // We don't need to mangle native member names unless | 105 // We don't need to mangle native member names unless |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 bool _provideSetter = false; | 139 bool _provideSetter = false; |
134 | 140 |
135 bool get isNative() => false; | 141 bool get isNative() => false; |
136 String get constructorName() { | 142 String get constructorName() { |
137 world.internalError('cannot be a constructor', span); | 143 world.internalError('cannot be a constructor', span); |
138 } | 144 } |
139 | 145 |
140 void provideGetter() {} | 146 void provideGetter() {} |
141 void provideSetter() {} | 147 void provideSetter() {} |
142 | 148 |
| 149 String get jsnameOfGetter() => 'get\$$jsnameRoot'; |
| 150 String get jsnameOfSetter() => 'set\$$jsnameRoot'; |
| 151 String get jsnameRoot() => _jsnameRoot != null ? _jsnameRoot : _jsname; |
| 152 |
143 Member get initDelegate() { | 153 Member get initDelegate() { |
144 world.internalError('cannot have initializers', span); | 154 world.internalError('cannot have initializers', span); |
145 } | 155 } |
146 void set initDelegate(ctor) { | 156 void set initDelegate(ctor) { |
147 world.internalError('cannot have initializers', span); | 157 world.internalError('cannot have initializers', span); |
148 } | 158 } |
149 | 159 |
150 Value computeValue() { | 160 Value computeValue() { |
151 world.internalError('cannot have value', span); | 161 world.internalError('cannot have value', span); |
152 } | 162 } |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 _provideOptionalParamInfo = true; | 883 _provideOptionalParamInfo = true; |
874 if (isStatic) { | 884 if (isStatic) { |
875 // ensure the type is generated. | 885 // ensure the type is generated. |
876 // TODO(sigmund): can we avoid generating the entire type, but only what | 886 // TODO(sigmund): can we avoid generating the entire type, but only what |
877 // we need? | 887 // we need? |
878 declaringType.markUsed(); | 888 declaringType.markUsed(); |
879 var type = declaringType.isTop ? '' : '${declaringType.jsname}.'; | 889 var type = declaringType.isTop ? '' : '${declaringType.jsname}.'; |
880 return new Value(functionType, '$type$jsname', node.span); | 890 return new Value(functionType, '$type$jsname', node.span); |
881 } | 891 } |
882 _provideGetter = true; | 892 _provideGetter = true; |
883 return new Value(functionType, '${target.code}.get\$$jsname()', node.span); | 893 return new Value(functionType, '${target.code}.$jsnameOfGetter()', node.span
); |
884 } | 894 } |
885 | 895 |
886 /** | 896 /** |
887 * Checks if the named arguments are in their natural or 'home' positions, | 897 * Checks if the named arguments are in their natural or 'home' positions, |
888 * i.e. they may be passed directly without inserting, deleting or moving the | 898 * i.e. they may be passed directly without inserting, deleting or moving the |
889 * arguments to correspond with the parameters. | 899 * arguments to correspond with the parameters. |
890 */ | 900 */ |
891 bool namesInHomePositions(Arguments args) { | 901 bool namesInHomePositions(Arguments args) { |
892 if (!args.hasNames) return true; | 902 if (!args.hasNames) return true; |
893 | 903 |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 f(member); | 1435 f(member); |
1426 }); | 1436 }); |
1427 }); | 1437 }); |
1428 } | 1438 } |
1429 | 1439 |
1430 bool isEmpty() { | 1440 bool isEmpty() { |
1431 return factories.getValues() | 1441 return factories.getValues() |
1432 .every((Map constructors) => constructors.isEmpty()); | 1442 .every((Map constructors) => constructors.isEmpty()); |
1433 } | 1443 } |
1434 } | 1444 } |
OLD | NEW |