-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from UniVE-SSV/native-calls-removal
Native calls removal
- Loading branch information
Showing
74 changed files
with
1,446 additions
and
1,355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
import it.unive.lisa.program.SourceCodeLocation; | ||
import it.unive.lisa.program.cfg.CFG; | ||
import it.unive.lisa.program.cfg.statement.Expression; | ||
import it.unive.lisa.program.cfg.statement.call.BinaryNativeCall; | ||
import it.unive.lisa.symbolic.SymbolicExpression; | ||
import it.unive.lisa.symbolic.value.BinaryExpression; | ||
import it.unive.lisa.symbolic.value.operator.binary.BinaryOperator; | ||
|
@@ -35,7 +34,7 @@ | |
* | ||
* @author <a href="mailto:[email protected]">Luca Negrini</a> | ||
*/ | ||
public class IMPAddOrConcat extends BinaryNativeCall { | ||
public class IMPAddOrConcat extends it.unive.lisa.program.cfg.statement.BinaryExpression { | ||
|
||
/** | ||
* Builds the addition. | ||
|
@@ -55,14 +54,12 @@ public IMPAddOrConcat(CFG cfg, String sourceFile, int line, int col, Expression | |
protected <A extends AbstractState<A, H, V>, | ||
H extends HeapDomain<H>, | ||
V extends ValueDomain<V>> AnalysisState<A, H, V> binarySemantics( | ||
AnalysisState<A, H, V> entryState, | ||
InterproceduralAnalysis<A, H, V> interprocedural, | ||
AnalysisState<A, H, V> leftState, | ||
AnalysisState<A, H, V> state, | ||
SymbolicExpression left, | ||
AnalysisState<A, H, V> rightState, | ||
SymbolicExpression right) | ||
throws SemanticException { | ||
AnalysisState<A, H, V> result = entryState.bottom(); | ||
AnalysisState<A, H, V> result = state.bottom(); | ||
BinaryOperator op; | ||
|
||
for (Type tleft : left.getTypes()) | ||
|
@@ -92,7 +89,7 @@ else if (tright.isNumericType() || tright.isUntyped()) | |
if (op == null) | ||
continue; | ||
|
||
result = result.lub(rightState.smallStepSemantics( | ||
result = result.lub(state.smallStepSemantics( | ||
new BinaryExpression( | ||
op == StringConcat.INSTANCE | ||
? Caches.types().mkSingletonSet(StringType.INSTANCE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ | |
import it.unive.lisa.interprocedural.InterproceduralAnalysis; | ||
import it.unive.lisa.program.SourceCodeLocation; | ||
import it.unive.lisa.program.cfg.CFG; | ||
import it.unive.lisa.program.cfg.statement.BinaryExpression; | ||
import it.unive.lisa.program.cfg.statement.Expression; | ||
import it.unive.lisa.program.cfg.statement.call.BinaryNativeCall; | ||
import it.unive.lisa.symbolic.SymbolicExpression; | ||
import it.unive.lisa.symbolic.heap.AccessChild; | ||
import it.unive.lisa.symbolic.heap.HeapDereference; | ||
|
@@ -21,7 +21,7 @@ | |
* | ||
* @author <a href="mailto:[email protected]">Luca Negrini</a> | ||
*/ | ||
public class IMPArrayAccess extends BinaryNativeCall { | ||
public class IMPArrayAccess extends BinaryExpression { | ||
|
||
/** | ||
* Builds the array access. | ||
|
@@ -42,20 +42,19 @@ public IMPArrayAccess(CFG cfg, String sourceFile, int line, int col, Expression | |
protected <A extends AbstractState<A, H, V>, | ||
H extends HeapDomain<H>, | ||
V extends ValueDomain<V>> AnalysisState<A, H, V> binarySemantics( | ||
AnalysisState<A, H, V> entryState, InterproceduralAnalysis<A, H, V> interprocedural, | ||
AnalysisState<A, H, V> leftState, | ||
InterproceduralAnalysis<A, H, V> interprocedural, | ||
AnalysisState<A, H, V> state, | ||
SymbolicExpression left, | ||
AnalysisState<A, H, V> rightState, | ||
SymbolicExpression right) | ||
|
||
throws SemanticException { | ||
|
||
if (!left.getDynamicType().isArrayType() && !left.getDynamicType().isUntyped()) | ||
return entryState.bottom(); | ||
return state.bottom(); | ||
// it is not possible to detect the correct type of the field without | ||
// resolving it. we rely on the rewriting that will happen inside heap | ||
// domain to translate this into a variable that will have its correct | ||
// type | ||
HeapDereference deref = new HeapDereference(getRuntimeTypes(), left, getLocation()); | ||
return rightState.smallStepSemantics(new AccessChild(getRuntimeTypes(), deref, right, getLocation()), this); | ||
return state.smallStepSemantics(new AccessChild(getRuntimeTypes(), deref, right, getLocation()), this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
import it.unive.lisa.program.SourceCodeLocation; | ||
import it.unive.lisa.program.cfg.CFG; | ||
import it.unive.lisa.program.cfg.statement.Expression; | ||
import it.unive.lisa.program.cfg.statement.call.NativeCall; | ||
import it.unive.lisa.program.cfg.statement.NaryExpression; | ||
import it.unive.lisa.symbolic.SymbolicExpression; | ||
import it.unive.lisa.symbolic.heap.HeapAllocation; | ||
import it.unive.lisa.symbolic.heap.HeapReference; | ||
|
@@ -25,7 +25,7 @@ | |
* | ||
* @author <a href="mailto:[email protected]">Luca Negrini</a> | ||
*/ | ||
public class IMPNewArray extends NativeCall { | ||
public class IMPNewArray extends NaryExpression { | ||
|
||
/** | ||
* Builds the array allocation. | ||
|
@@ -39,31 +39,24 @@ public class IMPNewArray extends NativeCall { | |
*/ | ||
public IMPNewArray(CFG cfg, String sourceFile, int line, int col, Type type, Expression[] dimensions) { | ||
super(cfg, new SourceCodeLocation(sourceFile, line, col), "new " + type + "[]", | ||
ArrayType.lookup(type, dimensions.length), | ||
dimensions); | ||
ArrayType.lookup(type, dimensions.length), dimensions); | ||
} | ||
|
||
@Override | ||
public <A extends AbstractState<A, H, V>, | ||
H extends HeapDomain<H>, | ||
V extends ValueDomain<V>> AnalysisState<A, H, V> callSemantics( | ||
AnalysisState<A, H, V> entryState, InterproceduralAnalysis<A, H, V> interprocedural, | ||
AnalysisState<A, H, V>[] computedStates, | ||
V extends ValueDomain<V>> AnalysisState<A, H, V> expressionSemantics( | ||
InterproceduralAnalysis<A, H, V> interprocedural, | ||
AnalysisState<A, H, V> state, | ||
ExpressionSet<SymbolicExpression>[] params) | ||
throws SemanticException { | ||
// it corresponds to the analysis state after the evaluation of all the | ||
// parameters of this call | ||
// (the semantics of this call does not need information about the | ||
// intermediate analysis states) | ||
AnalysisState<A, H, | ||
V> lastPostState = computedStates.length == 0 ? entryState : computedStates[computedStates.length - 1]; | ||
AnalysisState<A, H, | ||
V> sem = lastPostState.smallStepSemantics(new HeapAllocation(getRuntimeTypes(), getLocation()), this); | ||
HeapAllocation alloc = new HeapAllocation(getRuntimeTypes(), getLocation()); | ||
AnalysisState<A, H, V> sem = state.smallStepSemantics(alloc, this); | ||
|
||
AnalysisState<A, H, V> result = entryState.bottom(); | ||
AnalysisState<A, H, V> result = state.bottom(); | ||
for (SymbolicExpression loc : sem.getComputedExpressions()) { | ||
AnalysisState<A, H, | ||
V> refSem = sem.smallStepSemantics(new HeapReference(loc.getTypes(), loc, getLocation()), this); | ||
HeapReference ref = new HeapReference(loc.getTypes(), loc, getLocation()); | ||
AnalysisState<A, H, V> refSem = sem.smallStepSemantics(ref, this); | ||
result = result.lub(refSem); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ | |
import it.unive.lisa.program.SourceCodeLocation; | ||
import it.unive.lisa.program.cfg.CFG; | ||
import it.unive.lisa.program.cfg.statement.Expression; | ||
import it.unive.lisa.program.cfg.statement.NaryExpression; | ||
import it.unive.lisa.program.cfg.statement.VariableRef; | ||
import it.unive.lisa.program.cfg.statement.call.NativeCall; | ||
import it.unive.lisa.program.cfg.statement.call.UnresolvedCall; | ||
import it.unive.lisa.symbolic.SymbolicExpression; | ||
import it.unive.lisa.symbolic.heap.HeapAllocation; | ||
|
@@ -32,7 +32,7 @@ | |
* | ||
* @author <a href="mailto:[email protected]">Luca Negrini</a> | ||
*/ | ||
public class IMPNewObj extends NativeCall { | ||
public class IMPNewObj extends NaryExpression { | ||
|
||
/** | ||
* Builds the object allocation and initialization. | ||
|
@@ -51,30 +51,29 @@ public IMPNewObj(CFG cfg, String sourceFile, int line, int col, Type type, Expre | |
@Override | ||
public <A extends AbstractState<A, H, V>, | ||
H extends HeapDomain<H>, | ||
V extends ValueDomain<V>> AnalysisState<A, H, V> callSemantics( | ||
AnalysisState<A, H, V> entryState, InterproceduralAnalysis<A, H, V> interprocedural, | ||
AnalysisState<A, H, V>[] computedStates, | ||
V extends ValueDomain<V>> AnalysisState<A, H, V> expressionSemantics( | ||
InterproceduralAnalysis<A, H, V> interprocedural, | ||
AnalysisState<A, H, V> state, | ||
ExpressionSet<SymbolicExpression>[] params) | ||
throws SemanticException { | ||
HeapAllocation created = new HeapAllocation(getRuntimeTypes(), getLocation()); | ||
|
||
// we need to add the receiver to the parameters | ||
VariableRef paramThis = new VariableRef(getCFG(), getLocation(), "this", | ||
getStaticType()); | ||
Expression[] fullExpressions = ArrayUtils.insert(0, getParameters(), paramThis); | ||
VariableRef paramThis = new VariableRef(getCFG(), getLocation(), "this", getStaticType()); | ||
Expression[] fullExpressions = ArrayUtils.insert(0, getSubExpressions(), paramThis); | ||
ExpressionSet<SymbolicExpression>[] fullParams = ArrayUtils.insert(0, params, new ExpressionSet<>(created)); | ||
|
||
UnresolvedCall call = new UnresolvedCall(getCFG(), getLocation(), | ||
IMPFrontend.CALL_STRATEGY, true, getStaticType().toString(), fullExpressions); | ||
call.inheritRuntimeTypesFrom(this); | ||
AnalysisState<A, H, V> sem = call.callSemantics(entryState, interprocedural, computedStates, fullParams); | ||
call.setRuntimeTypes(getRuntimeTypes()); | ||
AnalysisState<A, H, V> sem = call.expressionSemantics(interprocedural, state, fullParams); | ||
|
||
if (!call.getMetaVariables().isEmpty()) | ||
sem = sem.forgetIdentifiers(call.getMetaVariables()); | ||
|
||
sem = sem.smallStepSemantics(created, this); | ||
|
||
AnalysisState<A, H, V> result = entryState.bottom(); | ||
AnalysisState<A, H, V> result = state.bottom(); | ||
for (SymbolicExpression loc : sem.getComputedExpressions()) | ||
result = result.lub(sem.smallStepSemantics(new HeapReference(loc.getTypes(), loc, getLocation()), call)); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.