gnu.kawa.reflect

Class TypeSwitch

public class TypeSwitch extends MethodProc implements CanInline, Inlineable

Implement 'typeswitch' (as in XQuery) or 'typecase'. Usage: (typeswitch SELECTOR CASE-LAMBDA ... DEFAULT-LAMBDA) Each CASE-LAMBDA is a 1-argument MethodProc, while DEFAULT-LAMBDA is a 0-argument Procedure. Calls the first CASE-LAMBDA such that SELECTOR is a valid argument; if there is none, calls DEFAULT-LAMBDA. In the current implementation, all of CASE-LAMBDA and DEFAULT-LAMBDA must be LambdaExps, and the call must be inlined.
Field Summary
static TypeSwitchtypeSwitch
Constructor Summary
TypeSwitch(String name)
Method Summary
voidapply(CallContext ctx)
voidcompile(ApplyExp exp, Compilation comp, Target target)
TypegetReturnType(Expression[] args)
Expressioninline(ApplyExp exp, ExpWalker walker)
intnumArgs()

Field Detail

typeSwitch

public static final TypeSwitch typeSwitch

Constructor Detail

TypeSwitch

public TypeSwitch(String name)

Method Detail

apply

public void apply(CallContext ctx)

compile

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

getReturnType

public Type getReturnType(Expression[] args)

inline

public Expression inline(ApplyExp exp, ExpWalker walker)

numArgs

public int numArgs()