Annotation Type Fallback
-
@Retention(CLASS) @Target(METHOD) public @interface Fallback
A method annotated with
Fallback
is treated as aSpecialization
that implicitly links all the guards of all other declaredSpecialization
annotated methods of the operation in a negated form. As a consequence it cannot declare any other guards. The expected signature of the method must match to the signature of aSpecialization
with the additional limitation that only generically executable argument types are allowed. A generically executable argument is a an argument hat can be executed from the childNode
using an execute method withoutUnsupportedOperationException
. In many cases the generically executable type isObject
. An operation is limited to just oneFallback
specialization which is always ordered at the end of the specialization chain.A simple example showing the use of the
Fallback
annotation in a DSL operation:@Specialization int doInt(int a) {..} @Specialization int doDouble(double a) {..} @Fallback int orElse(Object a) {..}
The previous example could be redeclared just using
Specialization
annotated methods as follows:@Specialization int doInt(int a) {..} @Specialization int doDouble(double a) {..} @Specialization(guard={"!isInt(a)", "!isDouble(a)"}) int orElse(Object a) {..}
Performance note: For operations with a lot of
Specialization
annotated methods the use ofFallback
might generate a guard that is very big. Try to avoid the use ofFallback
for specializations that are significantly important for peak performance.- See Also:
Specialization
,NodeChild