Annotation Type Fallback
-
@Retention(CLASS) @Target(METHOD) public @interface FallbackA method annotated with
Fallbackis treated as aSpecializationthat implicitly links all the guards of all other declaredSpecializationannotated 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 aSpecializationwith 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 childNodeusing an execute method withoutUnsupportedOperationException. In many cases the generically executable type isObject. An operation is limited to just oneFallbackspecialization which is always ordered at the end of the specialization chain.A simple example showing the use of the
Fallbackannotation 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
Specializationannotated 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
Specializationannotated methods the use ofFallbackmight generate a guard that is very big. Try to avoid the use ofFallbackfor specializations that are significantly important for peak performance.- See Also:
Specialization,NodeChild