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 #library('mirrors.dart2js'); | 5 #library('mirrors.dart2js'); |
6 | 6 |
7 #import('../../../lib/compiler/compiler.dart', prefix: 'diagnostics'); | 7 #import('../../../lib/compiler/compiler.dart', prefix: 'diagnostics'); |
8 #import('../../../lib/compiler/implementation/elements/elements.dart'); | 8 #import('../../../lib/compiler/implementation/elements/elements.dart'); |
9 #import('../../../lib/compiler/implementation/apiimpl.dart', prefix: 'api'); | 9 #import('../../../lib/compiler/implementation/apiimpl.dart', prefix: 'api'); |
10 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart'); | 10 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart'); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 const Dart2JsMethodKind(this.text); | 118 const Dart2JsMethodKind(this.text); |
119 | 119 |
120 String toString() => text; | 120 String toString() => text; |
121 } | 121 } |
122 | 122 |
123 | 123 |
124 String _getOperatorFromOperatorName(String name) { | 124 String _getOperatorFromOperatorName(String name) { |
125 Map<String, String> mapping = const { | 125 Map<String, String> mapping = const { |
126 'eq': '==', | 126 'eq': '==', |
127 'not': '~', | 127 'not': '~', |
| 128 'negate': 'negate', // Will change. |
128 'index': '[]', | 129 'index': '[]', |
129 'indexSet': '[]=', | 130 'indexSet': '[]=', |
130 'mul': '*', | 131 'mul': '*', |
131 'div': '/', | 132 'div': '/', |
132 'mod': '%', | 133 'mod': '%', |
133 'tdiv': '~/', | 134 'tdiv': '~/', |
134 'add': '+', | 135 'add': '+', |
135 'sub': '-', | 136 'sub': '-', |
136 'shl': '<<', | 137 'shl': '<<', |
137 'shr': '>>', | 138 'shr': '>>', |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 && _function.modifiers.isFactory()) { | 1237 && _function.modifiers.isFactory()) { |
1237 _constructorName = ''; | 1238 _constructorName = ''; |
1238 int dollarPos = _name.indexOf('\$'); | 1239 int dollarPos = _name.indexOf('\$'); |
1239 if (dollarPos != -1) { | 1240 if (dollarPos != -1) { |
1240 _constructorName = _name.substring(dollarPos+1); | 1241 _constructorName = _name.substring(dollarPos+1); |
1241 _name = _name.substring(0, dollarPos); | 1242 _name = _name.substring(0, dollarPos); |
1242 } | 1243 } |
1243 _kind = Dart2JsMethodKind.FACTORY; | 1244 _kind = Dart2JsMethodKind.FACTORY; |
1244 // canonical name is TypeName.constructorName | 1245 // canonical name is TypeName.constructorName |
1245 _canonicalName = '$_name.$_constructorName'; | 1246 _canonicalName = '$_name.$_constructorName'; |
1246 } else if (_name == 'negate') { | |
1247 _operatorName = _name; | |
1248 _name = 'operator'; | |
1249 _kind = Dart2JsMethodKind.OPERATOR; | |
1250 // canonical name is 'operator operatorName' | |
1251 _canonicalName = 'operator $_operatorName'; | |
1252 } else if (_name.startsWith('operator\$')) { | 1247 } else if (_name.startsWith('operator\$')) { |
1253 String str = _name.substring(9); | 1248 String str = _name.substring(9); |
1254 _name = 'operator'; | 1249 _name = 'operator'; |
1255 _kind = Dart2JsMethodKind.OPERATOR; | 1250 _kind = Dart2JsMethodKind.OPERATOR; |
1256 _operatorName = _getOperatorFromOperatorName(str); | 1251 _operatorName = _getOperatorFromOperatorName(str); |
1257 // canonical name is 'operator operatorName' | 1252 // canonical name is 'operator operatorName' |
1258 _canonicalName = 'operator $_operatorName'; | 1253 _canonicalName = 'operator $_operatorName'; |
1259 } else { | 1254 } else { |
1260 _kind = Dart2JsMethodKind.NORMAL; | 1255 _kind = Dart2JsMethodKind.NORMAL; |
1261 _canonicalName = _name; | 1256 _canonicalName = _name; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 if (node !== null) { | 1372 if (node !== null) { |
1378 var span = system.compiler.spanFromNode(node, script.uri); | 1373 var span = system.compiler.spanFromNode(node, script.uri); |
1379 return new Dart2JsLocation(script, span); | 1374 return new Dart2JsLocation(script, span); |
1380 } else { | 1375 } else { |
1381 var span = system.compiler.spanFromElement(_variable); | 1376 var span = system.compiler.spanFromElement(_variable); |
1382 return new Dart2JsLocation(script, span); | 1377 return new Dart2JsLocation(script, span); |
1383 } | 1378 } |
1384 } | 1379 } |
1385 } | 1380 } |
1386 | 1381 |
OLD | NEW |