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

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

Issue 15861028: Implement MethodMirror.metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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
Index: dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart b/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
index d1f93eda316292825eb33fe4bc80b97ffa78164c..36fc06c1329f965ce7c458e287c524ef667d00e5 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
@@ -10,6 +10,7 @@ import 'dart:mirrors';
import 'dart:_foreign_helper' show JS, JS_CURRENT_ISOLATE;
import 'dart:_collection-dev' as _symbol_dev;
import 'dart:_js_helper' show
+ BoundClosure,
Closure,
JSInvocationMirror,
Null,
@@ -106,7 +107,8 @@ class JsLibraryMirror extends JsObjectMirror implements LibraryMirror {
// TODO(ahe): Create accessor for accessing $. It is also
// used in js_helper.
new JsMethodMirror(
- symbol, JS('', '#[#]', JS_CURRENT_ISOLATE(), name), parameterCount);
+ symbol, JS('', '#[#]', JS_CURRENT_ISOLATE(), name),
+ parameterCount);
// TODO(ahe): Cache mirrors.
result[symbol] = mirror;
mirror._owner = this;
@@ -442,9 +444,15 @@ function(reflectee) {
if (callName == null) {
throw new RuntimeError('Cannot find callName on "$reflectee"');
}
- var jsFunction = JS('', '#[#]', reflectee, callName);
int parameterCount = int.parse(callName.split(r'$')[1]);
- return new JsMethodMirror(s(callName), jsFunction, parameterCount);
+ if (reflectee is BoundClosure) {
+ var target = reflectee.target;
+ return new JsMethodMirror(
+ s(target), JS('', '#[#]', reflectee.self, target), parameterCount);
+ } else {
+ var jsFunction = JS('', '#[#]', reflectee, callName);
+ return new JsMethodMirror(s(callName), jsFunction, parameterCount);
+ }
}
InstanceMirror apply(List positionalArguments,
@@ -465,6 +473,7 @@ class JsMethodMirror implements MethodMirror {
final _jsFunction;
final int _parameterCount;
DeclarationMirror _owner;
+ List _metadata;
JsMethodMirror(this.simpleName, this._jsFunction, this._parameterCount);
@@ -476,6 +485,15 @@ class JsMethodMirror implements MethodMirror {
DeclarationMirror get owner => _owner;
Symbol get qualifiedName => computeQualifiedName(owner, simpleName);
+
+ List<InstanceMirror> get metadata {
+ if (_metadata == null) {
+ var metadataFunction = JS('', r'#.$metadata', _jsFunction);
kasperl 2013/06/03 06:12:40 Could this code be shared? Maybe it's not worth th
ahe 2013/06/03 09:13:54 Done.
+ _metadata = (metadataFunction == null)
+ ? const [] : JS('', '#()', metadataFunction);
+ }
+ return _metadata.map(reflect).toList();
+ }
}
Symbol computeQualifiedName(DeclarationMirror owner, Symbol simpleName) {

Powered by Google App Engine
This is Rietveld 408576698