- All Superinterfaces:
Sourceable
- All Known Subinterfaces:
AbstractFunction,LogicFunction,SystemFunction
A CIVL function.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddLocation(Location location) voidaddPossibleValidConsequence(Pair<Expression, Integer> validConsequences) Possible valid consequence is a valid contract expression which is POSSIBLE a consequence of the whole contract Notice that consequences only come from requirementsvoidaddStatement(Statement statement) voidcomputePathconditionOfLocations(ModelFactory modelFactory) booleanintfid()The id of this function in its containing scopereturns the contract specification of this function.returns the type of this function.Possible valid consequence is a valid contract expression which is POSSIBLE a consequence of the whole contract Notice that consequences only come from requirementsbooleanIs this an abstract function?booleanIs this an atomic function? An atomic function is declared with the specifier$atomic_f.booleanreturns true if and only if the function is contracted.booleanbooleanisLogic()booleanisNondet()booleanIs this a normal function that contains a function body defined in the source code?booleanis this a pure function? i.e., a function that doesn't has side effect in the statebooleanis this function a purely local function?booleanbooleanreturns true iff this function is a state functionbooleanIs this a system function? A system function doesn't contain a function body and it is implemented by a library component in Java.model()name()voidprint(String prefix, PrintStream out, boolean isDebug) Print the function.voidperforms purely local analysis one each statement/location of this function, and concludes if the whole function is purely local or not.voidperforms purely local analysis on variables for each statement/location of this function.scopes()voidvoidsetContainingScope(Scope containingScope) voidsetFreeOfUnsafeloop(boolean noUnsafeloop) voidsetFunctionContract(FunctionContract contract) sets the contract of this function.voidsetLocations(Set<Location> locations) voidsetLogic(boolean value) Set weather this function is a logic function.voidvoidsetName(Identifier name) voidsetOuterScope(Scope outerScope) voidsetParameters(List<Variable> parameters) voidsetParameterTypes(CIVLType[] types) updates the types of the parameters of this functionvoidsetPureFunction(Boolean value) updates the property of this function to be purevoidsetReturnType(CIVLType returnType) updates the return type of this functionvoidvoidsetStartLocation(Location startLocation) voidsetStateFunction(boolean value) updates the property of this function to be a state functionvoidsetStatements(Set<Statement> statements) voidsimplify()Remove all locations that satisfies the following conditions: has exactly one outgoing statement and the statement is a no-op with the guard being the true boolean expression. Meanwhile, have to redirect each statement that targets at the no-op location to the target of the no-op location.returns the string representation of all un-reached code (if any) in this function.returns the variables that are used as the operand of the address-of operator.variableAddressedOf(Scope scope) returns the variables that are used as the operand of the address-of operator and are visible from the given lexical scope.Methods inherited from interface dev.civl.mc.model.IF.Sourceable
getSource, setCIVLSource
-
Method Details
-
isNondet
boolean isNondet() -
name
Identifier name()- Returns:
- The name of this function.
-
fid
int fid()The id of this function in its containing scope- Returns:
- the id of this function
-
parameters
- Returns:
- The list of parameters.
-
returnType
CIVLType returnType()- Returns:
- The return type of this function.
-
scopes
- Returns:
- The set of scopes in this function.
-
outerScope
Scope outerScope()- Returns:
- The outermost local scope in this function.
-
containingScope
Scope containingScope()- Returns:
- The scope containing this function.
-
statements
- Returns:
- The set of statements in this function.
-
startLocation
Location startLocation()- Returns:
- The first location in this function.
-
locations
- Returns:
- The set of locations in this function.
-
model
Model model()- Returns:
- The model to which this function belongs.
-
setStatements
- Parameters:
statements- The set of statements in this function.
-
setStartLocation
- Parameters:
startLocation- The first location in this function.
-
setLocations
- Parameters:
locations- The set of locations in this function.
-
addLocation
- Parameters:
location- The new location to add.
-
addStatement
- Parameters:
statement- The new statement to add.
-
setName
- Parameters:
name- The name of this function.
-
setParameters
- Parameters:
parameters- The list of parameters.
-
setScopes
- Parameters:
scopes- The set of scopes in this function.
-
setOuterScope
- Parameters:
outerScope- The outermost local scope of this function.
-
setContainingScope
- Parameters:
containingScope- The scope containing this function.
-
setModel
- Parameters:
model- The Model to which this function belongs.
-
print
Print the function.- Parameters:
prefix- String prefix to print on each lineout- The PrintStream to use for printing.isDebug- True iff the debugging option is enabled, when more information will be printed.
-
isRootFunction
boolean isRootFunction()- Returns:
- Is this the outermost function?
-
simplify
void simplify()Remove all locations that satisfies the following conditions:- has exactly one outgoing statement and
- the statement is a no-op with the guard being the true boolean expression.
-
purelyLocalAnalysisForVariables
void purelyLocalAnalysisForVariables()performs purely local analysis on variables for each statement/location of this function. No-op for system functions. -
purelyLocalAnalysis
void purelyLocalAnalysis()performs purely local analysis one each statement/location of this function, and concludes if the whole function is purely local or not. -
variableAddressedOf
returns the variables that are used as the operand of the address-of operator and are visible from the given lexical scope.- Parameters:
scope- a lexical scope- Returns:
- returns the variables that are used as the operand of the address-of operator and are visible from the given lexical scope.
-
variableAddressedOf
returns the variables that are used as the operand of the address-of operator.- Returns:
- returns the variables that are used as the operand of the address-of operator and are visible from the given lexical scope.
-
functionType
CIVLFunctionType functionType()returns the type of this function.- Returns:
- the type of this function.
-
isSystemFunction
boolean isSystemFunction()Is this a system function? A system function doesn't contain a function body and it is implemented by a library component in Java.- Returns:
- true iff this function is a system function.
-
isAtomicFunction
boolean isAtomicFunction()Is this an atomic function? An atomic function is declared with the specifier$atomic_f. Note that abstract functions and system functions are all atomic although they don't have the$atomic_fspecifier.- Returns:
-
isAbstractFunction
boolean isAbstractFunction()Is this an abstract function?- Returns:
- true iff this function is an abstract function.
-
isNormalFunction
boolean isNormalFunction()Is this a normal function that contains a function body defined in the source code?- Returns:
- true iff this is a normal function that contains a function body defined in the source code.
-
setReturnType
updates the return type of this function- Parameters:
returnType- the type to be used as the return type of this function
-
setParameterTypes
updates the types of the parameters of this function- Parameters:
types- the types to be used as the parameter types
-
unreachedCode
StringBuffer unreachedCode()returns the string representation of all un-reached code (if any) in this function.- Returns:
- the string representation of all un-reached code (if any) in this function
-
isPureFunction
boolean isPureFunction()is this a pure function? i.e., a function that doesn't has side effect in the state- Returns:
-
addPossibleValidConsequence
Possible valid consequence is a valid contract expression which is POSSIBLE a consequence of the whole contract Notice that consequences only come from requirements- Parameters:
validConsequences-
-
getPossibleValidConsequences
List<Pair<Expression,Integer>> getPossibleValidConsequences()Possible valid consequence is a valid contract expression which is POSSIBLE a consequence of the whole contract Notice that consequences only come from requirements- Parameters:
validConsequences-
-
isContracted
boolean isContracted()returns true if and only if the function is contracted.- Returns:
-
functionContract
FunctionContract functionContract()returns the contract specification of this function.- Returns:
-
setFunctionContract
sets the contract of this function.- Parameters:
contract-
-
computePathconditionOfLocations
-
dependsNoact
boolean dependsNoact() -
isPurelyLocal
boolean isPurelyLocal()is this function a purely local function?- Returns:
-
setStateFunction
void setStateFunction(boolean value) updates the property of this function to be a state function- Parameters:
value-
-
setPureFunction
updates the property of this function to be pure- Parameters:
value-
-
isStateFunction
boolean isStateFunction()returns true iff this function is a state function- Returns:
- true iff this function is a state function
-
setFreeOfUnsafeloop
void setFreeOfUnsafeloop(boolean noUnsafeloop) - Parameters:
noUnsafeloop- Set to true iff there is no unsafe loops in the LEXICAL function body. Unsafe loop is a loop whose start location doesn't satisfy thatLocation.isSafeLoop()returns true.
-
isFreeOfUnsafeloop
boolean isFreeOfUnsafeloop()- Returns:
- true iff there is no unsafe loops in the LEXICAL function
body. Unsafe loop is a loop whose start location doesn't satisfy
that
Location.isSafeLoop()returns true.
-
isLogic
boolean isLogic()- Returns:
- true iff this function is a logic function. A call to a logic function is side-effect free.
-
setLogic
void setLogic(boolean value) Set weather this function is a logic function.- Parameters:
value- true, to set the function as a logic function; false, otherwise.
-
setAccessesAtomicFunction
-
getAccessesAtomicFunction
-