Class Global

  • All Implemented Interfaces:
    CodeElement
    Direct Known Subclasses:
    ConstantGlobal

    public class Global
    extends java.lang.Object
    implements CodeElement
    A global variable, scoped by its container. Instances of this class can refer both to instance variables or static global variables.
    • Constructor Summary

      Constructors 
      Constructor Description
      Global​(CodeLocation location, Unit container, java.lang.String name, boolean isInstance)
      Builds an untyped global variable, identified by its name.
      Global​(CodeLocation location, Unit container, java.lang.String name, boolean isInstance, Type staticType)
      Builds the global, identified by its name and its type, happening at the given location in the program.
      Global​(CodeLocation location, Unit container, java.lang.String name, boolean isInstance, Type staticType, Annotations annotations)
      Builds the global, identified by its name and its type, happening at the given location in the program.
    • Constructor Detail

      • Global

        public Global​(CodeLocation location,
                      Unit container,
                      java.lang.String name,
                      boolean isInstance)
        Builds an untyped global variable, identified by its name. The type of this global is unknown (i.e. it is {#link Untyped#INSTANCE}).
        Parameters:
        location - the location of this global variable
        container - the Unit containing this global
        name - the name of this global
        isInstance - whether or not this is an instance global
      • Global

        public Global​(CodeLocation location,
                      Unit container,
                      java.lang.String name,
                      boolean isInstance,
                      Type staticType)
        Builds the global, identified by its name and its type, happening at the given location in the program.
        Parameters:
        location - the location where this global is defined within the program
        container - the Unit containing this global
        name - the name of this global
        isInstance - whether or not this is an instance global
        staticType - the type of this global. If unknown, use Untyped.INSTANCE
      • Global

        public Global​(CodeLocation location,
                      Unit container,
                      java.lang.String name,
                      boolean isInstance,
                      Type staticType,
                      Annotations annotations)
        Builds the global, identified by its name and its type, happening at the given location in the program.
        Parameters:
        location - the location where this global is defined within the program
        container - the Unit containing this global
        name - the name of this global
        isInstance - whether or not this is an instance global
        staticType - the type of this global. If unknown, use Untyped.INSTANCE
        annotations - the annotations of this global variable
    • Method Detail

      • getName

        public java.lang.String getName()
        Yields the name of this global.
        Returns:
        the name of this global
      • getStaticType

        public Type getStaticType()
        Yields the static type of this global.
        Returns:
        the static type of this global
      • getContainer

        public Unit getContainer()
        Yields the unit containing this global.
        Returns:
        the container
      • isInstance

        public boolean isInstance()
        Yields true if and only if this is an instance global.
        Returns:
        true only if that condition holds
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getLocation

        public CodeLocation getLocation()
        Description copied from interface: CodeElement
        Yields the location where this code element appears in the program.
        Specified by:
        getLocation in interface CodeElement
        Returns:
        the location where this code element appears in the program
      • getAnnotations

        public Annotations getAnnotations()
        Yields the annotations of this global element.
        Returns:
        the annotations of this global element
      • addAnnotation

        public void addAnnotation​(Annotation ann)
        Adds an annotation to the annotations of this global.
        Parameters:
        ann - the annotation to be added
      • toSymbolicVariable

        public Variable toSymbolicVariable​(CodeLocation where)
        Creates a Variable that represent this global, that can be used by SemanticDomains to reference it.
        Parameters:
        where - the location where the variable will be generated
        Returns:
        the variable representing this parameter