org.checkerframework.dataflow.reachingdef.ReachingDefinitionTransfer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dataflow-shaded Show documentation
Show all versions of dataflow-shaded Show documentation
dataflow-shaded is a dataflow framework based on the javac compiler.
It differs from the org.checkerframework:dataflow artifact in two ways.
First, the packages in this artifact have been renamed to org.checkerframework.shaded.*.
Second, unlike the dataflow artifact, this artifact contains the dependencies it requires.
package org.checkerframework.dataflow.reachingdef;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.analysis.ForwardTransferFunction;
import org.checkerframework.dataflow.analysis.RegularTransferResult;
import org.checkerframework.dataflow.analysis.TransferInput;
import org.checkerframework.dataflow.analysis.TransferResult;
import org.checkerframework.dataflow.analysis.UnusedAbstractValue;
import org.checkerframework.dataflow.cfg.UnderlyingAST;
import org.checkerframework.dataflow.cfg.node.AbstractNodeVisitor;
import org.checkerframework.dataflow.cfg.node.AssignmentNode;
import org.checkerframework.dataflow.cfg.node.LocalVariableNode;
import org.checkerframework.dataflow.cfg.node.Node;
/**
* The reaching definition transfer function. The transfer function processes the
* ReachingDefinitionNode in ReachingDefinitionStore, killing the node with same LHS and putting new
* generated node into the store. See dataflow manual for more details.
*/
public class ReachingDefinitionTransfer
extends AbstractNodeVisitor<
TransferResult,
TransferInput>
implements ForwardTransferFunction {
/** Create a new ReachingDefinitionTransfer. */
public ReachingDefinitionTransfer() {}
@Override
public ReachingDefinitionStore initialStore(
UnderlyingAST underlyingAST, @Nullable List parameters) {
return new ReachingDefinitionStore();
}
@Override
public RegularTransferResult visitNode(
Node n, TransferInput p) {
return new RegularTransferResult<>(null, p.getRegularStore());
}
@Override
public RegularTransferResult visitAssignment(
AssignmentNode n, TransferInput p) {
RegularTransferResult transferResult =
(RegularTransferResult)
super.visitAssignment(n, p);
processDefinition(n, transferResult.getRegularStore());
return transferResult;
}
/**
* Update a reaching definition node in the store from an assignment statement.
*
* @param def the definition that should be put into the store
* @param store the reaching definition store
*/
private void processDefinition(AssignmentNode def, ReachingDefinitionStore store) {
store.killDef(def.getTarget());
store.putDef(new ReachingDefinitionNode(def));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy