Modifier and Type | Field and Description |
---|---|
int |
arity
Tells how many arguments we need before we can invoke.
|
java.lang.invoke.MethodHandle |
j
The
MethodHandle . |
static java.lang.invoke.MethodType |
mtLL
an often used
MethodType for Lazy method(Lazy) |
static java.lang.invoke.MethodHandle |
unboxInt |
static java.lang.invoke.MethodHandle |
unboxObject |
Constructor and Description |
---|
MH(java.lang.invoke.MethodHandle it)
Create a MH from a
MethodHandle , takes arity from type |
MH(java.lang.invoke.MethodHandle it,
int ari)
Create a MH from a
MethodHandle with a given arity. |
Modifier and Type | Method and Description |
---|---|
Lazy<FV> |
_v()
Evaluation of a MH
|
MH |
apply(Lazy<FV> v)
Apply a MethodHandle to an argument and compute a result.
|
int |
constructor()
required to qualify as
FV |
static java.lang.invoke.MethodHandle |
findGetter(java.lang.Class<?> in,
java.lang.String name,
java.lang.Class<?> type)
wrapper for
MethodHandles.Lookup.findGetter(java.lang.Class<?>, java.lang.String, java.lang.Class<?>) |
static java.lang.invoke.MethodHandle |
findStatic(java.lang.Class<?> in,
java.lang.String name,
java.lang.invoke.MethodType type)
wrapper for
MethodHandles.Lookup.findStatic(java.lang.Class<?>, java.lang.String, java.lang.invoke.MethodType) |
static java.lang.invoke.MethodHandle |
findStaticGetter(java.lang.Class<?> in,
java.lang.String name,
java.lang.Class<?> type)
wrapper for
MethodHandles.Lookup.findStaticGetter(java.lang.Class<?>, java.lang.String, java.lang.Class<?>) |
static java.lang.invoke.MethodHandle |
findVirtual(java.lang.Class<?> in,
java.lang.String name,
java.lang.invoke.MethodType type)
wrapper for
MethodHandles.Lookup.findVirtual(java.lang.Class<?>, java.lang.String, java.lang.invoke.MethodType) |
java.lang.String |
toString() |
static java.lang.invoke.MethodHandle |
unboxRef(java.lang.Class<?> result) |
public final int arity
Tells how many arguments we need before we can invoke.
public final java.lang.invoke.MethodHandle j
The MethodHandle
.
public static final java.lang.invoke.MethodType mtLL
an often used MethodType
for Lazy method(Lazy)
public static final java.lang.invoke.MethodHandle unboxObject
public static final java.lang.invoke.MethodHandle unboxInt
public MH(java.lang.invoke.MethodHandle it)
Create a MH from a MethodHandle
, takes arity from type
public MH(java.lang.invoke.MethodHandle it, int ari)
Create a MH from a MethodHandle
with a given arity.
public final int constructor()
required to qualify as FV
constructor
in interface FV
Because product types have only one constructor, this will return 0 for every value of a product type.
public java.lang.String toString()
toString
in class java.lang.Object
public Lazy<FV> _v()
Evaluation of a MH
If the arity is not 0, it evaluates to itself.
If the arity is 0, it evaluates the result of the invokation of the MethodHandle
public final MH apply(Lazy<FV> v)
Apply a MethodHandle to an argument and compute a result.
This is used when an unknown function must be applied. For example consider
fold f s (x:xs) = fold f (f s x) xs g :: (Int -> Int) -> Int -> (Int -> Int) g h i j = (h i) + j sum = fold g (0+) [1,2,3]
But in fold, (f s) could already be a function. If so, we must evaluate it and only then apply the next argument. Therefore the common idiom is
// code for f s x new MH(f).apply(s)._e().apply(x)
public static final java.lang.invoke.MethodHandle findStatic(java.lang.Class<?> in, java.lang.String name, java.lang.invoke.MethodType type)
wrapper for MethodHandles.Lookup.findStatic(java.lang.Class<?>, java.lang.String, java.lang.invoke.MethodType)
Throw a Error
if something goes wrong as this must never happen in a
correct Frege program.
public static final java.lang.invoke.MethodHandle findVirtual(java.lang.Class<?> in, java.lang.String name, java.lang.invoke.MethodType type)
wrapper for MethodHandles.Lookup.findVirtual(java.lang.Class<?>, java.lang.String, java.lang.invoke.MethodType)
public static final java.lang.invoke.MethodHandle findStaticGetter(java.lang.Class<?> in, java.lang.String name, java.lang.Class<?> type)
wrapper for MethodHandles.Lookup.findStaticGetter(java.lang.Class<?>, java.lang.String, java.lang.Class<?>)
public static final java.lang.invoke.MethodHandle findGetter(java.lang.Class<?> in, java.lang.String name, java.lang.Class<?> type)
wrapper for MethodHandles.Lookup.findGetter(java.lang.Class<?>, java.lang.String, java.lang.Class<?>)
public static final java.lang.invoke.MethodHandle unboxRef(java.lang.Class<?> result)