public Pair<List<ProgramState>, List<ProgramState>> assumeDual(ProgramState programState) { ProgramState.Pop unstack = programState.unstackValue(1); SymbolicValue sv = unstack.values.get(0); List<ProgramState> falseConstraint = sv.setConstraint(unstack.state, BooleanConstraint.FALSE); List<ProgramState> trueConstraint = sv.setConstraint(unstack.state, BooleanConstraint.TRUE); return new Pair<>(falseConstraint, trueConstraint); }
private static ObjectConstraint openedConstraint( ProgramState programState, SymbolicValue value) { final Object constraint = programState.getConstraint(value.wrappedValue()); if (constraint instanceof ObjectConstraint) { ObjectConstraint oConstraint = (ObjectConstraint) constraint; if (oConstraint.hasStatus(Status.OPENED)) { return oConstraint; } } return null; }
private static ProgramState closeResource( ProgramState programState, @Nullable final SymbolicValue target) { if (target != null) { ObjectConstraint oConstraint = openedConstraint(programState, target); if (oConstraint != null) { return programState.addConstraint( target.wrappedValue(), oConstraint.withStatus(Status.CLOSED)); } } return programState; }
public SymbolicValue createMethodSymbolicValue( MethodInvocationTree syntaxNode, List<SymbolicValue> values) { SymbolicValue result; if (isEqualsMethod(syntaxNode) || isObjectsMethod(syntaxNode.symbol(), "equals")) { result = new RelationalSymbolicValue(counter, RelationalSymbolicValue.Kind.METHOD_EQUALS); SymbolicValue leftOp = values.get(1); SymbolicValue rightOp = values.get(0); result.computedFrom(ImmutableList.of(rightOp, leftOp)); } else if (isObjectsMethod(syntaxNode.symbol(), "isNull")) { result = new NullCheckSymbolicValue(counter, true); SymbolicValue operand = values.get(0); result.computedFrom(ImmutableList.of(operand)); } else if (isObjectsMethod(syntaxNode.symbol(), "nonNull")) { result = new NullCheckSymbolicValue(counter, false); SymbolicValue operand = values.get(0); result.computedFrom(ImmutableList.of(operand)); } else { result = createDefaultSymbolicValue(); } counter++; return result; }
private void closeResultSetsRelatedTo(SymbolicValue value) { for (Map.Entry<SymbolicValue, ObjectConstraint> constrainedValue : programState.getValuesWithConstraints(Status.OPENED).entrySet()) { if (constrainedValue.getKey() instanceof ResourceWrapperSymbolicValue) { ResourceWrapperSymbolicValue rValue = (ResourceWrapperSymbolicValue) constrainedValue.getKey(); if (value.equals(rValue.dependent)) { programState = programState.addConstraint( rValue, constrainedValue.getValue().withStatus(Status.CLOSED)); } } } }
@Override public SymbolicValue wrappedValue() { return dependent.wrappedValue(); }