- All Superinterfaces:
Sourceable
A scope. A scope contains the variables exclusive to this scope and references to any subscopes.
Maintainer: Stephen Siegel (siegel)
-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddFunction(CIVLFunction function) voidaddVariable(Variable variable) A new variable in this scope.children()voidcomplete()If a variable is already included in this scope, return the included variable.booleancontainsVariable(String name) function()getFunction(int fid) getFunction(Identifier name) getFunction(String name) intbooleanbooleanintid()booleanisDescendantOf(Scope anc) Return true if the scope is a descendant of the scope ancmodel()intintparent()voidprint(String prefix, PrintStream out, boolean isDebug) Print the scope and all children.voidsetChildren(Set<Scope> children) voidsetFunction(CIVLFunction function) voidvoidsetVariables(Set<Variable> variables) variable(int vid) Get the variable at the specified array index.variable(Identifier name) Get the variable associated with an identifier.Variable[]Important notice: Never ever modify the variable!A variable contains a pointer type if it is of type PointerType, if it is an array with elements containing pointer type, or if it is a struct with fields containing pointer type.A variables has a "procRefType" if it is of type Process, if it is an array with element of procRefType, or if it is a struct with fields of procRefType.A variables has a "scopeRefType" if it is of type Scope, if it is an array with element of scopeRefType, if it is a struct with fields of scopeRefType, or if it contains a pointer.A variables has a "$state" type, if it is of type $state, if it is an array with element of type $state, or if it is a struct with fields of type $state.A variable whose type is not a primitive type.Methods inherited from interface dev.civl.mc.model.IF.Sourceable
getSource, setCIVLSource
-
Method Details
-
parent
Scope parent()- Returns:
- The containing scope of this scope. If this is the top-most scope, returns null.
-
variables
Variable[] variables()Important notice: Never ever modify the variable!
- Returns:
- The set of variables contained in this scope. The iterator over the returned set will iterate in variable ID order.
-
numVariables
int numVariables()- Returns:
- The number of variables contained in this scope.
-
numFunctions
int numFunctions()- Returns:
- The number of functions contained in this scope.
-
id
int id()- Returns:
- The id of this scope. This id is unique within the model.
-
children
- Returns:
- The scopes contained by this scope.
-
model
Model model()- Returns:
- The model to which this scope belongs.
-
setParent
- Parameters:
parent- The containing scope of this scope.
-
setVariables
- Parameters:
variables- The set of variables contained in this scope.
-
setChildren
- Parameters:
children- The scopes contained by this scope.
-
addChild
- Parameters:
A- new scope contained by this scope.
-
addVariable
A new variable in this scope. -
contains
If a variable is already included in this scope, return the included variable. Otherwise return null.- Parameters:
variable- The variable which is being checked.- Returns:
- included variable iff variable already exists in this scope, null otherwise.
-
variable
Get the variable associated with an identifier. If this scope does not contain such a variable, parent scopes will be recursively checked.- Parameters:
name- The identifier for the variable.- Returns:
- The model representation of the variable in this scope hierarchy, or null if not found.
-
variable
Get the variable at the specified array index.- Parameters:
vid- The index of the variable. Should be in the range [0,numVariable()-1].- Returns:
- The variable at the index.
-
setFunction
- Parameters:
function- The function containing this scope.
-
function
CIVLFunction function()- Returns:
- The function containing this scope.
-
functionName
Identifier functionName()- Returns:
- The identifier of the function containing this scope.
-
variablesWithProcrefs
Collection<Variable> variablesWithProcrefs()A variables has a "procRefType" if it is of type Process, if it is an array with element of procRefType, or if it is a struct with fields of procRefType.- Returns:
- A collection of the variables in this scope with a procRefType.
-
variablesWithStaterefs
Collection<Variable> variablesWithStaterefs()A variables has a "$state" type, if it is of type $state, if it is an array with element of type $state, or if it is a struct with fields of type $state.- Returns:
- A collection of the variables in this scope with a type $state.
-
variablesWithScoperefs
Collection<Variable> variablesWithScoperefs()A variables has a "scopeRefType" if it is of type Scope, if it is an array with element of scopeRefType, if it is a struct with fields of scopeRefType, or if it contains a pointer.- Returns:
- A collection of the variables in this scope with a scopeRefType.
-
variablesWithPointers
Collection<Variable> variablesWithPointers()A variable contains a pointer type if it is of type PointerType, if it is an array with elements containing pointer type, or if it is a struct with fields containing pointer type.- Returns:
- A collection of the variables in this scope containing pointer types.
-
varsNeedSymbolicConstant
Collection<Variable> varsNeedSymbolicConstant()A variable whose type is not a primitive type.- Returns:
- A collection of the variables in this scope containing pointer types.
-
print
Print the scope and all children.- 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, such as if a variable is purely local
-
getVid
-
isDescendantOf
Return true if the scope is a descendant of the scope anc- Parameters:
anc-des-- Returns:
- true or false
-
containsVariable
-
variable
-
addFunction
-
getFunction
-
getFunction
-
getFunction
-
complete
void complete() -
hasVariable
boolean hasVariable() -
hasVariableWtPointer
boolean hasVariableWtPointer()
-