Package de.jplag.semantics
Class VariableRegistry
java.lang.Object
de.jplag.semantics.VariableRegistry
Registry of variables to assist in generating token semantics.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd all non-local visible variables as reads to the current CodeSemantics instance.voidEnter a class.voidEnter a local scope.voidExit a class.voidExit a local scope.booleanvoidregisterVariable(String variableName, VariableScope scope, boolean mutable) Register a variable.voidregisterVariableAccess(String variableName, boolean isClassVariable) Register a variable access, more precisely: Add a variable access to the current CodeSemantics instance.voidsetIgnoreNextVariableAccess(boolean ignoreNextVariableAccess) Set whether the next variable access is ignored.voidsetMutableWrite(boolean mutableWrite) Set whether accesses to mutable variables are writes from this point on.voidsetNextVariableAccessType(VariableAccessType nextVariableAccessType) Set the type of the next variable access.voidupdateSemantics(CodeSemantics semantics) Update the current semantics.
-
Constructor Details
-
VariableRegistry
public VariableRegistry()Initialize a new variable registry.
-
-
Method Details
-
inLocalScope
public boolean inLocalScope()- Returns:
- If we are currently in a local scope.
-
setNextVariableAccessType
Set the type of the next variable access. This only influences the very next call of registerVariableOperation.- Parameters:
nextVariableAccessType- The type of the next variable access.
-
setIgnoreNextVariableAccess
public void setIgnoreNextVariableAccess(boolean ignoreNextVariableAccess) Set whether the next variable access is ignored. This only influences the very next call of registerVariableOperation.- Parameters:
ignoreNextVariableAccess- Whether the next variable access is ignored.
-
setMutableWrite
public void setMutableWrite(boolean mutableWrite) Set whether accesses to mutable variables are writes from this point on.- Parameters:
mutableWrite- Whether accesses to mutable variables are writes from this point on.
-
enterClass
public void enterClass()Enter a class. -
exitClass
public void exitClass()Exit a class. This causes all variables bound to the current class to no longer be visible. -
enterLocalScope
public void enterLocalScope()Enter a local scope. -
exitLocalScope
public void exitLocalScope()Exit a local scope. This causes all variables bound to the current local scope to no longer be visible. -
updateSemantics
Update the current semantics.- Parameters:
semantics- are the new current semantics.
-
registerVariable
Register a variable.- Parameters:
variableName- The variable's name.scope- The variable's scope.mutable- Whether the variable is mutable.
-
registerVariableAccess
Register a variable access, more precisely: Add a variable access to the current CodeSemantics instance. The type of the access can be set with setNextVariableAccessType. By default, its type is read.- Parameters:
variableName- The variable's name.isClassVariable- Whether the variable is a class variable. This is true if a variable is qualified with the "this" keyword in Java, for example.
-
addAllNonLocalVariablesAsReads
public void addAllNonLocalVariablesAsReads()Add all non-local visible variables as reads to the current CodeSemantics instance.
-