Package it.unive.lisa.program
Class Global
- java.lang.Object
-
- it.unive.lisa.program.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotation(Annotation ann)Adds an annotation to the annotations of this global.booleanequals(java.lang.Object obj)AnnotationsgetAnnotations()Yields the annotations of this global element.CodeLocationgetLocation()Yields the location where this code element appears in the source file.java.lang.StringgetName()Yields the name of this global.TypegetStaticType()Yields the static type of this global.inthashCode()java.lang.StringtoString()
-
-
-
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 variablename- 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, usenullname- the name of this globalstaticType- the type of this global. If unknown, useUntyped.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, usenullname- the name of this globalstaticType- the type of this global. If unknown, useUntyped.INSTANCEannotations- 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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getLocation
public CodeLocation getLocation()
Description copied from interface:CodeElementYields the location where this code element appears in the source file.- Specified by:
getLocationin interfaceCodeElement- 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
-
-