Skip to content

Commit

Permalink
Renaming variable() to fixedVariable() in NonRelationalElement #279
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaneg committed Sep 8, 2023
1 parent 7d2a115 commit 229430c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ public C glb(C other) throws SemanticException {
}

@Override
public C variable(Identifier id, ProgramPoint pp) throws SemanticException {
return mk(left.variable(id, pp), right.variable(id, pp));
public C fixedVariable(Identifier id, ProgramPoint pp) throws SemanticException {
return mk(left.fixedVariable(id, pp), right.fixedVariable(id, pp));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@ public InferredPair<NonInterference> evalTernaryExpression(TernaryOperator opera
@Override
public InferredPair<NonInterference> evalIdentifier(Identifier id,
InferenceSystem<NonInterference> environment, ProgramPoint pp) throws SemanticException {
return new InferredPair<>(this, variable(id, pp), state(environment.getExecutionState(), pp));
return new InferredPair<>(this, fixedVariable(id, pp), state(environment.getExecutionState(), pp));
}

@Override
public NonInterference variable(Identifier id, ProgramPoint pp) {
public NonInterference fixedVariable(Identifier id, ProgramPoint pp) {
Annotations annots = id.getAnnotations();
if (annots.isEmpty())
return mkHighLow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ public boolean isPossiblyClean() {
/**
* Default approximation for {@link Identifier}s. This method returns the
* same as
* {@link BaseNonRelationalValueDomain#variable(Identifier, ProgramPoint)}
* {@link BaseNonRelationalValueDomain#fixedVariable(Identifier, ProgramPoint)}
* if the given identifier has no annotations. Otherwise, it relies on the
* presence if {@link #TAINTED_ANNOTATION} and {@link #CLEAN_ANNOTATION} to
* produce abstract values. defaulting to bottom. <br>
* <br>
* If this method does not return bottom, it is used as return value for
* both {@link #variable(Identifier, ProgramPoint)} and
* both {@link #fixedVariable(Identifier, ProgramPoint)} and
* {@link #evalIdentifier(Identifier, ValueEnvironment, ProgramPoint)}.
*
* @param id the identifier to evaluate
Expand All @@ -126,7 +126,7 @@ public boolean isPossiblyClean() {
protected T defaultApprox(Identifier id, ProgramPoint pp) throws SemanticException {
Annotations annots = id.getAnnotations();
if (annots.isEmpty())
return BaseNonRelationalValueDomain.super.variable(id, pp);
return BaseNonRelationalValueDomain.super.fixedVariable(id, pp);

if (annots.contains(BaseTaint.TAINTED_MATCHER))
return tainted();
Expand All @@ -138,11 +138,11 @@ protected T defaultApprox(Identifier id, ProgramPoint pp) throws SemanticExcepti
}

@Override
public T variable(Identifier id, ProgramPoint pp) throws SemanticException {
public T fixedVariable(Identifier id, ProgramPoint pp) throws SemanticException {
T def = defaultApprox(id, pp);
if (!def.isBottom())
return def;
return BaseNonRelationalValueDomain.super.variable(id, pp);
return BaseNonRelationalValueDomain.super.fixedVariable(id, pp);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public M assign(Identifier id, E expression, ProgramPoint pp) throws SemanticExc

Map<Identifier, T> func = mkNewFunction(function, false);
T value = lattice.eval(expression, (M) this, pp);
T v = lattice.variable(id, pp);
T v = lattice.fixedVariable(id, pp);
if (!v.isBottom())
// some domains might provide fixed representations
// for some variables
value = v;
if (id.isWeak() && function != null && function.containsKey(id))
else if (id.isWeak() && function != null && function.containsKey(id))
// if we have a weak identifier for which we already have
// information, we we perform a weak assignment
value = value.lub(getState(id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public interface NonRelationalElement<T extends NonRelationalElement<T, E, F>,
*
* @throws SemanticException if an error occurs during the computation
*/
default T variable(Identifier id, ProgramPoint pp) throws SemanticException {
default T fixedVariable(Identifier id, ProgramPoint pp) throws SemanticException {
return bottom();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public InferenceSystem<T> assign(Identifier id, ValueExpression expression, Prog
Map<Identifier, T> func = mkNewFunction(function, false);
InferredPair<T> eval = lattice.eval(expression, this, pp);
T value = eval.getInferred();
T v = lattice.variable(id, pp);
T v = lattice.fixedVariable(id, pp);
if (!v.isBottom())
// some domains might provide fixed representations
// for some variables
Expand Down

0 comments on commit 229430c

Please sign in to comment.