Class CodeMemberDescriptor

  • All Implemented Interfaces:
    CodeElement

    public class CodeMemberDescriptor
    extends java.lang.Object
    implements CodeElement
    A descriptor of a CodeMember, containing the debug informations (source file, line, column) as well as metadata.
    • Constructor Detail

      • CodeMemberDescriptor

        public CodeMemberDescriptor​(CodeLocation location,
                                    Unit unit,
                                    boolean instance,
                                    java.lang.String name,
                                    Parameter... formals)
        Builds the descriptor with Untyped return type.
        Parameters:
        location - the location where the cfg associated is define within the program
        unit - the Unit containing the cfg associated to this descriptor
        instance - whether or not the cfg associated to this descriptor is an instance cfg
        name - the name of the CFG associated with this descriptor
        formals - 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 program
        unit - the Unit containing the cfg associated to this descriptor
        instance - whether or not the cfg associated to this descriptor is an instance cfg
        name - the name of the CFG associated with this descriptor
        returnType - the return type of the CFG associated with this descriptor
        formals - 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 program
        unit - the Unit containing the cfg associated to this descriptor
        instance - whether or not the cfg associated to this descriptor is an instance cfg
        name - the name of the CFG associated with this descriptor
        returnType - the return type of the CFG associated with this descriptor
        annotations - the annotations of the CFG associated with this descriptor
        formals - the formal parameters of the CFG associated with this descriptor
    • Method Detail

      • isInstance

        public boolean isInstance()
        Yields true 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 its getFullName() followed by its parameters types.
        Returns:
        the signature
      • getSignatureWithParNames

        public java.lang.String getSignatureWithParNames()
        Yields the signature of this cfg, composed by its getFullName() 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 of VariableTableEntrys that have been added to this descriptor.
        Returns:
        the list of variables entries
      • addVariable

        public void addVariable​(VariableTableEntry variable)
        Adds a VariableTableEntry 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()
        Yields true if and only if the cfg associated to this descriptor is can be overridden by cfgs in Units 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 the Unit containing the cfg associated to this descriptor.
        Returns:
        the unit
      • overriddenBy

        public java.util.Collection<CodeMember> overriddenBy()
        Yields the collection of CodeMember that override the cfg associated with this descriptor.
        Returns:
        the collection of code members
      • overrides

        public java.util.Collection<CodeMember> overrides()
        Yields the collection of CodeMember that the cfg associated with this descriptor overrides.
        Returns:
        the collection of code members
      • 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
      • 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 that this signature can override reference. 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 interface CodeElement
        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