Class Global

  • All Implemented Interfaces:
    CodeElement

    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, java.lang.String name)
      Builds an untyped global variable, identified by its name.
      Global​(CodeLocation location, java.lang.String name, Type staticType)
      Builds the global reference, identified by its name and its type, happening at the given location in the program.
      Global​(CodeLocation location, java.lang.String name, Type staticType, Annotations annotations)
      Builds the global reference, identified by its name and its type, happening at the given location in the program.
    • Constructor Detail

      • Global

        public Global​(CodeLocation location,
                      java.lang.String name)
        Builds an untyped global variable, identified by its name. The location where this global happens is unknown (i.e. no source file/line/column is available) as well as its type (i.e. it is {#link Untyped#INSTANCE}).
        Parameters:
        location - the location of this global variable
        name - the name of this global
      • Global

        public Global​(CodeLocation location,
                      java.lang.String name,
                      Type staticType)
        Builds the global reference, 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 source file. If unknown, use null
        name - the name of this global
        staticType - the type of this global. If unknown, use Untyped.INSTANCE
      • Global

        public Global​(CodeLocation location,
                      java.lang.String name,
                      Type staticType,
                      Annotations annotations)
        Builds the global reference, 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 source file. If unknown, use null
        name - the name of this 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
      • 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 source file.
        Specified by:
        getLocation in interface CodeElement
        Returns:
        the location where this code element apperars in the source file
      • 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