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 #library('mirrors.dart2js'); | 5 #library('mirrors.dart2js'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 #import('dart:uri'); | 8 #import('dart:uri'); |
| 9 | 9 |
| 10 #import('../../../../../lib/compiler/compiler.dart', prefix: 'diagnostics'); | 10 #import('../../../../../lib/compiler/compiler.dart', prefix: 'diagnostics'); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 } | 52 } |
| 53 | 53 |
| 54 Dart2JsTypeMirror _convertTypeToTypeMirror( | 54 Dart2JsTypeMirror _convertTypeToTypeMirror( |
| 55 Dart2JsMirrorSystem system, | 55 Dart2JsMirrorSystem system, |
| 56 DartType type, | 56 DartType type, |
| 57 InterfaceType defaultType, | 57 InterfaceType defaultType, |
| 58 [FunctionSignature functionSignature]) { | 58 [FunctionSignature functionSignature]) { |
| 59 if (type === null) { | 59 if (type === null) { |
| 60 return new Dart2JsInterfaceTypeMirror(system, defaultType); | 60 return new Dart2JsInterfaceTypeMirror(system, defaultType); |
| 61 } else if (type is InterfaceType) { | 61 } else if (type is InterfaceType) { |
| 62 return new Dart2JsInterfaceTypeMirror(system, type); | 62 if (type === system.compiler.types.dynamicType) { |
| 63 return new Dart2JsDynamicMirror(system, type); | |
| 64 } else { | |
| 65 return new Dart2JsInterfaceTypeMirror(system, type); | |
| 66 } | |
| 63 } else if (type is TypeVariableType) { | 67 } else if (type is TypeVariableType) { |
| 64 return new Dart2JsTypeVariableMirror(system, type); | 68 return new Dart2JsTypeVariableMirror(system, type); |
| 65 } else if (type is FunctionType) { | 69 } else if (type is FunctionType) { |
| 66 return new Dart2JsFunctionTypeMirror(system, type, functionSignature); | 70 return new Dart2JsFunctionTypeMirror(system, type, functionSignature); |
| 67 } else if (type is VoidType) { | 71 } else if (type is VoidType) { |
| 68 return new Dart2JsVoidMirror(system, type); | 72 return new Dart2JsVoidMirror(system, type); |
| 69 } else if (type is TypedefType) { | 73 } else if (type is TypedefType) { |
| 70 return new Dart2JsTypedefMirror(system, type); | 74 return new Dart2JsTypedefMirror(system, type); |
| 71 } | 75 } |
| 72 throw new IllegalArgumentException("Unexpected interface type $type"); | 76 throw new IllegalArgumentException("Unexpected interface type $type"); |
| (...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 if (this === other) { | 1209 if (this === other) { |
| 1206 return true; | 1210 return true; |
| 1207 } | 1211 } |
| 1208 if (other is! TypeMirror) { | 1212 if (other is! TypeMirror) { |
| 1209 return false; | 1213 return false; |
| 1210 } | 1214 } |
| 1211 return other.isVoid; | 1215 return other.isVoid; |
| 1212 } | 1216 } |
| 1213 } | 1217 } |
| 1214 | 1218 |
| 1219 class Dart2JsDynamicMirror extends Dart2JsTypeElementMirror { | |
| 1220 | |
| 1221 Dart2JsDynamicMirror(Dart2JsMirrorSystem system, InterfaceType voidType) | |
| 1222 : super(system, voidType); | |
| 1223 | |
| 1224 InterfaceType get _dynamicType => _type; | |
| 1225 | |
| 1226 String get qualifiedName => simpleName; | |
| 1227 | |
| 1228 /** | |
| 1229 * The dynamic type has no location. | |
| 1230 */ | |
| 1231 Location get location => null; | |
| 1232 | |
| 1233 /** | |
| 1234 * The dynamic type has no library. | |
| 1235 */ | |
| 1236 LibraryMirror get library => null; | |
| 1237 | |
| 1238 bool get isObject => false; | |
|
Lasse Reichstein Nielsen
2012/09/24 10:41:09
Why not put these "false" getters on the supertype
Johnni Winther
2012/09/24 10:58:18
Done.
| |
| 1239 | |
| 1240 bool get isVoid => false; | |
| 1241 | |
| 1242 bool get isDynamic => true; | |
| 1243 | |
| 1244 bool get isTypeVariable => false; | |
| 1245 | |
| 1246 bool get isTypedef => false; | |
| 1247 | |
| 1248 bool get isFunction => false; | |
| 1249 | |
| 1250 bool operator ==(Object other) { | |
| 1251 if (this === other) { | |
| 1252 return true; | |
| 1253 } | |
| 1254 if (other is! TypeMirror) { | |
| 1255 return false; | |
| 1256 } | |
| 1257 return other.isDynamic; | |
| 1258 } | |
| 1259 } | |
| 1260 | |
| 1215 //------------------------------------------------------------------------------ | 1261 //------------------------------------------------------------------------------ |
| 1216 // Member mirrors implementation. | 1262 // Member mirrors implementation. |
| 1217 //------------------------------------------------------------------------------ | 1263 //------------------------------------------------------------------------------ |
| 1218 | 1264 |
| 1219 class Dart2JsMethodMirror extends Dart2JsElementMirror | 1265 class Dart2JsMethodMirror extends Dart2JsElementMirror |
| 1220 implements Dart2JsMemberMirror, MethodMirror { | 1266 implements Dart2JsMemberMirror, MethodMirror { |
| 1221 final Dart2JsObjectMirror _objectMirror; | 1267 final Dart2JsObjectMirror _objectMirror; |
| 1222 String _name; | 1268 String _name; |
| 1223 String _constructorName; | 1269 String _constructorName; |
| 1224 String _operatorName; | 1270 String _operatorName; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1391 if (node !== null) { | 1437 if (node !== null) { |
| 1392 var span = system.compiler.spanFromNode(node, script.uri); | 1438 var span = system.compiler.spanFromNode(node, script.uri); |
| 1393 return new Dart2JsLocation(script, span); | 1439 return new Dart2JsLocation(script, span); |
| 1394 } else { | 1440 } else { |
| 1395 var span = system.compiler.spanFromElement(_variable); | 1441 var span = system.compiler.spanFromElement(_variable); |
| 1396 return new Dart2JsLocation(script, span); | 1442 return new Dart2JsLocation(script, span); |
| 1397 } | 1443 } |
| 1398 } | 1444 } |
| 1399 } | 1445 } |
| 1400 | 1446 |
| OLD | NEW |