Chromium Code Reviews| Index: dart/sdk/lib/_internal/lib/js_mirrors.dart |
| diff --git a/dart/sdk/lib/_internal/lib/js_mirrors.dart b/dart/sdk/lib/_internal/lib/js_mirrors.dart |
| index 68e83b085ad99cac61981e3b530f82e801448ab4..bf7cc3990097288de12dafafb8a29c46420b9e4d 100644 |
| --- a/dart/sdk/lib/_internal/lib/js_mirrors.dart |
| +++ b/dart/sdk/lib/_internal/lib/js_mirrors.dart |
| @@ -36,6 +36,8 @@ String getName(Symbol symbol) { |
| } |
| class JsMirrorSystem implements MirrorSystem { |
| + final IsolateMirror isolate = new JsIsolateMirror(); |
| + |
| TypeMirror get dynamicType => _dynamicType; |
| TypeMirror get voidType => _voidType; |
| @@ -72,18 +74,16 @@ class JsMirrorSystem implements MirrorSystem { |
| List<String> functions = data[3]; |
| var metadataFunction = data[4]; |
| var fields = data[5]; |
| + bool isRoot = data[6]; |
| List metadata = (metadataFunction == null) |
| ? null : JS('List', '#()', metadataFunction); |
| var libraries = result.putIfAbsent(name, () => <LibraryMirror>[]); |
| libraries.add( |
| new JsLibraryMirror( |
| - s(name), uri, classes, functions, metadata, fields)); |
| + s(name), uri, classes, functions, metadata, fields, isRoot)); |
| } |
| return result; |
| } |
| - |
| - // TODO(ahe): Implement this. |
| - IsolateMirror get isolate => throw new UnimplementedError(); |
| } |
| abstract class JsMirror implements Mirror { |
| @@ -113,6 +113,21 @@ abstract class JsMirror implements Mirror { |
| } |
| } |
| +// This class is somewhat silly in the current implementation. |
| +class JsIsolateMirror extends JsMirror implements IsolateMirror { |
| + String get _prettyName => 'Isolate'; |
| + |
| + String get debugName => '[object Object]'; |
|
kustermann
2013/07/25 14:56:45
The documentation says, that 'debugName' must be u
ahe
2013/07/25 18:01:01
Yeah, it's kind of a joke. I guess nobody got it
|
| + |
| + // Note: this wouldn't always be true when we implement [mirrorSystemOf]. |
| + bool get isCurrent => true; |
| + |
| + LibraryMirror get rootLibrary { |
| + return currentJsMirrorSystem.libraries.values.firstWhere( |
| + (JsLibraryMirror library) => library._isRoot); |
| + } |
| +} |
| + |
| abstract class JsDeclarationMirror extends JsMirror |
| implements DeclarationMirror { |
| final Symbol simpleName; |
| @@ -161,6 +176,7 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror |
| final List<String> _functions; |
| final List _metadata; |
| final String _compactFieldSpecification; |
| + final bool _isRoot; |
| List<JsMethodMirror> _cachedFunctionMirrors; |
| List<JsVariableMirror> _cachedFields; |
| @@ -169,7 +185,8 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror |
| this._classes, |
| this._functions, |
| this._metadata, |
| - this._compactFieldSpecification) |
| + this._compactFieldSpecification, |
| + this._isRoot) |
| : super(simpleName); |
| String get _prettyName => 'LibraryMirror'; |