public abstract class VariableContainer extends MetaInfo
Abstract class that contains VariableDeclaration
variable declarations
and bindings between internal variables and external expressions.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NEW_VAR_PREFIX
Prefix for new variables that are created by the tool.
|
Constructor and Description |
---|
VariableContainer()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsInput(java.lang.String name)
Checks rather this object contain input signal variable with the specified name.
|
boolean |
containsOutput(java.lang.String name)
Checks rather this object contain output signal variable with the specified name.
|
boolean |
containsRegister(java.lang.String name)
Checks rather this object contain register variable with the specified name.
|
boolean |
containsVariable(ru.ispras.fortress.expression.NodeVariable variable)
Checks does this object contain the specified variable.
|
boolean |
containsVariable(java.lang.String name)
Checks rather object contains a variable with the specified name.
|
ru.ispras.fortress.expression.NodeVariable |
declareNewVariable(ru.ispras.fortress.data.DataType dataType)
Declares new variable of the specified data type.
|
void |
declareVariable(ru.ispras.fortress.expression.NodeVariable variable)
Declares non-existing variable.
|
void |
declareVariable(ru.ispras.fortress.expression.NodeVariable variable,
ru.ispras.fortress.expression.Node invariant)
Declares the specified variable with the specified invariant.
|
void |
declareVariable(ru.ispras.fortress.expression.NodeVariable variable,
ru.ispras.fortress.expression.Node initialValue,
ru.ispras.fortress.expression.Node invariant)
Declares the specified variable with the specified initial value and the specified invariant.
|
void |
declareVariables(java.util.Map<ru.ispras.fortress.expression.NodeVariable,VariableDeclaration> declarations)
Declares the specified collection of variables.
|
ru.ispras.fortress.expression.NodeVariable |
declareVariableVersion(RangedVariable variable)
Declares a new version of already declared variable.
|
boolean |
equals(java.lang.Object obj) |
java.util.Map<java.lang.String,ru.ispras.fortress.expression.Node> |
getBindings()
Returns bindings.
|
ru.ispras.fortress.data.DataType |
getDataType(java.lang.String name)
Returns data type of the declared variable with the specified name.
|
VariableDeclaration |
getDeclaration(ru.ispras.fortress.expression.NodeVariable variable)
Returns the declaration of the specified variable.
|
java.util.Collection<VariableDeclaration> |
getDeclarations()
Returns variables declarations.
|
ru.ispras.fortress.expression.Node |
getInitialValue(java.lang.String name)
Returns initial value of the declared variable with the specified name.
|
java.util.Set<java.lang.String> |
getInputNames()
Returns a collection of names of the declared input signal variables.
|
ru.ispras.fortress.expression.Node |
getInvariant(java.lang.String name)
Returns invariant of the declared variable with the specified name.
|
java.util.Set<java.lang.String> |
getOutputNames()
Returns a collection of names of the declared output signal variables.
|
java.util.Set<java.lang.String> |
getRegisterNames()
Returns a collection of names of the declared register variables.
|
ru.ispras.fortress.expression.NodeVariable |
getVariable(java.lang.String name)
Returns declared variable with specified name.
|
java.util.Set<java.lang.String> |
getVariableNames()
Returns a collection of this object variables names.
|
java.util.List<ru.ispras.fortress.expression.NodeVariable> |
getVariables()
Returns declared variables.
|
java.util.Map<ru.ispras.fortress.expression.NodeVariable,VariableDeclaration> |
getVariablesMapping()
Mapping of internal variables names to variable declarations.
|
int |
hashCode() |
void |
removeDeclaration(java.lang.String name)
Removes declaration of variable with the specified name.
|
void |
setBindings(java.util.Map<java.lang.String,ru.ispras.fortress.expression.Node> bindings)
Sets bindings.
|
void |
setVariablesMapping(java.util.Map<ru.ispras.fortress.expression.NodeVariable,VariableDeclaration> map)
Adds declared variables to the existing declarations.
|
addMetaInfo, addMetaInfo, addMetaInfo, addMetaInfo, getMetaInfo, getMetaInfo, getMetaInfo, hasMetaInfo, hasMetaInfo, removeMetaInfo
public static final java.lang.String NEW_VAR_PREFIX
public java.util.Collection<VariableDeclaration> getDeclarations()
public VariableDeclaration getDeclaration(ru.ispras.fortress.expression.NodeVariable variable)
variable
- variablejava.lang.IllegalArgumentException
- when argument is null
.public java.util.Map<ru.ispras.fortress.expression.NodeVariable,VariableDeclaration> getVariablesMapping()
public ru.ispras.fortress.expression.NodeVariable getVariable(java.lang.String name)
name
- name of variable to be returnednull
if there is no such variable.java.lang.IllegalArgumentException
- when argument is null
.public java.util.List<ru.ispras.fortress.expression.NodeVariable> getVariables()
public java.util.Set<java.lang.String> getVariableNames()
public java.util.Set<java.lang.String> getInputNames()
public java.util.Set<java.lang.String> getOutputNames()
public java.util.Set<java.lang.String> getRegisterNames()
public java.util.Map<java.lang.String,ru.ispras.fortress.expression.Node> getBindings()
public ru.ispras.fortress.data.DataType getDataType(java.lang.String name)
name
- variable namenull
otherwise.public ru.ispras.fortress.expression.Node getInitialValue(java.lang.String name)
name
- variable namenull
otherwise.public ru.ispras.fortress.expression.Node getInvariant(java.lang.String name)
name
- variable namenull
otherwise.public boolean containsVariable(ru.ispras.fortress.expression.NodeVariable variable)
variable
- variable to be checkedtrue
if module already has such variable declared, false
otherwise.java.lang.IllegalArgumentException
- when argument is null
.public boolean containsVariable(java.lang.String name)
name
- variable nametrue
if object contains a variable with the specified name,
false
otherwise.public boolean containsInput(java.lang.String name)
name
- variable nametrue
if this object contains an input signal variable with the specified name,
false
otherwise.public boolean containsOutput(java.lang.String name)
name
- variable nametrue
if this object contains an output signal variable with the specified name,
false
otherwise.public boolean containsRegister(java.lang.String name)
name
- variable nametrue
if this object contains a register variable with the specified name,
false
otherwise.public void declareVariables(java.util.Map<ru.ispras.fortress.expression.NodeVariable,VariableDeclaration> declarations)
declarations
- variables declarationsjava.lang.IllegalArgumentException
- when argument is null
.public void declareVariable(ru.ispras.fortress.expression.NodeVariable variable)
Object MUST NOT contain the specified variable. Check this fact by corresponding check-method first.
variable
- variable to be addedjava.lang.IllegalArgumentException
- when argument is null
.java.lang.IllegalStateException
- when this object
already contains such variable.public void declareVariable(ru.ispras.fortress.expression.NodeVariable variable, ru.ispras.fortress.expression.Node invariant)
mObject MUST NOT contain the specified variable. Check this fact by corresponding method first.
variable
- variable to be addedinvariant
- variable invariant (can be null
)java.lang.IllegalArgumentException
- when variable argument is null
.java.lang.IllegalStateException
- when this module object
already contains such variable.public void declareVariable(ru.ispras.fortress.expression.NodeVariable variable, ru.ispras.fortress.expression.Node initialValue, ru.ispras.fortress.expression.Node invariant)
Invariant keeps a constraint on variable value.
variable
- variableinitialValue
- initial value of variableinvariant
- variable invariantpublic ru.ispras.fortress.expression.NodeVariable declareNewVariable(ru.ispras.fortress.data.DataType dataType)
NOTE: the VariableData
variable data is not set here
because of Verilog parser features.
dataType
- new variable data typejava.lang.IllegalArgumentException
- when argument is null
.public ru.ispras.fortress.expression.NodeVariable declareVariableVersion(RangedVariable variable)
Variable version is a new variable with the same data type and the same invariant as the original variable. The version name differs from the original variable name.
variable
- an already declared module variablejava.lang.IllegalArgumentException
- in the following situations:
(1) when argument is null
;
(2) when this object does not contain the specified variable.public void setVariablesMapping(java.util.Map<ru.ispras.fortress.expression.NodeVariable,VariableDeclaration> map)
map
- mapping of variable name to variable declarationjava.lang.IllegalArgumentException
- when argument is null
.public void setBindings(java.util.Map<java.lang.String,ru.ispras.fortress.expression.Node> bindings)
bindings
- new bindingsjava.lang.IllegalArgumentException
- when argument is null
.public void removeDeclaration(java.lang.String name)
name
- variable namejava.lang.IllegalArgumentException
- when argument is null
.