gnu.expr

Class PrimProcedure

Implemented Interfaces:
Inlineable, Named

public class PrimProcedure
extends MethodProc
implements Inlineable

A primitive Procedure implemented by a plain Java method.

Field Summary

Fields inherited from class gnu.mapping.MethodProc

NO_MATCH, NO_MATCH_AMBIGUOUS, NO_MATCH_BAD_TYPE, NO_MATCH_TOO_FEW_ARGS, NO_MATCH_TOO_MANY_ARGS, argTypes

Fields inherited from class gnu.mapping.ProcedureN

noArgs

Constructor Summary

PrimProcedure(ClassType classtype, Type[] argTypes)
Use to compile new followed by constructor.
PrimProcedure(Method method)
PrimProcedure(Method method, boolean is_special, Language language)
PrimProcedure(Method method, LambdaExp source)
PrimProcedure(Method method, Language language)
PrimProcedure(int op_code, ClassType classtype, String name, Type retType, Type[] argTypes)
PrimProcedure(int opcode, Type retType, Type[] argTypes)
PrimProcedure(java.lang.reflect.Method method, Language language)

Method Summary

void
apply(CallContext ctx)
void
compile(Type thisType, ApplyExp exp, Compilation comp, Target target)
void
compile(ApplyExp exp, Compilation comp, Target target)
static void
compile(Compilation comp, Method method, Target target, boolean isTailCall, int op_code, Type stackType)
static PrimProcedure
getMethodFor(Class procClass, String name, Declaration decl, Expression[] args, Language language)
Get PrimProcedure for matching method in given class.
static PrimProcedure
getMethodFor(ClassType procClass, String name, Declaration decl, Type[] atypes, Language language)
static PrimProcedure
getMethodFor(ClassType procClass, String name, Declaration decl, Expression[] args, Language language)
static PrimProcedure
getMethodFor(Procedure pproc, Declaration decl, Type[] atypes, Language language)
static PrimProcedure
getMethodFor(Procedure pproc, Declaration decl, Expression[] args, Language language)
Search for a matching static method in a procedure's class.
static PrimProcedure
getMethodFor(Procedure pproc, Expression[] args)
String
getName()
Type
getParameterType(int index)
Type[]
getParameterTypes()
static Class
getProcedureClass(Object pproc)
Type
getReturnType()
Type
getReturnType(Expression[] args)
boolean
getStaticFlag()
String
getVerboseName()
static PrimProcedure
makeBuiltinBinary(int opcode, Type type)
static PrimProcedure
makeBuiltinUnary(int opcode, Type type)
int
match0(CallContext ctx)
int
match1(Object arg1, CallContext ctx)
int
match2(Object arg1, Object arg2, CallContext ctx)
int
match3(Object arg1, Object arg2, Object arg3, CallContext ctx)
int
match4(Object arg1, Object arg2, Object arg3, Object arg4, CallContext ctx)
int
matchN(Object[] args, CallContext ctx)
int
numArgs()
int
opcode()
void
print(java.io.PrintWriter ps)
void
setReturnType(Type retType)
boolean
takesContext()
static boolean
takesContext(Method method)
boolean
takesVarArgs()
Return true iff the last parameter is a "rest" argument.
String
toString()

Methods inherited from class gnu.mapping.MethodProc

applyN, getParameterType, isApplicable, matchFailAsException, mostSpecific, mostSpecific, numParameters, resolveParameterTypes

Methods inherited from class gnu.mapping.ProcedureN

apply0, apply1, apply2, apply3, apply4, applyN

Methods inherited from class gnu.mapping.Procedure

apply, apply, apply0, apply1, apply2, apply3, apply4, applyN, check0, check1, check2, check3, check4, checkArgCount, checkN, getName, getProperty, getSetter, getSymbol, match0, match1, match2, match3, match4, matchN, maxArgs, minArgs, name, numArgs, removeProperty, set0, set1, setN, setName, setProperty, setProperty, setSetter, setSymbol, toString

Constructor Details

PrimProcedure

public PrimProcedure(ClassType classtype,
                     Type[] argTypes)
Use to compile new followed by constructor.

PrimProcedure

public PrimProcedure(Method method)

PrimProcedure

public PrimProcedure(Method method,
                     boolean is_special,
                     Language language)

PrimProcedure

public PrimProcedure(Method method,
                     LambdaExp source)

PrimProcedure

public PrimProcedure(Method method,
                     Language language)

PrimProcedure

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

PrimProcedure

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

PrimProcedure

public PrimProcedure(java.lang.reflect.Method method,
                     Language language)

Method Details

apply

public void apply(CallContext ctx)
            throws Throwable
Overrides:
apply in interface Procedure

compile

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

compile

public void compile(ApplyExp exp,
                    Compilation comp,
                    Target target)
Specified by:
compile in interface Inlineable

compile

public static void compile(Compilation comp,
                           Method method,
                           Target target,
                           boolean isTailCall,
                           int op_code,
                           Type stackType)

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,
                                         Type[] atypes,
                                         Language language)

getMethodFor

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

getMethodFor

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

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,
                                         Expression[] args)

getName

public String getName()
Specified by:
getName in interface Named
Overrides:
getName in interface Procedure

getParameterType

public Type getParameterType(int index)
Overrides:
getParameterType in interface MethodProc

getParameterTypes

public final Type[] getParameterTypes()

getProcedureClass

public static Class getProcedureClass(Object pproc)

getReturnType

public Type getReturnType()

getReturnType

public Type getReturnType(Expression[] args)
Specified by:
getReturnType in interface Inlineable

getStaticFlag

public final boolean getStaticFlag()

getVerboseName

public String getVerboseName()

makeBuiltinBinary

public static PrimProcedure makeBuiltinBinary(int opcode,
                                              Type type)

makeBuiltinUnary

public static PrimProcedure makeBuiltinUnary(int opcode,
                                             Type type)

match0

public int match0(CallContext ctx)
Overrides:
match0 in interface Procedure

match1

public int match1(Object arg1,
                  CallContext ctx)
Overrides:
match1 in interface Procedure

match2

public int match2(Object arg1,
                  Object arg2,
                  CallContext ctx)
Overrides:
match2 in interface Procedure

match3

public int match3(Object arg1,
                  Object arg2,
                  Object arg3,
                  CallContext ctx)
Overrides:
match3 in interface Procedure

match4

public int match4(Object arg1,
                  Object arg2,
                  Object arg3,
                  Object arg4,
                  CallContext ctx)
Overrides:
match4 in interface Procedure

matchN

public int matchN(Object[] args,
                  CallContext ctx)
Overrides:
matchN in interface Procedure

numArgs

public int numArgs()
Overrides:
numArgs in interface Procedure

opcode

public final int opcode()

print

public void print(java.io.PrintWriter ps)

setReturnType

public void setReturnType(Type retType)

takesContext

public boolean takesContext()

takesContext

public static boolean takesContext(Method method)

takesVarArgs

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

toString

public String toString()
Overrides:
toString in interface Procedure