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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart

Issue 18670003: Remove support for conflicting constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
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 library mirrors_dart2js; 5 library mirrors_dart2js;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection' show LinkedHashMap; 8 import 'dart:collection' show LinkedHashMap;
9 9
10 import '../../compiler.dart' as api; 10 import '../../compiler.dart' as api;
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 } 1265 }
1266 1266
1267 //------------------------------------------------------------------------------ 1267 //------------------------------------------------------------------------------
1268 // Member mirrors implementation. 1268 // Member mirrors implementation.
1269 //------------------------------------------------------------------------------ 1269 //------------------------------------------------------------------------------
1270 1270
1271 class Dart2JsMethodMirror extends Dart2JsMemberMirror 1271 class Dart2JsMethodMirror extends Dart2JsMemberMirror
1272 implements MethodMirror { 1272 implements MethodMirror {
1273 final Dart2JsContainerMirror _objectMirror; 1273 final Dart2JsContainerMirror _objectMirror;
1274 final String simpleName; 1274 final String simpleName;
1275 final String constructorName;
1276 final Dart2JsMethodKind _kind; 1275 final Dart2JsMethodKind _kind;
1277 1276
1278 Dart2JsMethodMirror._internal(Dart2JsContainerMirror objectMirror, 1277 Dart2JsMethodMirror._internal(Dart2JsContainerMirror objectMirror,
1279 FunctionElement function, 1278 FunctionElement function,
1280 String this.simpleName, 1279 String this.simpleName,
1281 String this.constructorName,
1282 Dart2JsMethodKind this._kind) 1280 Dart2JsMethodKind this._kind)
1283 : this._objectMirror = objectMirror, 1281 : this._objectMirror = objectMirror,
1284 super(objectMirror.mirrors, function); 1282 super(objectMirror.mirrors, function);
1285 1283
1286 factory Dart2JsMethodMirror(Dart2JsContainerMirror objectMirror, 1284 factory Dart2JsMethodMirror(Dart2JsContainerMirror objectMirror,
1287 FunctionElement function) { 1285 FunctionElement function) {
1288 String realName = function.name.slowToString(); 1286 String realName = function.name.slowToString();
1289 // TODO(ahe): This method should not be calling 1287 // TODO(ahe): This method should not be calling
1290 // Elements.operatorNameToIdentifier. 1288 // Elements.operatorNameToIdentifier.
1291 String simpleName = 1289 String simpleName =
1292 Elements.operatorNameToIdentifier(function.name).slowToString(); 1290 Elements.operatorNameToIdentifier(function.name).slowToString();
1293 String constructorName = null;
1294 Dart2JsMethodKind kind; 1291 Dart2JsMethodKind kind;
1295 if (function.kind == ElementKind.GETTER) { 1292 if (function.kind == ElementKind.GETTER) {
1296 kind = Dart2JsMethodKind.GETTER; 1293 kind = Dart2JsMethodKind.GETTER;
1297 } else if (function.kind == ElementKind.SETTER) { 1294 } else if (function.kind == ElementKind.SETTER) {
1298 kind = Dart2JsMethodKind.SETTER; 1295 kind = Dart2JsMethodKind.SETTER;
1299 simpleName = '$simpleName='; 1296 simpleName = '$simpleName=';
1300 } else if (function.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { 1297 } else if (function.kind == ElementKind.GENERATIVE_CONSTRUCTOR) {
1301 // TODO(johnniwinther): Support detection of redirecting constructors. 1298 // TODO(johnniwinther): Support detection of redirecting constructors.
1302 constructorName = '';
1303 int dollarPos = simpleName.indexOf('\$');
1304 if (dollarPos != -1) {
1305 constructorName = simpleName.substring(dollarPos + 1);
1306 simpleName = simpleName.substring(0, dollarPos);
1307 // Simple name is TypeName.constructorName.
1308 simpleName = '$simpleName.$constructorName';
1309 } else {
1310 // Simple name is TypeName.
1311 }
1312 if (function.modifiers.isConst()) { 1299 if (function.modifiers.isConst()) {
1313 kind = Dart2JsMethodKind.CONST; 1300 kind = Dart2JsMethodKind.CONST;
1314 } else { 1301 } else {
1315 kind = Dart2JsMethodKind.GENERATIVE; 1302 kind = Dart2JsMethodKind.GENERATIVE;
1316 } 1303 }
1317 } else if (function.modifiers.isFactory()) { 1304 } else if (function.modifiers.isFactory()) {
1318 kind = Dart2JsMethodKind.FACTORY; 1305 kind = Dart2JsMethodKind.FACTORY;
1319 constructorName = '';
1320 int dollarPos = simpleName.indexOf('\$');
1321 if (dollarPos != -1) {
1322 constructorName = simpleName.substring(dollarPos+1);
1323 simpleName = simpleName.substring(0, dollarPos);
1324 simpleName = '$simpleName.$constructorName';
1325 }
1326 } else if (realName == 'unary-') { 1306 } else if (realName == 'unary-') {
1327 kind = Dart2JsMethodKind.OPERATOR; 1307 kind = Dart2JsMethodKind.OPERATOR;
1328 // Simple name is 'unary-'. 1308 // Simple name is 'unary-'.
1329 simpleName = Mirror.UNARY_MINUS; 1309 simpleName = Mirror.UNARY_MINUS;
1330 } else if (simpleName.startsWith('operator\$')) { 1310 } else if (simpleName.startsWith('operator\$')) {
1331 String str = simpleName.substring(9); 1311 String str = simpleName.substring(9);
1332 simpleName = 'operator'; 1312 simpleName = 'operator';
1333 kind = Dart2JsMethodKind.OPERATOR; 1313 kind = Dart2JsMethodKind.OPERATOR;
1334 simpleName = _getOperatorFromOperatorName(str); 1314 simpleName = _getOperatorFromOperatorName(str);
1335 } else { 1315 } else {
1336 kind = Dart2JsMethodKind.REGULAR; 1316 kind = Dart2JsMethodKind.REGULAR;
1337 } 1317 }
1338 return new Dart2JsMethodMirror._internal(objectMirror, function, 1318 return new Dart2JsMethodMirror._internal(objectMirror, function,
1339 simpleName, constructorName, kind); 1319 simpleName, kind);
1340 } 1320 }
1341 1321
1342 FunctionElement get _function => _element; 1322 FunctionElement get _function => _element;
1343 1323
1344 String get qualifiedName 1324 String get qualifiedName
1345 => '${owner.qualifiedName}.$simpleName'; 1325 => '${owner.qualifiedName}.$simpleName';
1346 1326
1347 DeclarationMirror get owner => _objectMirror; 1327 DeclarationMirror get owner => _objectMirror;
1348 1328
1349 bool get isTopLevel => _objectMirror is LibraryMirror; 1329 bool get isTopLevel => _objectMirror is LibraryMirror;
1350 1330
1351 bool get isConstructor 1331 bool get isConstructor
1352 => isGenerativeConstructor || isConstConstructor || 1332 => isGenerativeConstructor || isConstConstructor ||
1353 isFactoryConstructor || isRedirectingConstructor; 1333 isFactoryConstructor || isRedirectingConstructor;
1354 1334
1355 bool get isMethod => !isConstructor; 1335 bool get isMethod => !isConstructor;
1356 1336
1357 bool get isPrivate =>
1358 isConstructor ? _isPrivate(constructorName) : _isPrivate(simpleName);
1359
1360 bool get isStatic => _function.modifiers.isStatic(); 1337 bool get isStatic => _function.modifiers.isStatic();
1361 1338
1362 List<ParameterMirror> get parameters { 1339 List<ParameterMirror> get parameters {
1363 return _parametersFromFunctionSignature(mirrors, this, 1340 return _parametersFromFunctionSignature(mirrors, this,
1364 _function.computeSignature(mirrors.compiler)); 1341 _function.computeSignature(mirrors.compiler));
1365 } 1342 }
1366 1343
1367 TypeMirror get returnType => _convertTypeToTypeMirror( 1344 TypeMirror get returnType => _convertTypeToTypeMirror(
1368 mirrors, _function.computeSignature(mirrors.compiler).returnType, 1345 mirrors, _function.computeSignature(mirrors.compiler).returnType,
1369 mirrors.compiler.types.dynamicType); 1346 mirrors.compiler.types.dynamicType);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 * 1665 *
1689 * All API in this class is experimental. 1666 * All API in this class is experimental.
1690 */ 1667 */
1691 class BackDoor { 1668 class BackDoor {
1692 /// Return the compilation units comprising [library]. 1669 /// Return the compilation units comprising [library].
1693 static List<Mirror> compilationUnitsOf(Dart2JsLibraryMirror library) { 1670 static List<Mirror> compilationUnitsOf(Dart2JsLibraryMirror library) {
1694 return library._library.compilationUnits.toList().map( 1671 return library._library.compilationUnits.toList().map(
1695 (cu) => new Dart2JsCompilationUnitMirror(cu, library)).toList(); 1672 (cu) => new Dart2JsCompilationUnitMirror(cu, library)).toList();
1696 } 1673 }
1697 } 1674 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698