Search in sources :

Example 1 with CallEnvironment

use of org.jetbrains.plugins.groovy.lang.psi.controlFlow.CallEnvironment in project intellij-community by JetBrains.

the class DFAEngine method performDFA.

@Nullable
private List<E> performDFA(boolean timeout) {
    final int n = myFlow.length;
    final List<E> info = new ArrayList<>(Collections.nCopies(n, myDfa.initial()));
    final CallEnvironment env = new MyCallEnvironment(n);
    final WorkList workList = new WorkList(getFlowOrder());
    while (!workList.isEmpty()) {
        ProgressManager.checkCanceled();
        if (timeout && checkCounter())
            return null;
        final int num = workList.next();
        final Instruction curr = myFlow[num];
        // saved outbound state
        final E oldE = info.get(num);
        // inbound state
        final E newE = getInboundState(curr, info, env);
        // newly modified outbound state
        myDfa.fun(newE, curr);
        if (!mySemilattice.eq(newE, oldE)) {
            // if outbound state changed
            // save new state
            info.set(num, newE);
            for (Instruction next : getNext(curr, env)) {
                workList.offer(next.num());
            }
        }
    }
    return info;
}
Also used : CallEnvironment(org.jetbrains.plugins.groovy.lang.psi.controlFlow.CallEnvironment) Instruction(org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction) CallInstruction(org.jetbrains.plugins.groovy.lang.psi.controlFlow.CallInstruction) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)1 CallEnvironment (org.jetbrains.plugins.groovy.lang.psi.controlFlow.CallEnvironment)1 CallInstruction (org.jetbrains.plugins.groovy.lang.psi.controlFlow.CallInstruction)1 Instruction (org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction)1