Java Code Examples for com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph.Node#getAllDependencies()

The following examples show how to use com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph.Node#getAllDependencies() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Infer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Computes a path that goes from a given node to the leafs in the graph.
 * Typically this will start from a node containing a variable in
 * {@code varsToSolve}. For any given path, the cost is computed as the total
 * number of type-variables that should be eagerly instantiated across that path.
 */
Pair<List<Node>, Integer> computeTreeToLeafs(Node n) {
    Pair<List<Node>, Integer> cachedPath = treeCache.get(n);
    if (cachedPath == null) {
        //cache miss
        if (n.isLeaf()) {
            //if leaf, stop
            cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
        } else {
            //if non-leaf, proceed recursively
            Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
            for (Node n2 : n.getAllDependencies()) {
                if (n2 == n) continue;
                Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
                path = new Pair<List<Node>, Integer>(
                        path.fst.prependList(subpath.fst),
                        path.snd + subpath.snd);
            }
            cachedPath = path;
        }
        //save results in cache
        treeCache.put(n, cachedPath);
    }
    return cachedPath;
}
 
Example 2
Source File: Infer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Computes a path that goes from a given node to the leafs in the graph.
 * Typically this will start from a node containing a variable in
 * {@code varsToSolve}. For any given path, the cost is computed as the total
 * number of type-variables that should be eagerly instantiated across that path.
 */
Pair<List<Node>, Integer> computeTreeToLeafs(Node n) {
    Pair<List<Node>, Integer> cachedPath = treeCache.get(n);
    if (cachedPath == null) {
        //cache miss
        if (n.isLeaf()) {
            //if leaf, stop
            cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
        } else {
            //if non-leaf, proceed recursively
            Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
            for (Node n2 : n.getAllDependencies()) {
                if (n2 == n) continue;
                Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
                path = new Pair<List<Node>, Integer>(
                        path.fst.prependList(subpath.fst),
                        path.snd + subpath.snd);
            }
            cachedPath = path;
        }
        //save results in cache
        treeCache.put(n, cachedPath);
    }
    return cachedPath;
}
 
Example 3
Source File: Infer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Computes a path that goes from a given node to the leafs in the graph.
 * Typically this will start from a node containing a variable in
 * {@code varsToSolve}. For any given path, the cost is computed as the total
 * number of type-variables that should be eagerly instantiated across that path.
 */
Pair<List<Node>, Integer> computeTreeToLeafs(Node n) {
    Pair<List<Node>, Integer> cachedPath = treeCache.get(n);
    if (cachedPath == null) {
        //cache miss
        if (n.isLeaf()) {
            //if leaf, stop
            cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
        } else {
            //if non-leaf, proceed recursively
            Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
            for (Node n2 : n.getAllDependencies()) {
                if (n2 == n) continue;
                Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
                path = new Pair<List<Node>, Integer>(
                        path.fst.prependList(subpath.fst),
                        path.snd + subpath.snd);
            }
            cachedPath = path;
        }
        //save results in cache
        treeCache.put(n, cachedPath);
    }
    return cachedPath;
}
 
Example 4
Source File: Infer.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Computes a path that goes from a given node to the leafs in the graph.
 * Typically this will start from a node containing a variable in
 * {@code varsToSolve}. For any given path, the cost is computed as the total
 * number of type-variables that should be eagerly instantiated across that path.
 */
Pair<List<Node>, Integer> computeTreeToLeafs(Node n) {
    Pair<List<Node>, Integer> cachedPath = treeCache.get(n);
    if (cachedPath == null) {
        //cache miss
        if (n.isLeaf()) {
            //if leaf, stop
            cachedPath = new Pair<>(List.of(n), n.data.length());
        } else {
            //if non-leaf, proceed recursively
            Pair<List<Node>, Integer> path = new Pair<>(List.of(n), n.data.length());
            for (Node n2 : n.getAllDependencies()) {
                if (n2 == n) continue;
                Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
                path = new Pair<>(path.fst.prependList(subpath.fst),
                                  path.snd + subpath.snd);
            }
            cachedPath = path;
        }
        //save results in cache
        treeCache.put(n, cachedPath);
    }
    return cachedPath;
}
 
Example 5
Source File: Infer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Computes a path that goes from a given node to the leafs in the graph.
 * Typically this will start from a node containing a variable in
 * {@code varsToSolve}. For any given path, the cost is computed as the total
 * number of type-variables that should be eagerly instantiated across that path.
 */
Pair<List<Node>, Integer> computeTreeToLeafs(Node n) {
    Pair<List<Node>, Integer> cachedPath = treeCache.get(n);
    if (cachedPath == null) {
        //cache miss
        if (n.isLeaf()) {
            //if leaf, stop
            cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
        } else {
            //if non-leaf, proceed recursively
            Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
            for (Node n2 : n.getAllDependencies()) {
                if (n2 == n) continue;
                Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
                path = new Pair<List<Node>, Integer>(
                        path.fst.prependList(subpath.fst),
                        path.snd + subpath.snd);
            }
            cachedPath = path;
        }
        //save results in cache
        treeCache.put(n, cachedPath);
    }
    return cachedPath;
}
 
Example 6
Source File: Infer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Computes a path that goes from a given node to the leafs in the graph.
 * Typically this will start from a node containing a variable in
 * {@code varsToSolve}. For any given path, the cost is computed as the total
 * number of type-variables that should be eagerly instantiated across that path.
 */
Pair<List<Node>, Integer> computeTreeToLeafs(Node n) {
    Pair<List<Node>, Integer> cachedPath = treeCache.get(n);
    if (cachedPath == null) {
        //cache miss
        if (n.isLeaf()) {
            //if leaf, stop
            cachedPath = new Pair<>(List.of(n), n.data.length());
        } else {
            //if non-leaf, proceed recursively
            Pair<List<Node>, Integer> path = new Pair<>(List.of(n), n.data.length());
            for (Node n2 : n.getAllDependencies()) {
                if (n2 == n) continue;
                Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
                path = new Pair<>(path.fst.prependList(subpath.fst),
                                  path.snd + subpath.snd);
            }
            cachedPath = path;
        }
        //save results in cache
        treeCache.put(n, cachedPath);
    }
    return cachedPath;
}
 
Example 7
Source File: Infer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Computes a path that goes from a given node to the leafs in the graph.
 * Typically this will start from a node containing a variable in
 * {@code varsToSolve}. For any given path, the cost is computed as the total
 * number of type-variables that should be eagerly instantiated across that path.
 */
Pair<List<Node>, Integer> computeTreeToLeafs(Node n) {
    Pair<List<Node>, Integer> cachedPath = treeCache.get(n);
    if (cachedPath == null) {
        //cache miss
        if (n.isLeaf()) {
            //if leaf, stop
            cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
        } else {
            //if non-leaf, proceed recursively
            Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
            for (Node n2 : n.getAllDependencies()) {
                if (n2 == n) continue;
                Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
                path = new Pair<List<Node>, Integer>(
                        path.fst.prependList(subpath.fst),
                        path.snd + subpath.snd);
            }
            cachedPath = path;
        }
        //save results in cache
        treeCache.put(n, cachedPath);
    }
    return cachedPath;
}
 
Example 8
Source File: Infer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Computes a path that goes from a given node to the leafs in the graph.
 * Typically this will start from a node containing a variable in
 * {@code varsToSolve}. For any given path, the cost is computed as the total
 * number of type-variables that should be eagerly instantiated across that path.
 */
Pair<List<Node>, Integer> computeTreeToLeafs(Node n) {
    Pair<List<Node>, Integer> cachedPath = treeCache.get(n);
    if (cachedPath == null) {
        //cache miss
        if (n.isLeaf()) {
            //if leaf, stop
            cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
        } else {
            //if non-leaf, proceed recursively
            Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
            for (Node n2 : n.getAllDependencies()) {
                if (n2 == n) continue;
                Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
                path = new Pair<List<Node>, Integer>(
                        path.fst.prependList(subpath.fst),
                        path.snd + subpath.snd);
            }
            cachedPath = path;
        }
        //save results in cache
        treeCache.put(n, cachedPath);
    }
    return cachedPath;
}
 
Example 9
Source File: Infer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Computes a path that goes from a given node to the leafs in the graph.
 * Typically this will start from a node containing a variable in
 * {@code varsToSolve}. For any given path, the cost is computed as the total
 * number of type-variables that should be eagerly instantiated across that path.
 */
Pair<List<Node>, Integer> computeTreeToLeafs(Node n) {
    Pair<List<Node>, Integer> cachedPath = treeCache.get(n);
    if (cachedPath == null) {
        //cache miss
        if (n.isLeaf()) {
            //if leaf, stop
            cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
        } else {
            //if non-leaf, proceed recursively
            Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
            for (Node n2 : n.getAllDependencies()) {
                if (n2 == n) continue;
                Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
                path = new Pair<List<Node>, Integer>(
                        path.fst.prependList(subpath.fst),
                        path.snd + subpath.snd);
            }
            cachedPath = path;
        }
        //save results in cache
        treeCache.put(n, cachedPath);
    }
    return cachedPath;
}