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

Side by Side Diff: frog/member.dart

Issue 9465041: Better mangling in frog for fixing parts of issue 1837. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « frog/leg/ssa/js_names.dart ('k') | frog/member_set.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Member(String name, Type declaringType) 90 Member(String name, Type declaringType)
91 : this.declaringType = declaringType, 91 : this.declaringType = declaringType,
92 super(name, declaringType); 92 super(name, declaringType) {
93 if (_jsname != null && declaringType.isTop) {
94 _jsname = JsNames.getValid(_jsname);
95 }
96 }
93 97
94 abstract bool get isStatic(); 98 abstract bool get isStatic();
95 abstract Type get returnType(); 99 abstract Type get returnType();
96 100
97 abstract bool get canGet(); 101 abstract bool get canGet();
98 abstract bool get canSet(); 102 abstract bool get canSet();
99 103
100 Library get library() => declaringType.library; 104 Library get library() => declaringType.library;
101 105
102 bool get isPrivate() => name !== null && name.startsWith('_'); 106 bool get isPrivate() => name !== null && name.startsWith('_');
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 var code = null; 1145 var code = null;
1142 if (args.length == 0) { 1146 if (args.length == 0) {
1143 if (name == ':negate') { 1147 if (name == ':negate') {
1144 code = '-${target.code}'; 1148 code = '-${target.code}';
1145 } else if (name == ':bit_not') { 1149 } else if (name == ':bit_not') {
1146 code = '~${target.code}'; 1150 code = '~${target.code}';
1147 } 1151 }
1148 } else if (args.length == 1 && args.values[0].type.isNum) { 1152 } else if (args.length == 1 && args.values[0].type.isNum) {
1149 if (name == ':truncdiv' || name == ':mod') { 1153 if (name == ':truncdiv' || name == ':mod') {
1150 world.gen.corejs.useOperator(name); 1154 world.gen.corejs.useOperator(name);
1151 code = '\$$jsname(${target.code}, ${argsCode[0]})'; 1155 code = '$jsname\$(${target.code}, ${argsCode[0]})';
1152 } else { 1156 } else {
1153 var op = TokenKind.rawOperatorFromMethod(name); 1157 var op = TokenKind.rawOperatorFromMethod(name);
1154 code = '${target.code} $op ${argsCode[0]}'; 1158 code = '${target.code} $op ${argsCode[0]}';
1155 } 1159 }
1156 } 1160 }
1157 if (code !== null) { 1161 if (code !== null) {
1158 return new Value(inferredResult, code, node.span); 1162 return new Value(inferredResult, code, node.span);
1159 } 1163 }
1160 } else if (target.type.isString) { 1164 } else if (target.type.isString) {
1161 if (name == ':index' && args.values[0].type.isNum) { 1165 if (name == ':index' && args.values[0].type.isNum) {
(...skipping 28 matching lines...) Expand all
1190 if (argsCode[0] == 'null') { 1194 if (argsCode[0] == 'null') {
1191 return new Value(inferredResult, '${target.code} $op null', node.span); 1195 return new Value(inferredResult, '${target.code} $op null', node.span);
1192 } else if (target.type.isNum || target.type.isString) { 1196 } else if (target.type.isNum || target.type.isString) {
1193 // TODO(jimhug): Maybe check rhs. 1197 // TODO(jimhug): Maybe check rhs.
1194 return new Value(inferredResult, '${target.code} $op ${argsCode[0]}', 1198 return new Value(inferredResult, '${target.code} $op ${argsCode[0]}',
1195 node.span); 1199 node.span);
1196 } 1200 }
1197 world.gen.corejs.useOperator(name); 1201 world.gen.corejs.useOperator(name);
1198 // TODO(jimhug): Should be able to use faster path sometimes here! 1202 // TODO(jimhug): Should be able to use faster path sometimes here!
1199 return new Value(inferredResult, 1203 return new Value(inferredResult,
1200 '\$$jsname(${target.code}, ${argsCode[0]})', node.span); 1204 '$jsname\$(${target.code}, ${argsCode[0]})', node.span);
1201 } 1205 }
1202 1206
1203 if (isCallMethod) { 1207 if (isCallMethod) {
1204 declaringType.markUsed(); 1208 declaringType.markUsed();
1205 return new Value(inferredResult, 1209 return new Value(inferredResult,
1206 '${target.code}(${Strings.join(argsCode, ", ")})', node.span); 1210 '${target.code}(${Strings.join(argsCode, ", ")})', node.span);
1207 } 1211 }
1208 1212
1209 // TODO(jimhug): Reconcile with MethodSet version - ideally just eliminate 1213 // TODO(jimhug): Reconcile with MethodSet version - ideally just eliminate
1210 if (name == ':index') { 1214 if (name == ':index') {
1211 world.gen.corejs.useIndex = true; 1215 world.gen.corejs.useIndex = true;
1212 } else if (name == ':setindex') { 1216 } else if (name == ':setindex') {
1213 world.gen.corejs.useSetIndex = true; 1217 world.gen.corejs.useSetIndex = true;
1214 } else { 1218 } else {
1215 world.gen.corejs.useOperator(name); 1219 world.gen.corejs.useOperator(name);
1216 var argsString = argsCode.length == 0 ? '' : ', ${argsCode[0]}'; 1220 var argsString = argsCode.length == 0 ? '' : ', ${argsCode[0]}';
1217 return new Value(returnType, '\$$jsname(${target.code}${argsString})', 1221 return new Value(returnType, '$jsname\$(${target.code}${argsString})',
1218 node.span); 1222 node.span);
1219 } 1223 }
1220 1224
1221 // Fall back to normal method invocation. 1225 // Fall back to normal method invocation.
1222 var argsString = Strings.join(argsCode, ', '); 1226 var argsString = Strings.join(argsCode, ', ');
1223 return new Value(inferredResult, '${target.code}.$jsname($argsString)', 1227 return new Value(inferredResult, '${target.code}.$jsname($argsString)',
1224 node.span); 1228 node.span);
1225 } 1229 }
1226 1230
1227 resolve() { 1231 resolve() {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 f(member); 1391 f(member);
1388 }); 1392 });
1389 }); 1393 });
1390 } 1394 }
1391 1395
1392 bool isEmpty() { 1396 bool isEmpty() {
1393 return factories.getValues() 1397 return factories.getValues()
1394 .every((Map constructors) => constructors.isEmpty()); 1398 .every((Map constructors) => constructors.isEmpty());
1395 } 1399 }
1396 } 1400 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/js_names.dart ('k') | frog/member_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698