@SupportedAnnotationTypes(value={"com.oracle.graal.compiler.match.MatchRule","com.oracle.graal.compiler.match.MatchRules","com.oracle.graal.compiler.match.MatchableNode","com.oracle.graal.compiler.match.MatchableNodes"}) public class MatchProcessor extends AbstractProcessor
MatchRule
. A MatchStatementSet
service is
generated for each top level class containing at least one such field. These service objects can
be retrieved as follows:
Iterablesl = Services.load(MatchStatementSet.class); for (MatchStatementSet rules : sl) { ... }
Modifier and Type | Class and Description |
---|---|
private static class |
MatchProcessor.AnnotationValueVisitorImpl |
(package private) class |
MatchProcessor.MatchDescriptor |
(package private) static class |
MatchProcessor.MatchRuleDescriptor |
(package private) static class |
MatchProcessor.MatchRuleItem
Used to generate the MatchStatement constructor invocation.
|
(package private) static class |
MatchProcessor.MethodInvokerItem
Used to generate the wrapper class to invoke the code generation method.
|
private static class |
MatchProcessor.RuleParseError |
private class |
MatchProcessor.RuleParser |
(package private) static class |
MatchProcessor.TypeDescriptor |
Modifier and Type | Field and Description |
---|---|
private static boolean |
DEBUG
Set to true to enable logging to a local file during annotation processing.
|
(package private) Map<String,MatchProcessor.TypeDescriptor> |
knownTypes
The types which are know for purpose of parsing MatchRule expressions.
|
private PrintWriter |
log |
private TypeMirror |
matchableNodesTypeMirror |
private TypeMirror |
matchableNodeTypeMirror |
private TypeMirror |
matchRulesTypeMirror |
private TypeMirror |
matchRuleTypeMirror |
private Set<Element> |
processedMatchableNode |
private Set<Element> |
processedMatchRule |
private static Pattern |
tokenizer |
private MatchProcessor.TypeDescriptor |
valueType |
processingEnv
Constructor and Description |
---|
MatchProcessor() |
Modifier and Type | Method and Description |
---|---|
private void |
createFiles(MatchProcessor.MatchRuleDescriptor info) |
private void |
createProviderFile(String pkg,
String providerClassName,
Element... originatingElements) |
protected PrintWriter |
createSourceFile(String pkg,
String relativeName,
Filer filer,
Element... originatingElements) |
private void |
declareType(TypeMirror mirror,
String shortName,
String nodeClass,
String nodePackage,
String[] inputs,
boolean commutative,
boolean shareable,
Element element) |
private void |
errorMessage(Element element,
AnnotationMirror mirror,
String format,
Object... args) |
private void |
errorMessage(Element element,
String format,
Object... args) |
private AnnotationMirror |
findAnnotationMirror(Element element,
TypeMirror typeMirror) |
private void |
findMatchableNodes(Element element)
Search the super types of element for MatchableNode definitions.
|
private String |
findPackage(Element type) |
private String |
fullClassName(Element element)
Strip the package off a class name leaving the full class name including any outer classes.
|
private static AnnotationValue |
getAnnotationValue(AnnotationMirror mirror,
String name) |
private static <T> T |
getAnnotationValue(Class<T> expectedType,
AnnotationMirror mirror,
String name) |
private static <T> List<T> |
getAnnotationValueList(Class<T> expectedListType,
AnnotationMirror mirror,
String name) |
private PrintWriter |
getLog()
Logging facility for debugging the annotation processor.
|
SourceVersion |
getSupportedSourceVersion() |
private void |
logException(Throwable t) |
private void |
logMessage(String format,
Object... args) |
boolean |
process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) |
private void |
processMatchableNode(Element element)
Build up the type table to be used during parsing of the MatchRule.
|
private void |
processMatchableNode(Element element,
TypeElement topDeclaringType,
MatchableNode matchable,
AnnotationMirror mirror) |
private void |
processMatchRule(Map<TypeElement,MatchProcessor.MatchRuleDescriptor> map,
Element element,
AnnotationMirror mirror) |
private void |
processMethodMatchRule(ExecutableElement method,
MatchProcessor.MatchRuleDescriptor info,
MatchRule matchRule,
AnnotationMirror mirror) |
private void |
reportExceptionThrow(Element element,
Throwable t)
Bugs in an annotation processor can cause silent failure so try to report any exception
throws as errors.
|
private static <T> T |
resolveAnnotationValue(Class<T> expectedType,
AnnotationValue value) |
private static TypeElement |
topDeclaringType(Element element) |
private Types |
typeUtils() |
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, init, isInitialized
private final Set<Element> processedMatchRule
private final Set<Element> processedMatchableNode
private static final boolean DEBUG
private PrintWriter log
Map<String,MatchProcessor.TypeDescriptor> knownTypes
private MatchProcessor.TypeDescriptor valueType
private TypeMirror matchRulesTypeMirror
private TypeMirror matchRuleTypeMirror
private TypeMirror matchableNodeTypeMirror
private TypeMirror matchableNodesTypeMirror
public MatchProcessor()
public SourceVersion getSupportedSourceVersion()
getSupportedSourceVersion
in interface Processor
getSupportedSourceVersion
in class AbstractProcessor
private PrintWriter getLog()
private void logMessage(String format, Object... args)
private void logException(Throwable t)
private void reportExceptionThrow(Element element, Throwable t)
private void declareType(TypeMirror mirror, String shortName, String nodeClass, String nodePackage, String[] inputs, boolean commutative, boolean shareable, Element element)
private String findPackage(Element type)
private String fullClassName(Element element)
private void createFiles(MatchProcessor.MatchRuleDescriptor info)
private void createProviderFile(String pkg, String providerClassName, Element... originatingElements) throws IOException
IOException
protected PrintWriter createSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements)
private static TypeElement topDeclaringType(Element element)
private AnnotationMirror findAnnotationMirror(Element element, TypeMirror typeMirror)
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
process
in interface Processor
process
in class AbstractProcessor
private void processMatchableNode(Element element)
private void processMatchableNode(Element element, TypeElement topDeclaringType, MatchableNode matchable, AnnotationMirror mirror) throws JVMCIError
JVMCIError
private void processMatchRule(Map<TypeElement,MatchProcessor.MatchRuleDescriptor> map, Element element, AnnotationMirror mirror)
private void findMatchableNodes(Element element)
element
- private void processMethodMatchRule(ExecutableElement method, MatchProcessor.MatchRuleDescriptor info, MatchRule matchRule, AnnotationMirror mirror)
private void errorMessage(Element element, String format, Object... args)
private void errorMessage(Element element, AnnotationMirror mirror, String format, Object... args)
private static <T> List<T> getAnnotationValueList(Class<T> expectedListType, AnnotationMirror mirror, String name)
private static <T> T getAnnotationValue(Class<T> expectedType, AnnotationMirror mirror, String name)
private static <T> T resolveAnnotationValue(Class<T> expectedType, AnnotationValue value)
private static AnnotationValue getAnnotationValue(AnnotationMirror mirror, String name)