Package it.unive.lisa.program.cfg
Class CodeMemberDescriptor
- java.lang.Object
-
- it.unive.lisa.program.cfg.CodeMemberDescriptor
-
- All Implemented Interfaces:
CodeElement
public class CodeMemberDescriptor extends java.lang.Object implements CodeElement
A descriptor of aCodeMember
, containing the debug informations (source file, line, column) as well as metadata.
-
-
Constructor Summary
Constructors Constructor Description CodeMemberDescriptor(CodeLocation location, Unit unit, boolean instance, java.lang.String name, Parameter... formals)
Builds the descriptor withUntyped
return type.CodeMemberDescriptor(CodeLocation location, Unit unit, boolean instance, java.lang.String name, Type returnType, Annotations annotations, Parameter... formals)
Builds the descriptor.CodeMemberDescriptor(CodeLocation location, Unit unit, boolean instance, java.lang.String name, Type returnType, Parameter... formals)
Builds the descriptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAnnotation(Annotation ann)
Adds an annotations to this descriptor.void
addVariable(VariableTableEntry variable)
Adds aVariableTableEntry
at the end of the variable table.boolean
equals(java.lang.Object obj)
Annotations
getAnnotations()
Yields the annotations of this descriptor.Parameter[]
getFormals()
Yields the array containing the formal parameters of the CFG associated with this descriptor.java.lang.String
getFullName()
Yields the full name of the CFG associated with this descriptor.java.lang.String
getFullSignature()
Yields the full signature of this cfg, that is,getSignature()
preceded by the cfg's return type.java.lang.String
getFullSignatureWithParNames()
Yields the full signature of this cfg including parameters names, that is,getSignatureWithParNames()
preceded by the cfg's return type.CodeLocation
getLocation()
Yields the location where this code element appears in the program.java.lang.String
getName()
Yields the name of the CFG associated with this descriptor.Type
getReturnType()
Yields the return type of the CFG associated with this descriptor.java.lang.String
getSignature()
Yields the signature of this cfg, composed by itsgetFullName()
followed by its parameters types.java.lang.String
getSignatureWithParNames()
Yields the signature of this cfg, composed by itsgetFullName()
followed by its parameters (types and names).Unit
getUnit()
Yields theUnit
containing the cfg associated to this descriptor.java.util.List<VariableTableEntry>
getVariables()
Yields the list ofVariableTableEntry
s that have been added to this descriptor.int
hashCode()
boolean
isInstance()
Yieldstrue
if and only if the cfg associated to this descriptor is an instance cfg.boolean
isOverridable()
Yieldstrue
if and only if the cfg associated to this descriptor is can be overridden by cfgs inUnit
s that inherit for the cfg's unit.boolean
matchesSignature(CodeMemberDescriptor reference)
Checks if the signature defined by the given descriptor is matched by the one of this descriptor.java.util.Collection<CodeMember>
overriddenBy()
Yields the collection ofCodeMember
that override the cfg associated with this descriptor.java.util.Collection<CodeMember>
overrides()
Yields the collection ofCodeMember
that the cfg associated with this descriptor overrides.void
setOverridable(boolean overridable)
Sets whether or not the cfg associated to this descriptor can be overridden.java.lang.String
toString()
-
-
-
Constructor Detail
-
CodeMemberDescriptor
public CodeMemberDescriptor(CodeLocation location, Unit unit, boolean instance, java.lang.String name, Parameter... formals)
Builds the descriptor withUntyped
return type.- Parameters:
location
- the location where the cfg associated is define within the programunit
- theUnit
containing the cfg associated to this descriptorinstance
- whether or not the cfg associated to this descriptor is an instance cfgname
- the name of the CFG associated with this descriptorformals
- the formal parametersof the CFG associated with this descriptor
-
CodeMemberDescriptor
public CodeMemberDescriptor(CodeLocation location, Unit unit, boolean instance, java.lang.String name, Type returnType, Parameter... formals)
Builds the descriptor.- Parameters:
location
- the location where the cfg associated is define within the programunit
- theUnit
containing the cfg associated to this descriptorinstance
- whether or not the cfg associated to this descriptor is an instance cfgname
- the name of the CFG associated with this descriptorreturnType
- the return type of the CFG associated with this descriptorformals
- the formal parameters of the CFG associated with this descriptor
-
CodeMemberDescriptor
public CodeMemberDescriptor(CodeLocation location, Unit unit, boolean instance, java.lang.String name, Type returnType, Annotations annotations, Parameter... formals)
Builds the descriptor.- Parameters:
location
- the location where the cfg associated is define within the programunit
- theUnit
containing the cfg associated to this descriptorinstance
- whether or not the cfg associated to this descriptor is an instance cfgname
- the name of the CFG associated with this descriptorreturnType
- the return type of the CFG associated with this descriptorannotations
- the annotations of the CFG associated with this descriptorformals
- the formal parameters of the CFG associated with this descriptor
-
-
Method Detail
-
isInstance
public boolean isInstance()
Yieldstrue
if and only if the cfg associated to this descriptor is an instance cfg.- Returns:
true
only if that condition holds
-
getName
public java.lang.String getName()
Yields the name of the CFG associated with this descriptor.- Returns:
- the name of the CFG
-
getFullName
public java.lang.String getFullName()
Yields the full name of the CFG associated with this descriptor. This might differ from its name (e.g. it might be fully qualified with the compilation unit it belongs to).- Returns:
- the full name of the CFG
-
getSignature
public java.lang.String getSignature()
Yields the signature of this cfg, composed by itsgetFullName()
followed by its parameters types.- Returns:
- the signature
-
getSignatureWithParNames
public java.lang.String getSignatureWithParNames()
Yields the signature of this cfg, composed by itsgetFullName()
followed by its parameters (types and names).- Returns:
- the signature with parameters names included
-
getFullSignature
public java.lang.String getFullSignature()
Yields the full signature of this cfg, that is,getSignature()
preceded by the cfg's return type.- Returns:
- the full signature
-
getFullSignatureWithParNames
public java.lang.String getFullSignatureWithParNames()
Yields the full signature of this cfg including parameters names, that is,getSignatureWithParNames()
preceded by the cfg's return type.- Returns:
- the full signature with parameters names included
-
getFormals
public Parameter[] getFormals()
Yields the array containing the formal parameters of the CFG associated with this descriptor.- Returns:
- the formal parameters
-
getReturnType
public Type getReturnType()
Yields the return type of the CFG associated with this descriptor.- Returns:
- the return type
-
getVariables
public java.util.List<VariableTableEntry> getVariables()
Yields the list ofVariableTableEntry
s that have been added to this descriptor.- Returns:
- the list of variables entries
-
addVariable
public void addVariable(VariableTableEntry variable)
Adds aVariableTableEntry
at the end of the variable table. The index of the variable gets overwritten with the first free index for this descriptor.- Parameters:
variable
- the entry to add
-
isOverridable
public boolean isOverridable()
Yieldstrue
if and only if the cfg associated to this descriptor is can be overridden by cfgs inUnit
s that inherit for the cfg's unit.- Returns:
true
only if that condition holds
-
setOverridable
public void setOverridable(boolean overridable)
Sets whether or not the cfg associated to this descriptor can be overridden.- Parameters:
overridable
- the overridability of the cfg
-
getUnit
public Unit getUnit()
Yields theUnit
containing the cfg associated to this descriptor.- Returns:
- the unit
-
overriddenBy
public java.util.Collection<CodeMember> overriddenBy()
Yields the collection ofCodeMember
that override the cfg associated with this descriptor.- Returns:
- the collection of code members
-
overrides
public java.util.Collection<CodeMember> overrides()
Yields the collection ofCodeMember
that the cfg associated with this descriptor overrides.- Returns:
- the collection of code members
-
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
-
matchesSignature
public boolean matchesSignature(CodeMemberDescriptor reference)
Checks if the signature defined by the given descriptor is matched by the one of this descriptor. If the signature match, this roughly means thatthis
signature can overridereference
. For two signatures to match, it is required that:- both signatures have the same name
- both signatures have the same number of formals
- for each formal, the static type of the matching signature (i.e.,
this
) can be assigned to the static type of the matched signature (i.e.,reference
)
- Parameters:
reference
- the other signature to be used as reference- Returns:
true
if the two signatures are compatible,false
otherwise
-
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 descriptor.- Returns:
- the annotations of this descriptor
-
addAnnotation
public void addAnnotation(Annotation ann)
Adds an annotations to this descriptor.- Parameters:
ann
- the annotation to be added
-
-