package reflection
Contains the Sigma Reflection API. Sigma reflection is a mechanism for obtaining metadata about classes, methods, fields, etc. at runtime. It is used by kiama to rewrite ErgoTree expressions. It is also used by the ErgoTree interpreter to implement MethodCall nodes.
The Sigma Reflection API has two implementations: 1) based on the Java Reflection API 2) based on Sigma Reflection metadata declared in the StaticImpl.scala file
- Alphabetic
- By Inheritance
- reflection
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- class JRClass[T] extends RClass[T]
A class that represents a Java class of type
T
. - class JRConstructor[T] extends RConstructor[T]
Implements RConstructor using Java reflection.
Implements RConstructor using Java reflection.
- T
The type of the class that declares this constructor.
- class JRField extends RField
Implements RField using Java reflection.
- class JRMethod extends RMethod
Implements RMethod using Java reflection.
- abstract class RClass[T] extends AnyRef
Represents a class that can be reflected upon to obtain information about its fields, methods, constructors and superclass.
Represents a class that can be reflected upon to obtain information about its fields, methods, constructors and superclass.
- T
The type represented by this
RClass
.
- trait RConstructor[T] extends AnyRef
A representation of a constructor of a class, providing reflective access to the constructor's parameters and ability to create new instances.
A representation of a constructor of a class, providing reflective access to the constructor's parameters and ability to create new instances.
- T
the type of the class
- abstract class RField extends AnyRef
A representation of a field of a class, providing reflective access to the field's type.
- abstract class RMethod extends AnyRef
Represents a method that can be invoked on an object with arguments.
- class SRClass[T] extends RClass[T]
Represents a class in an Sigma Reflection metadata.
Represents a class in an Sigma Reflection metadata. Extends RClass by providing a concrete implementation without relying on Java reflection.
- abstract class SRConstructor[T] extends RConstructor[T]
Represents a constructor in an Sigma Reflection metadata.
Represents a constructor in an Sigma Reflection metadata. Extends RConstructor by providing a concrete implementation without relying on Java reflection.
- class SRField extends RField
Represents a field in an Sigma Reflection metadata.
Represents a field in an Sigma Reflection metadata. Extends RField by providing a concrete implementation without relying on Java reflection. The instances of this class are used as parameters of
registerClassEntry
method. - abstract class SRMethod extends RMethod
Represents a method in an Sigma Reflection metadata.
Represents a method in an Sigma Reflection metadata. Extends RMethod by providing a concrete implementation without relying on Java reflection.
Value Members
- def memoize[K, V](map: Map[K, V])(key: K, value: => V): V
Memoizes a value in a mutable HashMap.
Memoizes a value in a mutable HashMap.
- map
The mutable HashMap to store the key-value pair.
- key
The key to store in the map.
- value
The value to be evaluated and stored in the map if the key is not present.
- returns
The value associated with the given key in the map. If the key is not present in the map, evaluates the
value
parameter and stores it in the map before returning it.
- def mkConstructor(parameterTypes: Array[Class[_]])(handler: (Array[AnyRef]) => Any): SRConstructor[Any]
Creates a new SRConstructor instance with the given parameter types and handler function.
Creates a new SRConstructor instance with the given parameter types and handler function.
- parameterTypes
the types of the constructor's parameters
- handler
a function that handles creating a new instance using this constructor
- returns
an SRConstructor instance
- def mkMethod(clazz: Class[_], name: String, paramTypes: Seq[Class[_]])(handler: (Any, Array[AnyRef]) => Any): ((String, Seq[Class[_]]), RMethod)
Creates a new SRMethod instance with the given parameters and handler function.
Creates a new SRMethod instance with the given parameters and handler function. This is analogous to the Java Reflection API's java.lang.reflect.Method class.
- clazz
the java.lang.Class that declares the method
- name
the name of the method
- paramTypes
the types of the method's parameters
- handler
a function that handles invoking the method, when RMethod.invoke is called then this
handler
is called- returns
a tuple containing the method's name and parameter types as its first element, and an SRMethod instance as its second element
- See also
- object JRConstructor
- object JRField
- object JRMethod
- object Platform
Platform dependent implementation of reflection methods.
- object RClass
- object ReflectionData
Reflection metadata and global dictionaries to access it.
Reflection metadata and global dictionaries to access it. Such metadata is only used on JS platform to support reflection-like interfaces of RClass, RMethod, RConstructor. These interfaces implemented on JVM using Java reflection.
For each class that needs reflection metadata, we register a class entry using
registerClassEntry
method with the necessary information such as constructors and methods. Only information that is needed at runtime is registered.- See also
mkConstructor, mkMethod