Class VariableRegistry

java.lang.Object
de.jplag.semantics.VariableRegistry

public class VariableRegistry extends Object
Registry of variables to assist in generating token 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

      public void setNextVariableAccessType(VariableAccessType nextVariableAccessType)
      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

      public void updateSemantics(CodeSemantics semantics)
      Update the current semantics.
      Parameters:
      semantics - are the new current semantics.
    • registerVariable

      public void registerVariable(String variableName, VariableScope scope, boolean mutable)
      Register a variable.
      Parameters:
      variableName - The variable's name.
      scope - The variable's scope.
      mutable - Whether the variable is mutable.
    • registerVariableAccess

      public void registerVariableAccess(String variableName, boolean isClassVariable)
      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.