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

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

Issue 15857005: Implement newInstance on ClassMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased 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
« no previous file with comments | « no previous file | dart/tests/lib/mirrors/mirrors_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart b/dart/sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart
index 6b5ecbc80d99350eac127ae69ca28e4428237747..88e9bbaf26ed332b6b967eabf579690a04b958af 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart
@@ -231,6 +231,30 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror {
JS('', r'$[#]', '${_n(simpleName)}_${_n(fieldName)}'));
}
+ InstanceMirror newInstance(Symbol constructorName,
+ List positionalArguments,
+ [Map<Symbol,dynamic> namedArguments]) {
+ if (namedArguments != null && !namedArguments.isEmpty) {
+ throw new UnsupportedError('Named arguments are not implemented');
+ }
+ String constructorName = '${_n(simpleName)}\$${_n(constructorName)}';
+ return _reflect(JS('', r'$[#].apply($, #)', constructorName,
+ new List.from(positionalArguments)));
+ }
+
+ Future<InstanceMirror> newInstanceAsync(
+ Symbol constructorName,
+ List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
+ if (namedArguments != null && !namedArguments.isEmpty) {
+ throw new UnsupportedError('Named arguments are not implemented');
+ }
+ return new Future<InstanceMirror>(
+ () => newInstance(
+ constructorName, positionalArguments, namedArguments));
+ }
+
+
String toString() => 'ClassMirror(${_n(simpleName)})';
}
« no previous file with comments | « no previous file | dart/tests/lib/mirrors/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698