public class MatchPattern extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
MatchPattern.MatchResultCode |
(package private) static class |
MatchPattern.Result
A descriptive result for match failures.
|
Modifier and Type | Field and Description |
---|---|
private static MatchPattern[] |
EMPTY_PATTERNS |
private Position[] |
inputs
The inputs to match the patterns against.
|
private String |
name
An optional name for this node.
|
private Class<? extends Node> |
nodeClass
The expected type of the node.
|
private MatchPattern[] |
patterns
Patterns to match the inputs.
|
private boolean |
singleUser
Can there only be one user of the node.
|
Modifier | Constructor and Description |
---|---|
|
MatchPattern(Class<? extends Node> nodeClass,
String name,
boolean singleUser) |
private |
MatchPattern(Class<? extends Node> nodeClass,
String name,
boolean singleUser,
MatchPattern[] patterns,
Position[] inputs) |
|
MatchPattern(Class<? extends Node> nodeClass,
String name,
MatchPattern first,
MatchPattern second,
MatchPattern third,
Position[] inputs,
boolean singleUser) |
|
MatchPattern(Class<? extends Node> nodeClass,
String name,
MatchPattern first,
MatchPattern second,
Position[] inputs,
boolean singleUser) |
|
MatchPattern(Class<? extends Node> nodeClass,
String name,
MatchPattern first,
Position[] inputs,
boolean singleUser) |
|
MatchPattern(String name,
boolean singleUser) |
Modifier and Type | Method and Description |
---|---|
String |
formatMatch(Node root)
For a node starting at root, produce a String showing the inputs that matched against this
rule.
|
private Node |
getInput(int index,
Node node) |
MatchPattern.Result |
matchShape(Node node,
MatchStatement statement)
Recursively match the shape of the tree without worry about named values.
|
private MatchPattern.Result |
matchShape(Node node,
MatchStatement statement,
boolean atRoot) |
private MatchPattern.Result |
matchType(Node node) |
(package private) MatchPattern.Result |
matchUsage(Node node,
MatchContext context)
Match any named nodes and ensure that the consumed nodes can be safely merged.
|
private MatchPattern.Result |
matchUsage(Node node,
MatchContext context,
boolean atRoot) |
(package private) Class<? extends Node> |
nodeClass() |
String |
toString() |
private final Class<? extends Node> nodeClass
private final String name
private final MatchPattern[] patterns
private final boolean singleUser
private static final MatchPattern[] EMPTY_PATTERNS
public MatchPattern(String name, boolean singleUser)
public MatchPattern(Class<? extends Node> nodeClass, String name, boolean singleUser)
private MatchPattern(Class<? extends Node> nodeClass, String name, boolean singleUser, MatchPattern[] patterns, Position[] inputs)
public MatchPattern(Class<? extends Node> nodeClass, String name, MatchPattern first, Position[] inputs, boolean singleUser)
public MatchPattern(Class<? extends Node> nodeClass, String name, MatchPattern first, MatchPattern second, Position[] inputs, boolean singleUser)
public MatchPattern(Class<? extends Node> nodeClass, String name, MatchPattern first, MatchPattern second, MatchPattern third, Position[] inputs, boolean singleUser)
private MatchPattern.Result matchType(Node node)
MatchPattern.Result matchUsage(Node node, MatchContext context)
node
- context
- private MatchPattern.Result matchUsage(Node node, MatchContext context, boolean atRoot)
public MatchPattern.Result matchShape(Node node, MatchStatement statement)
node
- statement
- private MatchPattern.Result matchShape(Node node, MatchStatement statement, boolean atRoot)
public String formatMatch(Node root)