gnu.expr

Class PrimProcedure

public class PrimProcedure extends MethodProc implements Inlineable

A primitive Procedure implemented by a plain Java method.
Constructor Summary
PrimProcedure(String className, String methodName, int numArgs)
PrimProcedure(Method method, Language language)
PrimProcedure(Method method)
PrimProcedure(Method method, Language language)
PrimProcedure(Method method, char mode, Language language)
PrimProcedure(Method method, LambdaExp source)
PrimProcedure(int opcode, Type retType, Type[] argTypes)
PrimProcedure(int op_code, ClassType classtype, String name, Type retType, Type[] argTypes)
Method Summary
voidapply(CallContext ctx)
voidcompile(ApplyExp exp, Compilation comp, Target target)
static voidcompileInvoke(Compilation comp, Method method, Target target, boolean isTailCall, int op_code, Type stackType)
Emit the actual invoke operation, after arguments have been pushed.
MethodgetMethod()
static PrimProceduregetMethodFor(Procedure pproc, Expression[] args)
static PrimProceduregetMethodFor(Procedure pproc, Declaration decl, Expression[] args, Language language)
Search for a matching static method in a procedure's class.
static PrimProceduregetMethodFor(Procedure pproc, Declaration decl, Type[] atypes, Language language)
static PrimProceduregetMethodFor(Class procClass, String name, Declaration decl, Expression[] args, Language language)
Get PrimProcedure for matching method in given class.
static PrimProceduregetMethodFor(ClassType procClass, String name, Declaration decl, Expression[] args, Language language)
static PrimProceduregetMethodFor(ClassType procClass, String name, Declaration decl, Type[] atypes, Language language)
StringgetName()
TypegetParameterType(int index)
Type[]getParameterTypes()
static ClassgetProcedureClass(Object pproc)
TypegetReturnType()
TypegetReturnType(Expression[] args)
booleangetStaticFlag()
True if there is no 'this' parameter.
StringgetVerboseName()
booleanisConstructor()
booleanisSpecial()
static PrimProceduremakeBuiltinBinary(int opcode, Type type)
static PrimProceduremakeBuiltinUnary(int opcode, Type type)
intmatch0(CallContext ctx)
intmatch1(Object arg1, CallContext ctx)
intmatch2(Object arg1, Object arg2, CallContext ctx)
intmatch3(Object arg1, Object arg2, Object arg3, CallContext ctx)
intmatch4(Object arg1, Object arg2, Object arg3, Object arg4, CallContext ctx)
intmatchN(Object[] args, CallContext ctx)
intnumArgs()
The (minimum, number) of arguments.
intopcode()
voidprint(PrintWriter ps)
voidsetReturnType(Type retType)
booleantakesContext()
static booleantakesContext(Method method)
booleantakesTarget()
Whether we are passed an argument for the 'target' / 'receiver' / 'this'.
booleantakesVarArgs()
Return true iff the last parameter is a "rest" argument.
StringtoString()

Constructor Detail

PrimProcedure

public PrimProcedure(String className, String methodName, int numArgs)

PrimProcedure

public PrimProcedure(Method method, Language language)

PrimProcedure

public PrimProcedure(Method method)

PrimProcedure

public PrimProcedure(Method method, Language language)

PrimProcedure

public PrimProcedure(Method method, char mode, Language language)

PrimProcedure

public PrimProcedure(Method method, LambdaExp source)

PrimProcedure

public PrimProcedure(int opcode, Type retType, Type[] argTypes)

PrimProcedure

public PrimProcedure(int op_code, ClassType classtype, String name, Type retType, Type[] argTypes)

Method Detail

apply

public void apply(CallContext ctx)

compile

public void compile(ApplyExp exp, Compilation comp, Target target)

compileInvoke

public static void compileInvoke(Compilation comp, Method method, Target target, boolean isTailCall, int op_code, Type stackType)
Emit the actual invoke operation, after arguments have been pushed. Does whatever magic is needed to pass the result to target, including passing CallContext or special handling of ConsumerTarget.

getMethod

public Method getMethod()

getMethodFor

public static PrimProcedure getMethodFor(Procedure pproc, Expression[] args)

getMethodFor

public static PrimProcedure getMethodFor(Procedure pproc, Declaration decl, Expression[] args, Language language)
Search for a matching static method in a procedure's class.

Returns: a PrimProcedure that is suitable, or null.

getMethodFor

public static PrimProcedure getMethodFor(Procedure pproc, Declaration decl, Type[] atypes, Language language)

getMethodFor

public static PrimProcedure getMethodFor(Class procClass, String name, Declaration decl, Expression[] args, Language language)
Get PrimProcedure for matching method in given class.

getMethodFor

public static PrimProcedure getMethodFor(ClassType procClass, String name, Declaration decl, Expression[] args, Language language)

getMethodFor

public static PrimProcedure getMethodFor(ClassType procClass, String name, Declaration decl, Type[] atypes, Language language)

getName

public String getName()

getParameterType

public Type getParameterType(int index)

getParameterTypes

public final Type[] getParameterTypes()

getProcedureClass

public static Class getProcedureClass(Object pproc)

getReturnType

public Type getReturnType()

getReturnType

public Type getReturnType(Expression[] args)

getStaticFlag

public final boolean getStaticFlag()
True if there is no 'this' parameter.

getVerboseName

public String getVerboseName()

isConstructor

public final boolean isConstructor()

isSpecial

public boolean isSpecial()

makeBuiltinBinary

public static PrimProcedure makeBuiltinBinary(int opcode, Type type)

makeBuiltinUnary

public static PrimProcedure makeBuiltinUnary(int opcode, Type type)

match0

public int match0(CallContext ctx)

match1

public int match1(Object arg1, CallContext ctx)

match2

public int match2(Object arg1, Object arg2, CallContext ctx)

match3

public int match3(Object arg1, Object arg2, Object arg3, CallContext ctx)

match4

public int match4(Object arg1, Object arg2, Object arg3, Object arg4, CallContext ctx)

matchN

public int matchN(Object[] args, CallContext ctx)

numArgs

public int numArgs()
The (minimum, number) of arguments. Doesn't not count implicit CallContext argument. Does count 'this' argument for non-static methods. Does count an implicit staticLink argument for constructor.

opcode

public final int opcode()

print

public void print(PrintWriter ps)

setReturnType

public void setReturnType(Type retType)

takesContext

public boolean takesContext()

takesContext

public static boolean takesContext(Method method)

takesTarget

public boolean takesTarget()
Whether we are passed an argument for the 'target' / 'receiver' / 'this'. Normally this is false for static methods and true for non-static methods. However, we may need to be able to call a static method using {@code object.name(args...)} (Java syntax) or {@code (invoke object 'name args...)} (Scheme syntax). This includes when the {@code object} is implied. In this case we need to ignore the first argument's value.

takesVarArgs

public boolean takesVarArgs()
Return true iff the last parameter is a "rest" argument.

toString

public String toString()