Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code refactor #370

Merged
merged 4 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/checkers/inference/dataflow/InferenceTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ public class InferenceTransfer extends CFTransfer {
// case where the correct, inferred RHS has no primary annotation
private Map<Tree, Pair<RefinementVariableSlot, RefinementVariableSlot>> createdTypeVarRefinementVariables = new HashMap<>();
wmdietl marked this conversation as resolved.
Show resolved Hide resolved

private final InferenceAnnotatedTypeFactory typeFactory;

public InferenceTransfer(InferenceAnalysis analysis) {
super(analysis);
typeFactory = (InferenceAnnotatedTypeFactory) analysis.getTypeFactory();
wmdietl marked this conversation as resolved.
Show resolved Hide resolved
}

private InferenceAnalysis getInferenceAnalysis() {
Expand Down Expand Up @@ -90,7 +93,6 @@ public TransferResult<CFValue, CFStore> visitAssignment(AssignmentNode assignmen

Node lhs = assignmentNode.getTarget();
CFStore store = transferInput.getRegularStore();
InferenceAnnotatedTypeFactory typeFactory = (InferenceAnnotatedTypeFactory) analysis.getTypeFactory();

// Target tree is null for field access's
Tree targetTree = assignmentNode.getTarget().getTree();
Expand Down Expand Up @@ -144,7 +146,7 @@ public TransferResult<CFValue, CFStore> visitAssignment(AssignmentNode assignmen
return createRefinementVar(assignmentNode.getTarget(), assignmentNode.getTree(), store, atm, valueType);
}

return storeDeclaration(lhs, (VariableTree) assignmentNode.getTree(), store, typeFactory);
return storeDeclaration(lhs, (VariableTree) assignmentNode.getTree(), store);

} else if (lhs.getTree().getKind() == Tree.Kind.IDENTIFIER
|| lhs.getTree().getKind() == Tree.Kind.MEMBER_SELECT) {
Expand Down Expand Up @@ -178,7 +180,6 @@ public TransferResult<CFValue, CFStore> visitAssignment(AssignmentNode assignmen
public TransferResult<CFValue, CFStore> visitStringConcatenateAssignment(StringConcatenateAssignmentNode assignmentNode, TransferInput<CFValue, CFStore> transferInput) {
// TODO: CompoundAssigment trees are not refined, see Issue 9
CFStore store = transferInput.getRegularStore();
InferenceAnnotatedTypeFactory typeFactory = (InferenceAnnotatedTypeFactory) analysis.getTypeFactory();

Tree targetTree = assignmentNode.getLeftOperand().getTree();

Expand Down Expand Up @@ -232,7 +233,7 @@ private TransferResult<CFValue, CFStore> createRefinementVar(Node lhs,
refVar = createdRefinementVariables.get(assignmentTree);
} else {
AnnotationLocation location = VariableAnnotator.treeToLocation(analysis.getTypeFactory(), assignmentTree);
refVar = getInferenceAnalysis().getSlotManager().createRefinementVariableSlot(location, slotToRefine, refineTo);
refVar = slotManager.createRefinementVariableSlot(location, slotToRefine, refineTo);

// Fields from library methods can be refined, but the slotToRefine is a ConstantSlot
// which does not have a refined slots field.
Expand All @@ -243,7 +244,7 @@ private TransferResult<CFValue, CFStore> createRefinementVar(Node lhs,
createdRefinementVariables.put(assignmentTree, refVar);
}

atm.replaceAnnotation(getInferenceAnalysis().getSlotManager().getAnnotation(refVar));
atm.replaceAnnotation(slotManager.getAnnotation(refVar));

// add refinement variable value to output
CFValue result = analysis.createAbstractValue(atm);
Expand Down Expand Up @@ -386,12 +387,10 @@ private TransferResult<CFValue, CFStore> createTypeVarRefinementVars(Node lhs, T
* @param lhs
* @param assignmentTree
* @param store
* @param typeFactory
* @return
*/
private TransferResult<CFValue, CFStore> storeDeclaration(Node lhs,
VariableTree assignmentTree, CFStore store,
InferenceAnnotatedTypeFactory typeFactory) {
VariableTree assignmentTree, CFStore store) {

AnnotatedTypeMirror atm = typeFactory.getAnnotatedType(assignmentTree);
CFValue result = analysis.createAbstractValue(atm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public ConstraintEncodingT serialize(PreferenceConstraint constraint) {

@Override
public ConstraintEncodingT serialize(CombineConstraint combineConstraint) {
return comparableConstraintEncoder == null ? null :
return combineConstraintEncoder == null ? null :
ConstraintEncoderCoordinator.dispatch(combineConstraint, combineConstraintEncoder);
}

Expand Down