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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/mirrors.dart

Issue 11624011: Mirrors implemented via patches. 2nd try. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/lib/mirrors.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/mirrors.dart b/sdk/lib/_internal/compiler/implementation/lib/mirrors.dart
deleted file mode 100644
index 6728d4790c2500b7c378412d6917e453bcd7d564..0000000000000000000000000000000000000000
--- a/sdk/lib/_internal/compiler/implementation/lib/mirrors.dart
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library dart_mirrors;
-
-import 'dart:isolate';
-
-part '../../../../mirrors/mirrors.dart';
-
-/**
- * Stub class for the mirror system.
- */
-class _Mirrors {
- static MirrorSystem currentMirrorSystem() {
- _ensureEnabled();
- throw new UnsupportedError("MirrorSystem not implemented");
- }
-
- static Future<MirrorSystem> mirrorSystemOf(SendPort port) {
- _ensureEnabled();
- throw new UnsupportedError("MirrorSystem not implemented");
- }
-
- static InstanceMirror reflect(Object reflectee) {
- _ensureEnabled();
- return new _InstanceMirror(reflectee);
- }
-}
-
-class _InstanceMirror extends InstanceMirror {
- static final Expando<ClassMirror> classMirrors = new Expando<ClassMirror>();
-
- final reflectee;
-
- _InstanceMirror(this.reflectee) {
- _ensureEnabled();
- }
-
- bool get hasReflectee => true;
-
- ClassMirror get type {
- String className = Primitives.objectTypeName(reflectee);
- var constructor = Primitives.getConstructor(className);
- var mirror = classMirrors[constructor];
- if (mirror == null) {
- mirror = new _ClassMirror(className, constructor);
- classMirrors[constructor] = mirror;
- }
- return mirror;
- }
-
- Future<InstanceMirror> invoke(String memberName,
- List<Object> positionalArguments,
- [Map<String,Object> namedArguments]) {
- if (namedArguments != null && !namedArguments.isEmpty) {
- throw new UnsupportedError('Named arguments are not implemented');
- }
- // Copy the list to ensure that it can safely be passed to
- // JavaScript.
- var jsList = new List.from(positionalArguments);
- var mangledName = '${memberName}\$${positionalArguments.length}';
- var method = JS('var', '#[#]', reflectee, mangledName);
- var completer = new Completer<InstanceMirror>();
- // TODO(ahe): [Completer] or [Future] should have API to create a
- // delayed action. Simulating with a [Timer].
- new Timer(0, (timer) {
- if (JS('String', 'typeof #', method) == 'function') {
- var result =
- JS('var', '#.apply(#, #)', method, reflectee, jsList);
- completer.complete(new _InstanceMirror(result));
- } else {
- completer.completeException('not a method $memberName');
- }
- });
- return completer.future;
- }
-
- String toString() => 'InstanceMirror($reflectee)';
-}
-
-class _ClassMirror extends ClassMirror {
- final String _name;
- final _jsConstructor;
-
- _ClassMirror(this._name, this._jsConstructor) {
- _ensureEnabled();
- }
-
- String toString() => 'ClassMirror($_name)';
-}
-
-_ensureEnabled() {
- if (Primitives.mirrorsEnabled) return;
- throw new UnsupportedError('dart:mirrors is an experimental feature');
-}

Powered by Google App Engine
This is Rietveld 408576698