Dart API Referencedart:mirrorsClosureMirror

ClosureMirror abstract class

A ClosureMirror reflects a closure.

A ClosureMirror provides access to its captured variables and provides the ability to execute its reflectee.

abstract class ClosureMirror implements InstanceMirror {
  /**
   * A mirror on the function associated with this closure.
   */
  MethodMirror get function;

  /**
   * The source code for this closure, if available.  Otherwise null.
   *
   * TODO(turnidge): Would this just be available in function?
   */
  String get source;

  /**
   * Executes the closure. The arguments given in the descriptor need to
   * be InstanceMirrors or simple values.
   *
   * A value is simple if one of the following holds:
   *  - the value is null
   *  - the value is of type [num]
   *  - the value is of type [bool]
   *  - the value is of type [String]
   */
  Future<InstanceMirror> apply(List<Object> positionalArguments,
                               [Map<String,Object> namedArguments]);

  /**
   * Looks up the value of a name in the scope of the closure. The
   * result is a mirror on that value.
   */
  Future<InstanceMirror> findInContext(String name);
}

Implements

InstanceMirror

Properties

final MethodMirror function #

A mirror on the function associated with this closure.

MethodMirror get function;

final bool hasReflectee #

inherited from InstanceMirror

Does reflectee contain the instance reflected by this mirror? This will always be true in the local case (reflecting instances in the same isolate), but only true in the remote case if this mirror reflects a simple value.

A value is simple if one of the following holds: - the value is null - the value is of type num - the value is of type bool - the value is of type String

bool get hasReflectee;

final MirrorSystem mirrors #

inherited from Mirror

The MirrorSystem that contains this mirror.

MirrorSystem get mirrors;

final reflectee #

inherited from InstanceMirror

If the InstanceMirror reflects an instance it is meaningful to have a local reference to, we provide access to the actual instance here.

If you access reflectee when hasReflectee is false, an exception is thrown.

get reflectee;

final String source #

The source code for this closure, if available. Otherwise null.

TODO(turnidge): Would this just be available in function?

String get source;

final ClassMirror type #

inherited from InstanceMirror

A mirror on the type of the reflectee.

ClassMirror get type;

Methods

Future<InstanceMirror> apply(List<Object> positionalArguments, [Map<String, Object> namedArguments]) #

Executes the closure. The arguments given in the descriptor need to be InstanceMirrors or simple values.

A value is simple if one of the following holds: - the value is null - the value is of type num - the value is of type bool - the value is of type String

Future<InstanceMirror> apply(List<Object> positionalArguments,
                             [Map<String,Object> namedArguments]);

Future<InstanceMirror> findInContext(String name) #

Looks up the value of a name in the scope of the closure. The result is a mirror on that value.

Future<InstanceMirror> findInContext(String name);

Future<InstanceMirror> getField(String fieldName) #

inherited from ObjectMirror

Invokes a getter and returns a mirror on the result. The getter can be the implicit getter for a field or a user-defined getter method.

TODO(turnidge): Handle ambiguous names.

Future<InstanceMirror> getField(String fieldName);

Future<InstanceMirror> invoke(String memberName, List<Object> positionalArguments, [Map<String, Object> namedArguments]) #

inherited from ObjectMirror

Invokes the named function and returns a mirror on the result.

TODO(turnidge): Properly document. TODO(turnidge): Handle ambiguous names. TODO(turnidge): Handle optional & named arguments.

Future<InstanceMirror> invoke(String memberName,
                              List<Object> positionalArguments,
                              [Map<String,Object> namedArguments]);

Future<InstanceMirror> setField(String fieldName, Object value) #

inherited from ObjectMirror

Invokes a setter and returns a mirror on the result. The setter may be either the implicit setter for a non-final field or a user-defined setter method.

TODO(turnidge): Handle ambiguous names.

Future<InstanceMirror> setField(String fieldName, Object value);