Package gnu.kawa.reflect
Class TypeSwitch
java.lang.Object
gnu.mapping.PropertySet
gnu.mapping.Procedure
gnu.mapping.ProcedureN
gnu.mapping.MethodProc
gnu.kawa.reflect.TypeSwitch
- All Implemented Interfaces:
Inlineable
,Named
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 1-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
FieldsFields inherited from class gnu.mapping.MethodProc
applyToConsumerDefaultMP, argTypes, NO_MATCH, NO_MATCH_AMBIGUOUS, NO_MATCH_BAD_TYPE, NO_MATCH_GUARD_FALSE, NO_MATCH_TOO_FEW_ARGS, NO_MATCH_TOO_MANY_ARGS, NO_MATCH_UNUSED_KEYWORD, THROW_ON_EXCEPTION
Fields inherited from class gnu.mapping.ProcedureN
applyToObject, noArgs
Fields inherited from class gnu.mapping.Procedure
applyMethodType, applyToConsumerDefault, applyToConsumerMethod, applyToObjectDefault, applyToObjectMethod, compilerKey, compilerXKey, inlineIfConstantSymbol, validateApplyKey, validateXApplyKey
Fields inherited from class gnu.mapping.PropertySet
nameKey
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
compile
(ApplyExp exp, Compilation comp, Target target) getReturnType
(Expression[] args) Semi-deprecated - instead should be set at Inline time.int
numArgs()
ReturnminArgs()|(maxArgs<<12)
.Methods inherited from class gnu.mapping.MethodProc
applyToConsumerDefaultMP, getParameterType, isApplicable, matchFailAsException, mostSpecific, numParameters, overrideEquivalent, resolveParameterTypes
Methods inherited from class gnu.mapping.ProcedureN
applyToObject
Methods inherited from class gnu.mapping.Procedure
apply0, apply1, apply2, apply3, apply4, applyL, applyN, applyToConsumerDefault, applyToObjectDefault, checkArgCount, checkBadCode, getApplyMethod, getApplyToConsumerMethod, getApplyToObjectMethod, getSetter, getSourceLocation, isSideEffectFree, lookupApplyHandle, maxArgs, maxArgs, minArgs, minArgs, set0, set1, setN, setSetter, setSourceLocation, toString
Methods inherited from class gnu.mapping.PropertySet
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
-
Field Details
-
typeSwitch
-
-
Constructor Details
-
TypeSwitch
-
-
Method Details
-
numArgs
public int numArgs()Description copied from class:Procedure
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. -
compile
- Specified by:
compile
in interfaceInlineable
-
getReturnType
Description copied from class:Procedure
Semi-deprecated - instead should be set at Inline time. FIXME- Overrides:
getReturnType
in classProcedure
-