Module dev.civl.mc

Interface Scope

All Superinterfaces:
Sourceable

public interface Scope extends Sourceable

A scope. A scope contains the variables exclusive to this scope and references to any subscopes.

Maintainer: Stephen Siegel (siegel)

  • 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

      Set<Scope> children()
      Returns:
      The scopes contained by this scope.
    • model

      Model model()
      Returns:
      The model to which this scope belongs.
    • setParent

      void setParent(Scope parent)
      Parameters:
      parent - The containing scope of this scope.
    • setVariables

      void setVariables(Set<Variable> variables)
      Parameters:
      variables - The set of variables contained in this scope.
    • setChildren

      void setChildren(Set<Scope> children)
      Parameters:
      children - The scopes contained by this scope.
    • addChild

      void addChild(Scope child)
      Parameters:
      A - new scope contained by this scope.
    • addVariable

      void addVariable(Variable variable)
      A new variable in this scope.
    • contains

      Variable contains(Variable variable)
      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

      Variable variable(Identifier name)
      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

      Variable variable(int vid)
      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

      void setFunction(CIVLFunction function)
      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

      void print(String prefix, PrintStream out, boolean isDebug)
      Print the scope and all children.
      Parameters:
      prefix - String prefix to print on each line
      out - 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

      int getVid(Variable staticVariable)
    • isDescendantOf

      boolean isDescendantOf(Scope anc)
      Return true if the scope is a descendant of the scope anc
      Parameters:
      anc -
      des -
      Returns:
      true or false
    • containsVariable

      boolean containsVariable(String name)
    • variable

      Variable variable(String name)
    • addFunction

      void addFunction(CIVLFunction function)
    • getFunction

      CIVLFunction getFunction(Identifier name)
    • getFunction

      CIVLFunction getFunction(String name)
    • getFunction

      CIVLFunction getFunction(int fid)
    • complete

      void complete()
    • hasVariable

      boolean hasVariable()
    • hasVariableWtPointer

      boolean hasVariableWtPointer()