Package gnu.mapping
Class Procedure
- java.lang.Object
-
- gnu.mapping.PropertySet
-
- gnu.mapping.Procedure
-
- All Implemented Interfaces:
Named
- Direct Known Subclasses:
AutoloadProcedure
,Expression
,Invoke
,LangObjType.ArgListBuilder
,Procedure0
,Procedure0or1
,Procedure1
,Procedure1or2
,Procedure2
,Procedure3
,Procedure4
,ProcedureN
public class Procedure extends PropertySet
The abstract parent for all Scheme functions.
-
-
Field Summary
Fields Modifier and Type Field Description static MethodType
applyMethodType
static MethodHandle
applyToConsumerDefault
protected MethodHandle
applyToConsumerMethod
static MethodHandle
applyToObjectDefault
protected MethodHandle
applyToObjectMethod
A static method with signature ??apply(Procedure,CallContext)static LazyPropertyKey<?>
compilerKey
static Symbol
compilerXKey
static Symbol
inlineIfConstantSymbol
static Symbol
validateApplyKey
Key for a property used by gnu.expr.Inlinecalls.static Symbol
validateXApplyKey
Same as validateApplyKey but handles splice args.-
Fields inherited from class gnu.mapping.PropertySet
nameKey
-
-
Constructor Summary
Constructors Constructor Description Procedure()
Procedure(boolean resultGoesToConsumer, MethodHandle applyMethod)
Procedure(boolean resultGoesToConsumer, MethodHandle applyMethod, String n)
Procedure(String n)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
apply0()
Object
apply1(Object arg1)
Object
apply2(Object arg1, Object arg2)
Object
apply3(Object arg1, Object arg2, Object arg3)
Object
apply4(Object arg1, Object arg2, Object arg3, Object arg4)
Object
applyL(ArgList args)
Object
applyN(Object[] args)
static Object
applyToConsumerDefault(Procedure proc, CallContext ctx)
static Object
applyToObjectDefault(Procedure proc, CallContext ctx)
static void
checkArgCount(Procedure proc, int argCount)
Check that the number of arguments in a call is valid.void
checkBadCode(CallContext ctx)
MethodHandle
getApplyMethod()
MethodHandle
getApplyToConsumerMethod()
MethodHandle
getApplyToObjectMethod()
Type
getReturnType(Expression[] args)
Semi-deprecated - instead should be set at Inline time.Procedure
getSetter()
String
getSourceLocation()
boolean
isSideEffectFree()
True if this Procedure (definitely) has no side-effects.static MethodHandle
lookupApplyHandle(Class clas, String mname)
int
maxArgs()
Maximum number of arguments allowed, or -1 for unlimited.static int
maxArgs(int num)
Extract maximum number of arguments fromnumArgs()
encoding.int
minArgs()
Minimum number of arguments required.static int
minArgs(int num)
Extract minimum number of arguments fromnumArgs()
encoding.int
numArgs()
ReturnminArgs()|(maxArgs<<12)
.void
set0(Object result)
If HasSetter, the Procedure is called in the LHS of an assignment.void
set1(Object arg1, Object value)
void
setN(Object[] args)
void
setSetter(Procedure setter)
void
setSourceLocation(String file, int line)
String
toString()
-
Methods inherited from class gnu.mapping.PropertySet
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
-
-
-
-
Field Detail
-
applyToObjectMethod
protected MethodHandle applyToObjectMethod
A static method with signature ??apply(Procedure,CallContext)
-
applyToConsumerMethod
protected MethodHandle applyToConsumerMethod
-
validateApplyKey
public static final Symbol validateApplyKey
Key for a property used by gnu.expr.Inlinecalls. The property value is either a String of the form "CLASSNAME:METHODNAME", or a java.lang.reflect.Method (or FUTURE: MethodHandle) for a static method whose parameters are(ApplyExp exp, InlineCalls visitor, Type required, Procedure proc)
and returns a re-written/validatedExpression
.
-
validateXApplyKey
public static final Symbol validateXApplyKey
Same as validateApplyKey but handles splice args.
-
compilerXKey
public static final Symbol compilerXKey
-
inlineIfConstantSymbol
public static final Symbol inlineIfConstantSymbol
-
compilerKey
public static final LazyPropertyKey<?> compilerKey
-
applyMethodType
public static final MethodType applyMethodType
-
applyToObjectDefault
public static final MethodHandle applyToObjectDefault
-
applyToConsumerDefault
public static final MethodHandle applyToConsumerDefault
-
-
Constructor Detail
-
Procedure
public Procedure()
-
Procedure
public Procedure(String n)
-
Procedure
public Procedure(boolean resultGoesToConsumer, MethodHandle applyMethod)
-
Procedure
public Procedure(boolean resultGoesToConsumer, MethodHandle applyMethod, String n)
-
-
Method Detail
-
setSourceLocation
public void setSourceLocation(String file, int line)
-
getSourceLocation
public String getSourceLocation()
-
getApplyToConsumerMethod
public final MethodHandle getApplyToConsumerMethod()
-
getApplyToObjectMethod
public final MethodHandle getApplyToObjectMethod()
-
applyToConsumerDefault
public static Object applyToConsumerDefault(Procedure proc, CallContext ctx) throws Throwable
- Throws:
Throwable
-
applyToObjectDefault
public static Object applyToObjectDefault(Procedure proc, CallContext ctx) throws Throwable
- Throws:
Throwable
-
getApplyMethod
public MethodHandle getApplyMethod()
-
checkBadCode
public void checkBadCode(CallContext ctx)
-
apply3
public Object apply3(Object arg1, Object arg2, Object arg3) throws Throwable
- Throws:
Throwable
-
apply4
public Object apply4(Object arg1, Object arg2, Object arg3, Object arg4) throws Throwable
- Throws:
Throwable
-
minArgs
public final int minArgs()
Minimum number of arguments required.
-
maxArgs
public final int maxArgs()
Maximum number of arguments allowed, or -1 for unlimited. (May also return -1 if there are keyword arguments, for implementation reasons - FIXME.)
-
numArgs
public int numArgs()
ReturnminArgs()|(maxArgs<<12)
. We use a single virtual function to reduce the number of methods in the system, as well as the number of virtual method table entries. We shift by 12 so the number can normally be represented using a sipush instruction, without requiring a constant pool entry.
-
minArgs
public static int minArgs(int num)
Extract minimum number of arguments fromnumArgs()
encoding.
-
maxArgs
public static int maxArgs(int num)
Extract maximum number of arguments fromnumArgs()
encoding.
-
checkArgCount
public static void checkArgCount(Procedure proc, int argCount)
Check that the number of arguments in a call is valid.- Parameters:
proc
- the Procedure being calledargCount
- the number of arguments in the call- Throws:
WrongArguments
- there are too many or too few actual arguments
-
getSetter
public Procedure getSetter()
-
setSetter
public void setSetter(Procedure setter)
-
set0
public void set0(Object result) throws Throwable
If HasSetter, the Procedure is called in the LHS of an assignment.- Throws:
Throwable
-
isSideEffectFree
public boolean isSideEffectFree()
True if this Procedure (definitely) has no side-effects. Note side-effect-free does not imply idempotent if this allocates an object with "identity".
-
getReturnType
public Type getReturnType(Expression[] args)
Semi-deprecated - instead should be set at Inline time. FIXME
-
lookupApplyHandle
public static MethodHandle lookupApplyHandle(Class clas, String mname)
-
-