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 withUntypedreturn 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 voidaddAnnotation(Annotation ann)Adds an annotations to this descriptor.voidaddVariable(VariableTableEntry variable)Adds aVariableTableEntryat the end of the variable table.booleanequals(java.lang.Object obj)AnnotationsgetAnnotations()Yields the annotations of this descriptor.Parameter[]getFormals()Yields the array containing the formal parameters of the CFG associated with this descriptor.java.lang.StringgetFullName()Yields the full name of the CFG associated with this descriptor.java.lang.StringgetFullSignature()Yields the full signature of this cfg, that is,getSignature()preceded by the cfg's return type.java.lang.StringgetFullSignatureWithParNames()Yields the full signature of this cfg including parameters names, that is,getSignatureWithParNames()preceded by the cfg's return type.CodeLocationgetLocation()Yields the location where this code element appears in the program.java.lang.StringgetName()Yields the name of the CFG associated with this descriptor.TypegetReturnType()Yields the return type of the CFG associated with this descriptor.java.lang.StringgetSignature()Yields the signature of this cfg, composed by itsgetFullName()followed by its parameters types.java.lang.StringgetSignatureWithParNames()Yields the signature of this cfg, composed by itsgetFullName()followed by its parameters (types and names).UnitgetUnit()Yields theUnitcontaining the cfg associated to this descriptor.java.util.List<VariableTableEntry>getVariables()Yields the list ofVariableTableEntrys that have been added to this descriptor.inthashCode()booleanisInstance()Yieldstrueif and only if the cfg associated to this descriptor is an instance cfg.booleanisOverridable()Yieldstrueif and only if the cfg associated to this descriptor is can be overridden by cfgs inUnits that inherit for the cfg's unit.booleanmatchesSignature(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 ofCodeMemberthat override the cfg associated with this descriptor.java.util.Collection<CodeMember>overrides()Yields the collection ofCodeMemberthat the cfg associated with this descriptor overrides.voidsetOverridable(boolean overridable)Sets whether or not the cfg associated to this descriptor can be overridden.java.lang.StringtoString()
-
-
-
Constructor Detail
-
CodeMemberDescriptor
public CodeMemberDescriptor(CodeLocation location, Unit unit, boolean instance, java.lang.String name, Parameter... formals)
Builds the descriptor withUntypedreturn type.- Parameters:
location- the location where the cfg associated is define within the programunit- theUnitcontaining 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- theUnitcontaining 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- theUnitcontaining 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()
Yieldstrueif and only if the cfg associated to this descriptor is an instance cfg.- Returns:
trueonly 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 ofVariableTableEntrys that have been added to this descriptor.- Returns:
- the list of variables entries
-
addVariable
public void addVariable(VariableTableEntry variable)
Adds aVariableTableEntryat 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()
Yieldstrueif and only if the cfg associated to this descriptor is can be overridden by cfgs inUnits that inherit for the cfg's unit.- Returns:
trueonly 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 theUnitcontaining the cfg associated to this descriptor.- Returns:
- the unit
-
overriddenBy
public java.util.Collection<CodeMember> overriddenBy()
Yields the collection ofCodeMemberthat override the cfg associated with this descriptor.- Returns:
- the collection of code members
-
overrides
public java.util.Collection<CodeMember> overrides()
Yields the collection ofCodeMemberthat the cfg associated with this descriptor overrides.- Returns:
- the collection of code members
-
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
-
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 thatthissignature 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:
trueif the two signatures are compatible,falseotherwise
-
getLocation
public CodeLocation getLocation()
Description copied from interface:CodeElementYields the location where this code element appears in the program.- Specified by:
getLocationin 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
-
-