| Index: lib/compiler/implementation/lib/js_helper.dart
|
| diff --git a/lib/compiler/implementation/lib/js_helper.dart b/lib/compiler/implementation/lib/js_helper.dart
|
| index fcfa49be512b7399e1bd8afaa727a0e4f859b52e..8a827f8649bb51983b469f6c2e46777fc0c7b2f1 100644
|
| --- a/lib/compiler/implementation/lib/js_helper.dart
|
| +++ b/lib/compiler/implementation/lib/js_helper.dart
|
| @@ -352,6 +352,78 @@ class ListIterator<T> implements Iterator<T> {
|
| }
|
| }
|
|
|
| +createInvocationMirror(name, internalName, type, arguments, argumentNames) =>
|
| + new JSInvocationMirror(name, internalName, type, arguments, argumentNames);
|
| +
|
| +class JSInvocationMirror implements InvocationMirror {
|
| + static const METHOD = 0;
|
| + static const GETTER = 1;
|
| + static const SETTER = 2;
|
| +
|
| + final String memberName;
|
| + final String _internalName;
|
| + final int _kind;
|
| + final List _arguments;
|
| + final List _namedArgumentNames;
|
| + /** Map from argument name to index in _arguments. */
|
| + Map<String,dynamic> _namedIndices = null;
|
| +
|
| + JSInvocationMirror(this.memberName,
|
| + this._internalName,
|
| + this._kind,
|
| + this._arguments,
|
| + this._namedArgumentNames) {
|
| + if (_kind == METHOD) {
|
| + if (_namedArgumentNames != null && _namedArgumentNames.length > 0) {
|
| + _namedIndices = <String,int>{};
|
| + int namedArgumentCount = _namedArgumentNames.length;
|
| + int namedArgumentsStartIndex =
|
| + _arguments.length - _namedArgumentNames.length;
|
| + for (int i = 0; i < namedArgumentCount; i++) {
|
| + _namedIndices[_namedArgumentNames[i]] = i + namedArgumentsStartIndex;
|
| + }
|
| + } else {
|
| + _namedIndices = const <String,int>{};
|
| + }
|
| + }
|
| + }
|
| +
|
| + bool get isMethod => _kind == METHOD;
|
| + bool get isGetter => _kind == GETTER;
|
| + bool get isSetter => _kind == SETTER;
|
| + bool get isAccessor => _kind != METHOD;
|
| +
|
| + List get positionalArguments {
|
| + if (isAccessor) return null;
|
| + var list = [];
|
| + var argumentCount =
|
| + _arguments.length - _namedArgumentNames.length;
|
| + for (var index = 0 ; index < argumentCount ; index++) {
|
| + list.add(_arguments[index]);
|
| + }
|
| + return list;
|
| + }
|
| +
|
| + Map<String,dynamic> get namedArguments {
|
| + if (isAccessor) return null;
|
| + var map = <String,dynamic>{};
|
| + _namedIndices.forEach((String name, int index) {
|
| + map[name] = _arguments[index];
|
| + });
|
| + return map;
|
| + }
|
| +
|
| + // TODO(lrn): Hide subtype when class literals are implemented.
|
| + // Type get runtimeType => InvocationMirror;
|
| +
|
| + invokeOn(Object object) {
|
| + List arguments = _arguments;
|
| + if (!isJsArray(arguments)) arguments = new List.from(arguments);
|
| + return JS("var", "#[#].apply(#, #)",
|
| + object, _internalName, object, arguments);
|
| + }
|
| +}
|
| +
|
| class Primitives {
|
| static int hashCodeSeed = 0;
|
|
|
|
|