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

Unified Diff: runtime/lib/mirrors_impl.dart

Issue 19235015: Implement metadata as an internal native. Be honest about which mirrors don't yet support metadata … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 months 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
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors_impl.dart
===================================================================
--- runtime/lib/mirrors_impl.dart (revision 25060)
+++ runtime/lib/mirrors_impl.dart (working copy)
@@ -70,8 +70,8 @@
return result;
}
-List<InstanceMirror> _metadata(mirror)
- native 'Mirrors_metadata';
+List _metadata(reflectee)
+ native 'DeclarationMirror_metadata';
// This will verify the argument types, unwrap them, and ensure we have a fixed
// array.
@@ -164,24 +164,9 @@
String toString() => "IsolateMirror on '$debugName'";
}
-// A VMReference is used to hold a reference to a VM-internal object,
-// which can include things like libraries, classes, etc.
-class VMReference extends NativeFieldWrapperClass1 {
-}
-
-abstract class _LocalVMObjectMirrorImpl extends _LocalMirrorImpl {
- _LocalVMObjectMirrorImpl(this._reference) {}
-
- // For now, all VMObjects hold a VMReference. We could consider
- // storing the Object reference itself here if the object is a Dart
- // language objects (except for objects of type VMReference, of
- // course).
- VMReference _reference;
-}
-
-abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl
+abstract class _LocalObjectMirrorImpl extends _LocalMirrorImpl
implements ObjectMirror {
- _LocalObjectMirrorImpl(this._reflectee, ref) : super(ref) {}
+ _LocalObjectMirrorImpl(this._reflectee);
final _reflectee; // May be a MirrorReference or an ordinary object.
@@ -275,9 +260,8 @@
// TODO(ahe): This is a hack, see delegate below.
static Function _invokeOnClosure;
- _LocalInstanceMirrorImpl(ref,
- this._type,
- reflectee) : super(reflectee, ref) {}
+ _LocalInstanceMirrorImpl(this._type,
+ reflectee) : super(reflectee) {}
var _type;
ClassMirror get type {
@@ -321,10 +305,9 @@
class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl
implements ClosureMirror {
- _LocalClosureMirrorImpl(ref,
- type,
+ _LocalClosureMirrorImpl(type,
reflectee,
- this.function) : super(ref, type, reflectee) {}
+ this.function) : super(type, reflectee) {}
final MethodMirror function;
@@ -404,7 +387,6 @@
class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
implements ClassMirror {
_LocalClassMirrorImpl(reflectee,
- ref,
String simpleName,
this.isClass,
this._owner,
@@ -418,7 +400,7 @@
this.members = _convertStringToSymbolMap(members),
this.constructors = _convertStringToSymbolMap(constructors),
this.typeVariables = _convertStringToSymbolMap(typeVariables),
- super(reflectee, ref);
+ super(reflectee);
Symbol _simpleName;
Symbol get simpleName {
@@ -584,7 +566,7 @@
// get the metadata objects, convert them into InstanceMirrors using
// reflect() and then make them into a Dart list
- List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList();
+ List<InstanceMirror> get metadata => _metadata(_reflectee).map(reflect).toList();
ahe 2013/07/17 13:03:39 Long line.
static _name(reflectee)
@@ -617,12 +599,11 @@
class _LocalFunctionTypeMirrorImpl extends _LocalClassMirrorImpl
implements FunctionTypeMirror {
- _LocalFunctionTypeMirrorImpl(ref,
+ _LocalFunctionTypeMirrorImpl(reflectee,
simpleName,
this._returnType,
this.parameters)
- : super(null,
- ref,
+ : super(reflectee,
simpleName,
true,
null,
@@ -702,9 +683,10 @@
return _upperBound;
}
- // get the metadata objects, convert them into InstanceMirrors using
- // reflect() and then make them into a Dart list
- List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList();
+ List<InstanceMirror> get metadata {
+ throw new UnimplementedError(
+ 'TypeVariableMirror.metadata is not implemented');
+ }
String toString() => "TypeVariableMirror on '${_n(simpleName)}'";
}
@@ -769,14 +751,13 @@
class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
implements LibraryMirror {
_LocalLibraryMirrorImpl(reflectee,
- ref,
String simpleName,
String url,
Map<String, Mirror> members)
: this.simpleName = _s(simpleName),
this.members = _convertStringToSymbolMap(members),
this.uri = Uri.parse(url),
- super(reflectee, ref);
+ super(reflectee);
final Symbol simpleName;
@@ -848,7 +829,7 @@
// get the metadata objects, convert them into InstanceMirrors using
// reflect() and then make them into a Dart list
- List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList();
+ List<InstanceMirror> get metadata => _metadata(_reflectee).map(reflect).toList();
ahe 2013/07/17 13:03:39 Long line.
String toString() => "LibraryMirror on '${_n(simpleName)}'";
@@ -970,7 +951,7 @@
owner; // ensure owner is computed
// get the metadata objects, convert them into InstanceMirrors using
// reflect() and then make them into a Dart list
- return _metadata(this).map(reflect).toList();
+ return _metadata(_reflectee).map(reflect).toList();
}
String toString() => "MethodMirror on '${_n(simpleName)}'";
@@ -981,13 +962,15 @@
class _LocalVariableMirrorImpl extends _LocalMirrorImpl
implements VariableMirror {
- _LocalVariableMirrorImpl(String simpleName,
+ _LocalVariableMirrorImpl(this._reflectee,
+ String simpleName,
this._owner,
this._type,
this.isStatic,
this.isFinal)
: this.simpleName = _s(simpleName);
+ final _MirrorReference _reflectee;
final Symbol simpleName;
Symbol _qualifiedName = null;
@@ -1031,10 +1014,9 @@
final bool isFinal;
List<InstanceMirror> get metadata {
- owner; // ensure owner is computed
// get the metadata objects, convert them into InstanceMirrors using
// reflect() and then make them into a Dart list
- return _metadata(this).map(reflect).toList();
+ return _metadata(_reflectee).map(reflect).toList();
}
String toString() => "VariableMirror on '${_n(simpleName)}'";
@@ -1043,7 +1025,7 @@
class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl
implements ParameterMirror {
_LocalParameterMirrorImpl(type, this.isOptional)
- : super('<TODO:unnamed>', null, type, false, false) {}
+ : super(null, '<TODO:unnamed>', null, type, false, false) {}
final bool isOptional;
@@ -1056,6 +1038,12 @@
throw new UnimplementedError(
'ParameterMirror.hasDefaultValue is not implemented');
}
+
+ // TODO(11418): Implement.
+ List<InstanceMirror> get metadata {
+ throw new UnimplementedError(
+ 'ParameterMirror.metadata is not implemented');
+ }
}
class _SpecialTypeMirrorImpl extends _LocalMirrorImpl
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698