summaryrefslogtreecommitdiff
path: root/src/main/java/com/seaofnodes/simple/node/MultiNode.java
blob: b4d6d78e68811a3ad73e10015b06cdd09f6778ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.seaofnodes.simple.node;

import com.seaofnodes.simple.util.Ary;


public interface MultiNode {

    abstract Ary<Node> outs();

    // Find a projection by index
    default ProjNode proj( int idx ) {
        for( Node out : outs() )
            if( out instanceof ProjNode prj && prj._idx==idx )
                return prj;
        return null;
    }

    // Find a projection by index
    default CProjNode cproj( int idx ) {
        for( Node out : outs() )
            if( out instanceof CProjNode prj && prj._idx==idx )
                return prj;
        return null;
    }

    // Return not-null if this projection index is a ideal copy.
    // Called by ProjNode ideal and used to collapse Multis.
    default Node pcopy(int idx) { return null; }
}