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 java.lang.invoke.MethodTypeapplyMethodTypestatic java.lang.invoke.MethodHandleapplyToConsumerDefaultprotected java.lang.invoke.MethodHandleapplyToConsumerMethodstatic java.lang.invoke.MethodHandleapplyToObjectDefaultprotected java.lang.invoke.MethodHandleapplyToObjectMethodA static method with signature ??apply(Procedure,CallContext)static LazyPropertyKey<?>compilerKeystatic SymbolcompilerXKeystatic SymbolinlineIfConstantSymbolstatic SymbolvalidateApplyKeyKey for a property used by gnu.expr.Inlinecalls.static SymbolvalidateXApplyKeySame as validateApplyKey but handles splice args.-
Fields inherited from class gnu.mapping.PropertySet
nameKey
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectapply0()java.lang.Objectapply1(java.lang.Object arg1)java.lang.Objectapply2(java.lang.Object arg1, java.lang.Object arg2)java.lang.Objectapply3(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)java.lang.Objectapply4(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)java.lang.ObjectapplyL(ArgList args)java.lang.ObjectapplyN(java.lang.Object[] args)static java.lang.ObjectapplyToConsumerDefault(Procedure proc, CallContext ctx)static java.lang.ObjectapplyToObjectDefault(Procedure proc, CallContext ctx)static voidcheckArgCount(Procedure proc, int argCount)Check that the number of arguments in a call is valid.voidcheckBadCode(CallContext ctx)java.lang.invoke.MethodHandlegetApplyMethod()java.lang.invoke.MethodHandlegetApplyToConsumerMethod()java.lang.invoke.MethodHandlegetApplyToObjectMethod()TypegetReturnType(Expression[] args)Semi-deprecated - instead should be set at Inline time.ProceduregetSetter()java.lang.StringgetSourceLocation()booleanisSideEffectFree()True if this Procedure (definitely) has no side-effects.static java.lang.invoke.MethodHandlelookupApplyHandle(java.lang.Class clas, java.lang.String mname)intmaxArgs()Maximum number of arguments allowed, or -1 for unlimited.static intmaxArgs(int num)Extract maximum number of arguments fromnumArgs()encoding.intminArgs()Minimum number of arguments required.static intminArgs(int num)Extract minimum number of arguments fromnumArgs()encoding.intnumArgs()ReturnminArgs()|(maxArgs<<12).voidset0(java.lang.Object result)If HasSetter, the Procedure is called in the LHS of an assignment.voidset1(java.lang.Object arg1, java.lang.Object value)voidsetN(java.lang.Object[] args)voidsetSetter(Procedure setter)voidsetSourceLocation(java.lang.String file, int line)java.lang.StringtoString()-
Methods inherited from class gnu.mapping.PropertySet
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
-
-
-
-
Field Detail
-
applyToObjectMethod
protected java.lang.invoke.MethodHandle applyToObjectMethod
A static method with signature ??apply(Procedure,CallContext)
-
applyToConsumerMethod
protected java.lang.invoke.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 java.lang.invoke.MethodType applyMethodType
-
applyToObjectDefault
public static final java.lang.invoke.MethodHandle applyToObjectDefault
-
applyToConsumerDefault
public static final java.lang.invoke.MethodHandle applyToConsumerDefault
-
-
Constructor Detail
-
Procedure
public Procedure()
-
Procedure
public Procedure(java.lang.String n)
-
Procedure
public Procedure(boolean resultGoesToConsumer, java.lang.invoke.MethodHandle applyMethod)
-
Procedure
public Procedure(boolean resultGoesToConsumer, java.lang.invoke.MethodHandle applyMethod, java.lang.String n)
-
-
Method Detail
-
setSourceLocation
public void setSourceLocation(java.lang.String file, int line)
-
getSourceLocation
public java.lang.String getSourceLocation()
-
getApplyToConsumerMethod
public final java.lang.invoke.MethodHandle getApplyToConsumerMethod()
-
getApplyToObjectMethod
public final java.lang.invoke.MethodHandle getApplyToObjectMethod()
-
applyToConsumerDefault
public static java.lang.Object applyToConsumerDefault(Procedure proc, CallContext ctx) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
applyToObjectDefault
public static java.lang.Object applyToObjectDefault(Procedure proc, CallContext ctx) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
getApplyMethod
public java.lang.invoke.MethodHandle getApplyMethod()
-
checkBadCode
public void checkBadCode(CallContext ctx)
-
applyL
public java.lang.Object applyL(ArgList args) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
applyN
public java.lang.Object applyN(java.lang.Object[] args) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
apply0
public java.lang.Object apply0() throws java.lang.Throwable- Throws:
java.lang.Throwable
-
apply1
public java.lang.Object apply1(java.lang.Object arg1) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
apply2
public java.lang.Object apply2(java.lang.Object arg1, java.lang.Object arg2) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
apply3
public java.lang.Object apply3(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
apply4
public java.lang.Object apply4(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4) throws java.lang.Throwable- Throws:
java.lang.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(java.lang.Object result) throws java.lang.ThrowableIf HasSetter, the Procedure is called in the LHS of an assignment.- Throws:
java.lang.Throwable
-
set1
public void set1(java.lang.Object arg1, java.lang.Object value) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
setN
public void setN(java.lang.Object[] args) throws java.lang.Throwable- Throws:
java.lang.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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
lookupApplyHandle
public static java.lang.invoke.MethodHandle lookupApplyHandle(java.lang.Class clas, java.lang.String mname)
-
-