Package it.unive.lisa.program
Class Global
- java.lang.Object
-
- it.unive.lisa.program.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAnnotation(Annotation ann)
Adds an annotation to the annotations of this global.boolean
equals(java.lang.Object obj)
Annotations
getAnnotations()
Yields the annotations of this global element.Unit
getContainer()
Yields the unit containing this global.CodeLocation
getLocation()
Yields the location where this code element appears in the program.java.lang.String
getName()
Yields the name of this global.Type
getStaticType()
Yields the static type of this global.int
hashCode()
boolean
isInstance()
Yieldstrue
if and only if this is an instance global.java.lang.String
toString()
Variable
toSymbolicVariable(CodeLocation where)
Creates aVariable
that represent this global, that can be used bySemanticDomain
s to reference it.
-
-
-
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 variablecontainer
- theUnit
containing this globalname
- the name of this globalisInstance
- 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 programcontainer
- theUnit
containing this globalname
- the name of this globalisInstance
- whether or not this is an instance globalstaticType
- the type of this global. If unknown, useUntyped.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 programcontainer
- theUnit
containing this globalname
- the name of this globalisInstance
- whether or not this is an instance globalstaticType
- the type of this global. If unknown, useUntyped.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()
Yieldstrue
if and only if this is an instance global.- Returns:
true
only if that condition holds
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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 interfaceCodeElement
- 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 aVariable
that represent this global, that can be used bySemanticDomain
s to reference it.- Parameters:
where
- the location where the variable will be generated- Returns:
- the variable representing this parameter
-
-