Chromium Code Reviews| 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 // These values are allowed to be passed directly over the wire. | 7 // These values are allowed to be passed directly over the wire. |
| 8 bool _isSimpleValue(var value) { | 8 bool _isSimpleValue(var value) { |
| 9 return (value == null || value is num || value is String || value is bool); | 9 return (value == null || value is num || value is String || value is bool); |
| 10 } | 10 } |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1030 return owner is LibraryMirror; | 1030 return owner is LibraryMirror; |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 SourceLocation get location { | 1033 SourceLocation get location { |
| 1034 throw new UnimplementedError( | 1034 throw new UnimplementedError( |
| 1035 'VariableMirror.location is not implemented'); | 1035 'VariableMirror.location is not implemented'); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 var _type; | 1038 var _type; |
| 1039 TypeMirror get type { | 1039 TypeMirror get type { |
| 1040 if (_type == null) { | |
| 1041 _type = _VariableMirror_type(_reflectee); | |
| 1042 } | |
| 1040 if (_type is! Mirror) { | 1043 if (_type is! Mirror) { |
| 1041 _type = _type.resolve(mirrors); | 1044 _type = _type.resolve(mirrors); |
| 1042 } | 1045 } |
| 1043 return _type; | 1046 return _type; |
| 1044 } | 1047 } |
| 1045 | 1048 |
| 1046 final bool isStatic; | 1049 final bool isStatic; |
| 1047 final bool isFinal; | 1050 final bool isFinal; |
| 1048 | 1051 |
| 1049 String toString() => "VariableMirror on '${_n(simpleName)}'"; | 1052 String toString() => "VariableMirror on '${_n(simpleName)}'"; |
| 1053 | |
| 1054 static _VariableMirror_type(reflectee) | |
| 1055 native "VariableMirror_type"; | |
| 1050 } | 1056 } |
| 1051 | 1057 |
| 1052 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl | 1058 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl |
| 1053 implements ParameterMirror { | 1059 implements ParameterMirror { |
| 1054 _LocalParameterMirrorImpl(type, this.isOptional) | 1060 _LocalParameterMirrorImpl(type, this.isOptional) |
| 1055 : super(null, '<TODO:unnamed>', null, type, false, false) {} | 1061 : super(null, '<TODO:unnamed>', null, type, false, false) {} |
| 1056 | 1062 |
| 1057 final bool isOptional; | 1063 final bool isOptional; |
| 1058 | 1064 |
| 1059 String get defaultValue { | 1065 String get defaultValue { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1089 SourceLocation get location { | 1095 SourceLocation get location { |
| 1090 throw new UnimplementedError( | 1096 throw new UnimplementedError( |
| 1091 'TypeMirror.location is not implemented'); | 1097 'TypeMirror.location is not implemented'); |
| 1092 } | 1098 } |
| 1093 | 1099 |
| 1094 Symbol get qualifiedName { | 1100 Symbol get qualifiedName { |
| 1095 return simpleName; | 1101 return simpleName; |
| 1096 } | 1102 } |
| 1097 | 1103 |
| 1098 String toString() => "TypeMirror on '${_n(simpleName)}'"; | 1104 String toString() => "TypeMirror on '${_n(simpleName)}'"; |
| 1105 | |
| 1106 operator ==(other) { | |
|
rmacnak
2013/07/20 00:46:52
Allow tests to pass which previously relied on the
siva
2013/07/22 05:25:32
Please add an issue to track this temporary workar
rmacnak
2013/07/22 19:05:09
Done.
| |
| 1107 if (other is! _SpecialTypeMirrorImpl) { | |
| 1108 return false; | |
| 1109 } | |
| 1110 return this.simpleName == other.simpleName; | |
| 1111 } | |
| 1099 } | 1112 } |
| 1100 | 1113 |
| 1101 class _Mirrors { | 1114 class _Mirrors { |
| 1102 // Does a port refer to our local isolate? | 1115 // Does a port refer to our local isolate? |
| 1103 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort'; | 1116 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort'; |
| 1104 | 1117 |
| 1105 static MirrorSystem _currentMirrorSystem = null; | 1118 static MirrorSystem _currentMirrorSystem = null; |
| 1106 | 1119 |
| 1107 // Creates a new local MirrorSystem. | 1120 // Creates a new local MirrorSystem. |
| 1108 static MirrorSystem makeLocalMirrorSystem() | 1121 static MirrorSystem makeLocalMirrorSystem() |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1147 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); | 1160 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); |
| 1148 static ClassMirror reflectClass(Type key) { | 1161 static ClassMirror reflectClass(Type key) { |
| 1149 var classMirror = _classMirrorCache[key]; | 1162 var classMirror = _classMirrorCache[key]; |
| 1150 if (classMirror == null) { | 1163 if (classMirror == null) { |
| 1151 classMirror = makeLocalClassMirror(key); | 1164 classMirror = makeLocalClassMirror(key); |
| 1152 _classMirrorCache[key] = classMirror; | 1165 _classMirrorCache[key] = classMirror; |
| 1153 } | 1166 } |
| 1154 return classMirror; | 1167 return classMirror; |
| 1155 } | 1168 } |
| 1156 } | 1169 } |
| OLD | NEW |