Package jdk.graal.compiler.graphio
Interface GraphStructure<G,N,C,P>
- Type Parameters:
G
- the type of the (root node of a) graphN
- the type of nodesC
- the type of node classesP
- the type of node ports
public interface GraphStructure<G,N,C,P>
Interface that defines structure of a compiler graph. The structure of a graph is composed from
nodes with properties, the classes of individual nodes, and ports associated with each node that
may contain edges to other nodes. The structure of a graph is assumed to be immutable for the
time of
operations
on it.-
Method Summary
Modifier and TypeMethodDescriptionclassForNode
(N node) Finds a node class fornode
.boolean
edgeDirect
(P port, int index) Checks whether an edge is direct.The name of an edge.Collection
<? extends N> Nodes where the edges for a port lead to/from.Type of an edge.Castsobj
to graph, if possible.nameTemplate
(C nodeClass) The template used to build the name of nodes of this class.Finds a node forobj
, if possible.Finds a node class forobj
, if possible.nodeClassType
(C nodeClass) Java class for a node class.boolean
nodeHasPredecessor
(N node) Checks if there is a predecessor for a node.int
Id ofnode
.void
Collects node properties.Nodes of a graph.int
nodesCount
(G graph) Number of nodes in a graph.portInputs
(C nodeClass) Input ports of a node class.portOutputs
(C nodeClass) Output ports of a node class.int
The number of edges in a port.
-
Method Details
-
graph
Castsobj
to graph, if possible. If the given objectobj
can be seen as a graph or sub-graph of a graph, then return the properly typed instance. Otherwise returnnull
- Parameters:
currentGraph
- the currently processed graphobj
- an object to check and view as a graph- Returns:
- appropriate graph object or
null
if the object doesn't represent a graph
-
nodes
Nodes of a graph. Each graph is composed from a fixed set of nodes. This method returns an iterable which provides access to all of them - the number of nodes provided by the iterable must match the number returned bynodesCount(java.lang.Object)
method.- Parameters:
graph
- the graph to query for nodes- Returns:
- iterable with all the graph's nodes
- See Also:
-
nodesCount
Number of nodes in a graph. The number must match the content returned bynodes(java.lang.Object)
method.- Parameters:
graph
- the graph to query- Returns:
- the number of nodes that will be returned by
nodes(java.lang.Object)
-
nodeId
Id ofnode
. Each node in the graph is uniquely identified by an integer value. If two nodes have the same id, then they shall be==
to each other.- Parameters:
node
- the node to query for an id- Returns:
- the id of the node
-
nodeHasPredecessor
Checks if there is a predecessor for a node.- Parameters:
node
- the node to check- Returns:
true
if it has a predecessor,false
otherwise
-
nodeProperties
Collects node properties. Each node can be associated with additional properties identified by their name. This method shall copy them into the provided map.- Parameters:
graph
- the current graphnode
- the node to collect properties forproperties
- the map to put the properties to
-
node
Finds a node forobj
, if possible. If the given objectobj
can be seen as an instance of node return the properly typed instance of the node class. Otherwise returnnull
.- Parameters:
obj
- an object to find node for- Returns:
- appropriate graph object or
null
if the object doesn't represent a node
-
nodeClass
Finds a node class forobj
, if possible. If the given objectobj
can be seen as an instance of node class return the properly typed instance of the node class. Otherwise returnnull
.- Parameters:
obj
- an object to find node class for- Returns:
- appropriate graph object or
null
if the object doesn't represent a node class
-
classForNode
Finds a node class fornode
.- Parameters:
node
- an instance of node in this graph- Returns:
- the node's node class, never
null
-
nameTemplate
The template used to build the name of nodes of this class. The template may use references to inputs ({i#inputName}) and its properties ({p#propertyName}).- Parameters:
nodeClass
- the node class to find name template for- Returns:
- the string representing the template
-
nodeClassType
Java class for a node class.- Parameters:
nodeClass
- the node class- Returns:
- the
Class
or other type representation of the node class
-
portInputs
Input ports of a node class. Each node class has a fixed set of ports where individual edges can attach to.- Parameters:
nodeClass
- the node class- Returns:
- input ports for the node class
-
portOutputs
Output ports of a node class. Each node class has a fixed set of ports from where individual edges can point to other nodes.- Parameters:
nodeClass
- the node class- Returns:
- output ports for the node class
-
portSize
The number of edges in a port. The protocol will then call methodsedgeDirect(java.lang.Object, int)
,edgeName(java.lang.Object, int)
,edgeType(java.lang.Object, int)
andedgeNodes(java.lang.Object, java.lang.Object, java.lang.Object, int)
for indexes from0
toportSize - 1
- Parameters:
port
- the port- Returns:
- number of edges in this port
-
edgeDirect
Checks whether an edge is direct. Direct edge shall have exactly one node - it is an error to return more than one for such an edge from the method.- Parameters:
port
- the portindex
- index from0
toportSize(java.lang.Object)
minus1
- Returns:
true
if only one node can be returned fromedgeNodes(java.lang.Object, java.lang.Object, java.lang.Object, int)
method
-
edgeName
The name of an edge.- Parameters:
port
- the portindex
- index from0
toportSize(java.lang.Object)
minus1
- Returns:
- the name of the edge
-
edgeType
Type of an edge. The type must be a graphenum
- e.g. either real instance ofEnum
subclass, or something that theGraphOutput.Builder
can recognize asenum
.- Parameters:
port
-index
- index from0
toportSize(java.lang.Object)
minus1
- Returns:
- any
Enum
representing type of the edge
-
edgeNodes
Nodes where the edges for a port lead to/from. This method is called for bothdirect/non-direct edges
. In case of a direct edge the returned collection must have exactly one element.- Parameters:
graph
- the graphnode
- the node in the graphport
- port of the node classindex
- index from0
toportSize(java.lang.Object)
minus1
- Returns:
null
if there are no edges associated with given port or collection of nodes where to/from the edges lead to
-