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 // VM-specific implementation of the dart:mirrors library. | 5 // VM-specific implementation of the dart:mirrors library. |
6 | 6 |
7 import "dart:collection" show UnmodifiableListView, UnmodifiableMapView; | 7 import "dart:collection" show UnmodifiableListView, UnmodifiableMapView; |
8 | 8 |
9 final emptyList = new UnmodifiableListView([]); | 9 final emptyList = new UnmodifiableListView([]); |
10 final emptyMap = new UnmodifiableMapView({}); | 10 final emptyMap = new UnmodifiableMapView({}); |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1350 final bool isShow; | 1350 final bool isShow; |
1351 | 1351 |
1352 _LocalCombinatorMirror(identifierString, this.isShow) | 1352 _LocalCombinatorMirror(identifierString, this.isShow) |
1353 : this.identifiers = [_s(identifierString)]; | 1353 : this.identifiers = [_s(identifierString)]; |
1354 | 1354 |
1355 bool get isHide => !isShow; | 1355 bool get isHide => !isShow; |
1356 } | 1356 } |
1357 | 1357 |
1358 class _LocalMethodMirror extends _LocalDeclarationMirror | 1358 class _LocalMethodMirror extends _LocalDeclarationMirror |
1359 implements MethodMirror { | 1359 implements MethodMirror { |
1360 final _instantiatorForLocal; | |
regis
2015/04/08 20:58:06
I do not understand the meaning of "ForLocal".
rmacnak
2015/04/08 21:35:05
I was only setting this for local functions, then
| |
1360 final bool isStatic; | 1361 final bool isStatic; |
1361 final bool isAbstract; | 1362 final bool isAbstract; |
1362 final bool isGetter; | 1363 final bool isGetter; |
1363 final bool isSetter; | 1364 final bool isSetter; |
1364 final bool isConstructor; | 1365 final bool isConstructor; |
1365 final bool isConstConstructor; | 1366 final bool isConstConstructor; |
1366 final bool isGenerativeConstructor; | 1367 final bool isGenerativeConstructor; |
1367 final bool isRedirectingConstructor; | 1368 final bool isRedirectingConstructor; |
1368 final bool isFactoryConstructor; | 1369 final bool isFactoryConstructor; |
1369 final bool isOperator; | 1370 final bool isOperator; |
1370 | 1371 |
1371 static const _operators = const ["%", "&", "*", "+", "-", "/", "<", "<<", | 1372 static const _operators = const ["%", "&", "*", "+", "-", "/", "<", "<<", |
1372 "<=", "==", ">", ">=", ">>", "[]", "[]=", "^", "|", "~", "unary-", "~/"]; | 1373 "<=", "==", ">", ">=", ">>", "[]", "[]=", "^", "|", "~", "unary-", "~/"]; |
1373 | 1374 |
1374 _LocalMethodMirror(reflectee, | 1375 _LocalMethodMirror(reflectee, |
1375 String simpleName, | 1376 String simpleName, |
1376 this._owner, | 1377 this._owner, |
1378 this._instantiatorForLocal, | |
1377 this.isStatic, | 1379 this.isStatic, |
1378 this.isAbstract, | 1380 this.isAbstract, |
1379 this.isGetter, | 1381 this.isGetter, |
1380 this.isSetter, | 1382 this.isSetter, |
1381 this.isConstructor, | 1383 this.isConstructor, |
1382 this.isConstConstructor, | 1384 this.isConstConstructor, |
1383 this.isGenerativeConstructor, | 1385 this.isGenerativeConstructor, |
1384 this.isRedirectingConstructor, | 1386 this.isRedirectingConstructor, |
1385 this.isFactoryConstructor) | 1387 this.isFactoryConstructor) |
1386 : this.isOperator = _operators.contains(simpleName), | 1388 : this.isOperator = _operators.contains(simpleName), |
1387 super(reflectee, _s(simpleName)); | 1389 super(reflectee, _s(simpleName)); |
1388 | 1390 |
1389 DeclarationMirror _owner; | 1391 DeclarationMirror _owner; |
1390 DeclarationMirror get owner { | 1392 DeclarationMirror get owner { |
1391 // For nested closures it is possible, that the mirror for the owner has not | 1393 // For nested closures it is possible, that the mirror for the owner has not |
1392 // been created yet. | 1394 // been created yet. |
1393 if (_owner == null) { | 1395 if (_owner == null) { |
1394 _owner = _MethodMirror_owner(_reflectee); | 1396 _owner = _MethodMirror_owner(_reflectee, _instantiatorForLocal); |
1395 } | 1397 } |
1396 return _owner; | 1398 return _owner; |
1397 } | 1399 } |
1398 | 1400 |
1399 bool get isPrivate => _n(simpleName).startsWith('_') || | 1401 bool get isPrivate => _n(simpleName).startsWith('_') || |
1400 _n(constructorName).startsWith('_'); | 1402 _n(constructorName).startsWith('_'); |
1401 | 1403 |
1402 bool get isTopLevel => owner is LibraryMirror; | 1404 bool get isTopLevel => owner is LibraryMirror; |
1403 bool get isSynthetic => false; | 1405 bool get isSynthetic => false; |
1404 | 1406 |
1405 Type get _instantiator { | 1407 Type get _instantiator { |
1408 if (_instantiatorForLocal != null) { | |
1409 return _instantiatorForLocal; | |
1410 } | |
1406 var o = owner; | 1411 var o = owner; |
1407 while (o is MethodMirror) o = o.owner; | 1412 while (o is MethodMirror) o = o.owner; |
1408 return o._instantiator; | 1413 return o._instantiator; |
1409 } | 1414 } |
1410 | 1415 |
1411 TypeMirror _returnType = null; | 1416 TypeMirror _returnType = null; |
1412 TypeMirror get returnType { | 1417 TypeMirror get returnType { |
1413 if (_returnType == null) { | 1418 if (_returnType == null) { |
1414 if (isConstructor) { | 1419 if (isConstructor) { |
1415 _returnType = owner; | 1420 _returnType = owner; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1466 var cn = _n(constructorName); | 1471 var cn = _n(constructorName); |
1467 if(cn == ''){ | 1472 if(cn == ''){ |
1468 _simpleName = _s(ownerName); | 1473 _simpleName = _s(ownerName); |
1469 } else { | 1474 } else { |
1470 _simpleName = _s(ownerName + "." + cn); | 1475 _simpleName = _s(ownerName + "." + cn); |
1471 } | 1476 } |
1472 } | 1477 } |
1473 | 1478 |
1474 String toString() => "MethodMirror on '${MirrorSystem.getName(simpleName)}'"; | 1479 String toString() => "MethodMirror on '${MirrorSystem.getName(simpleName)}'"; |
1475 | 1480 |
1476 static dynamic _MethodMirror_owner(reflectee) | 1481 static dynamic _MethodMirror_owner(reflectee, instantiator) |
1477 native "MethodMirror_owner"; | 1482 native "MethodMirror_owner"; |
1478 | 1483 |
1479 static dynamic _MethodMirror_return_type(reflectee, instantiator) | 1484 static dynamic _MethodMirror_return_type(reflectee, instantiator) |
1480 native "MethodMirror_return_type"; | 1485 native "MethodMirror_return_type"; |
1481 | 1486 |
1482 List<ParameterMirror> _MethodMirror_parameters(reflectee) | 1487 List<ParameterMirror> _MethodMirror_parameters(reflectee) |
1483 native "MethodMirror_parameters"; | 1488 native "MethodMirror_parameters"; |
1484 | 1489 |
1485 static String _MethodMirror_source(reflectee) | 1490 static String _MethodMirror_source(reflectee) |
1486 native "MethodMirror_source"; | 1491 native "MethodMirror_source"; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1564 SourceLocation get location { | 1569 SourceLocation get location { |
1565 throw new UnsupportedError("ParameterMirror.location unimplemented"); | 1570 throw new UnsupportedError("ParameterMirror.location unimplemented"); |
1566 } | 1571 } |
1567 | 1572 |
1568 List<InstanceMirror> get metadata { | 1573 List<InstanceMirror> get metadata { |
1569 if (_unmirroredMetadata == null) return emptyList; | 1574 if (_unmirroredMetadata == null) return emptyList; |
1570 return new UnmodifiableListView(_unmirroredMetadata.map(reflect)); | 1575 return new UnmodifiableListView(_unmirroredMetadata.map(reflect)); |
1571 } | 1576 } |
1572 | 1577 |
1573 Type get _instantiator { | 1578 Type get _instantiator { |
1574 var o = owner; | 1579 return owner._instantiator; |
1575 while (o is MethodMirror) o = o.owner; | |
1576 return o._instantiator; | |
1577 } | 1580 } |
1578 | 1581 |
1579 TypeMirror _type = null; | 1582 TypeMirror _type = null; |
1580 TypeMirror get type { | 1583 TypeMirror get type { |
1581 if (_type == null) { | 1584 if (_type == null) { |
1582 _type = reflectType( | 1585 _type = reflectType( |
1583 _ParameterMirror_type(_reflectee, _position, _instantiator)); | 1586 _ParameterMirror_type(_reflectee, _position, _instantiator)); |
1584 } | 1587 } |
1585 return _type; | 1588 return _type; |
1586 } | 1589 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1688 if (typeMirror == null) { | 1691 if (typeMirror == null) { |
1689 typeMirror = makeLocalTypeMirror(key); | 1692 typeMirror = makeLocalTypeMirror(key); |
1690 _instanitationCache[key] = typeMirror; | 1693 _instanitationCache[key] = typeMirror; |
1691 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1694 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
1692 _declarationCache[key] = typeMirror; | 1695 _declarationCache[key] = typeMirror; |
1693 } | 1696 } |
1694 } | 1697 } |
1695 return typeMirror; | 1698 return typeMirror; |
1696 } | 1699 } |
1697 } | 1700 } |
OLD | NEW |