Interface ReferenceManager

  • All Known Implementing Classes:
    ReferenceDBManager

    public interface ReferenceManager
    Interface for managing references.
    • Field Detail

      • MNEMONIC

        static final int MNEMONIC
        Operand index which corresponds to the instruction/data mnemonic.
        See Also:
        Constant Field Values
    • Method Detail

      • addReference

        Reference addReference​(Reference reference)
        Add a memory, stack, register or external reference
        Parameters:
        reference -
      • addStackReference

        Reference addStackReference​(Address fromAddr,
                                    int opIndex,
                                    int stackOffset,
                                    RefType type,
                                    SourceType source)
        Add a reference to a stack location. If a reference already exists for the fromAddr and opIndex, the existing reference is replaced with the new reference.
        Parameters:
        fromAddr - "from" address within a function
        opIndex - operand index
        stackOffset - stack offset of the reference
        type - reference type - how the location is being referenced.
        source - the source of this reference
      • addRegisterReference

        Reference addRegisterReference​(Address fromAddr,
                                       int opIndex,
                                       Register register,
                                       RefType type,
                                       SourceType source)
        Add a reference to a register. If a reference already exists for the fromAddr and opIndex, the existing reference is replaced with the new reference.
        Parameters:
        fromAddr - "from" address
        opIndex - operand index
        register - register to add the reference to
        type - reference type - how the location is being referenced.
        source - the source of this reference
      • addMemoryReference

        Reference addMemoryReference​(Address fromAddr,
                                     Address toAddr,
                                     RefType type,
                                     SourceType source,
                                     int opIndex)
        Adds a memory reference.
        Parameters:
        fromAddr - address of the codeunit where the reference occurs
        toAddr - address of the location being referenced. Memory, stack, and register addresses are all permitted.
        type - reference type - how the location is being referenced.
        source - the source of this reference
        opIndex - the operand index display of the operand making this reference
      • addOffsetMemReference

        Reference addOffsetMemReference​(Address fromAddr,
                                        Address toAddr,
                                        long offset,
                                        RefType type,
                                        SourceType source,
                                        int opIndex)
        Add an offset memory reference.
        Parameters:
        fromAddr - address for the "from"
        toAddr - address of the "to"
        offset - value added to a base address to get the toAddr
        type - reference type - how the location is being referenced
        source - the source of this reference
        opIndex - the operand index
      • addShiftedMemReference

        Reference addShiftedMemReference​(Address fromAddr,
                                         Address toAddr,
                                         int shiftValue,
                                         RefType type,
                                         SourceType source,
                                         int opIndex)
        Add a shifted memory reference; the "to" address is computed as the value at the operand at opIndex shifted by some number of bits, specified in the shiftValue parameter.
        Parameters:
        fromAddr - address for the "from"
        toAddr - computed as the value of the operand at opIndex shifted by the number of bits specified by shiftValue
        shiftValue -
        type - reference type - how the location is being referenced
        source - the source of this reference
        opIndex - the operand index
      • addExternalReference

        Reference addExternalReference​(Address fromAddr,
                                       java.lang.String libraryName,
                                       java.lang.String extLabel,
                                       Address extAddr,
                                       SourceType source,
                                       int opIndex,
                                       RefType type)
                                throws InvalidInputException,
                                       DuplicateNameException
        Adds an external reference.
        Parameters:
        fromAddr - from address (source of the reference)
        libraryName - name of external program
        extLabel - label within the external program, may be null if extAddr is not null
        extAddr - address within the external program, may be null
        source - the source of this reference
        type - reference type - how the location is being referenced
        opIndex - operand index
        Throws:
        InvalidInputException
        DuplicateNameException
      • addExternalReference

        Reference addExternalReference​(Address fromAddr,
                                       Namespace extNamespace,
                                       java.lang.String extLabel,
                                       Address extAddr,
                                       SourceType source,
                                       int opIndex,
                                       RefType type)
                                throws InvalidInputException,
                                       DuplicateNameException
        Adds an external reference.
        Parameters:
        fromAddr - from address (source of the reference)
        extNamespace - external namespace containing the named external label.
        extLabel - label within the external program, may be null if extAddr is not null
        extAddr - address within the external program, may be null
        source - the source of this reference
        type - reference type - how the location is being referenced
        opIndex - operand index
        Throws:
        InvalidInputException
        DuplicateNameException
      • addExternalReference

        Reference addExternalReference​(Address fromAddr,
                                       int opIndex,
                                       ExternalLocation location,
                                       SourceType source,
                                       RefType type)
                                throws InvalidInputException
        Adds an external reference.
        Parameters:
        fromAddr - from address (source of the reference)
        opIndex - operand index
        location - external location
        source - the source of this reference
        type - reference type - how the location is being referenced
        Returns:
        external reference
        Throws:
        InvalidInputException
      • removeAllReferencesFrom

        void removeAllReferencesFrom​(Address beginAddr,
                                     Address endAddr)
        Removes all references where "From address" is in the given range.
        Parameters:
        beginAddr - the first address in the range.
        endAddr - the last address in the range.
      • removeAllReferencesFrom

        void removeAllReferencesFrom​(Address fromAddr)
        Remove all stack, external, and memory references for the given from address.
        Parameters:
        fromAddr - the address of the codeunit from which to remove all references.
      • getReferencesTo

        Reference[] getReferencesTo​(Variable var)
        Returns all references to the given variable. Only data references to storage are considered.
        Parameters:
        var - variable to retrieve references to
        Returns:
        array of variable references, or zero length array if no references exist
      • getReferencedVariable

        Variable getReferencedVariable​(Reference reference)
        Returns the referenced function variable.
        Parameters:
        reference -
        Returns:
        function variable or null if variable not found
      • setPrimary

        void setPrimary​(Reference ref,
                        boolean isPrimary)
        Set the given reference's primary attribute
        Parameters:
        ref - the reference to make primary.
        isPrimary - true to make the reference primary, false to make it non-primary
      • hasFlowReferencesFrom

        boolean hasFlowReferencesFrom​(Address addr)
        Return whether the given address has flow references from this address.
        Parameters:
        addr - the address to test for flow references.
      • getFlowReferencesFrom

        Reference[] getFlowReferencesFrom​(Address addr)
        Get the flow references from the given address.
        Parameters:
        addr - the address of the codeunit to get all flows from.
      • getExternalReferences

        ReferenceIterator getExternalReferences()
        Returns an iterator over all external references
      • getReferencesTo

        ReferenceIterator getReferencesTo​(Address addr)
        Get an iterator over all references that have the given address as their "To" address.
        Parameters:
        addr - the address that all references in the iterator refer to.
      • getReferenceIterator

        ReferenceIterator getReferenceIterator​(Address startAddr)
        Get an iterator over references starting with the specified fromAddr. A forward iterator is returned with references sorted on the from address.
        Parameters:
        startAddr - the first from address to consider.
        Returns:
        a forward memory reference iterator.
      • getReference

        Reference getReference​(Address fromAddr,
                               Address toAddr,
                               int opIndex)
        Get the reference that has the given from and to address, and operand index.
        Parameters:
        fromAddr - the address of the codeunit making the reference.
        toAddr - the address being referred to.
        opIndex - the operand index.
      • getReferencesFrom

        Reference[] getReferencesFrom​(Address addr)
        Get all references "from" the specified addr.
        Parameters:
        addr - address of code-unit making the references.
        Returns:
        array of all references "from" the specified addr.
      • getReferencesFrom

        Reference[] getReferencesFrom​(Address fromAddr,
                                      int opIndex)
        Returns all references "from" the given fromAddr and operand (specified by opIndex).
        Parameters:
        fromAddr - the from which to get references
        opIndex - the operand from which to get references
        Returns:
        all references "from" the given fromAddr and operand.
      • hasReferencesFrom

        boolean hasReferencesFrom​(Address fromAddr,
                                  int opIndex)
        Returns true if there are any memory references at the given address/opIndex. Keep in mind this is a rather inefficient method as it must examine all references from the specified fromAddr.
        Parameters:
        fromAddr - the address of the codeunit being tested
        opIndex - the index of the operand being tested.
      • hasReferencesFrom

        boolean hasReferencesFrom​(Address fromAddr)
        Returns true if there are any memory references at the given address.
        Parameters:
        fromAddr - the address of the codeunit being tested
      • getPrimaryReferenceFrom

        Reference getPrimaryReferenceFrom​(Address addr,
                                          int opIndex)
        Get the primary reference from the given address.
        Parameters:
        addr - from address
        opIndex - operand index
      • getReferenceSourceIterator

        AddressIterator getReferenceSourceIterator​(Address startAddr,
                                                   boolean forward)
        Returns an iterator over addresses that are the "From" address in a reference
        Parameters:
        startAddr - address to position iterator.
        forward - true means to iterate in the forward direction
      • getReferenceSourceIterator

        AddressIterator getReferenceSourceIterator​(AddressSetView addrSet,
                                                   boolean forward)
        Returns an iterator over all addresses that are the "From" address in a reference, restricted by the given address set.
        Parameters:
        addrSet - the set of address to restrict the iterator.
        forward - true means to iterate in the forward direction
      • getReferenceDestinationIterator

        AddressIterator getReferenceDestinationIterator​(Address startAddr,
                                                        boolean forward)
        Returns an iterator over all addresses that are the "To" address in a reference.
        Parameters:
        startAddr - start of iterator
        forward - true means to iterate in the forward direction
      • getReferenceDestinationIterator

        AddressIterator getReferenceDestinationIterator​(AddressSetView addrSet,
                                                        boolean forward)
        Returns an iterator over all addresses that are the "To" address in a memory reference, restricted by the given address set.
        Parameters:
        addrSet - the set of address to restrict the iterator.
        forward - true means to iterate in the forward direction
      • getReferenceCountTo

        int getReferenceCountTo​(Address toAddr)
        Returns the number of memory References to the specified toAddr
        Parameters:
        toAddr - the address being referenced
      • getReferenceCountFrom

        int getReferenceCountFrom​(Address fromAddr)
        Returns the number of memory References from the specified fromAddr
        Parameters:
        fromAddr - the address of the codeunit making the reference.
      • getReferenceDestinationCount

        int getReferenceDestinationCount()
        Return the number of references for "to" addresses.
      • getReferenceSourceCount

        int getReferenceSourceCount()
        Return the number of references for "from" addresses.
      • hasReferencesTo

        boolean hasReferencesTo​(Address toAddr)
        Return true if a memory reference exists with the given "to" address.
        Parameters:
        toAddr - address being refered to.
      • updateRefType

        Reference updateRefType​(Reference ref,
                                RefType refType)
        Uodate the reference type on a memory reference.
        Parameters:
        ref - reference to be updated
        refType - new reference type
      • setAssociation

        void setAssociation​(Symbol s,
                            Reference ref)
        Associates the given reference with the given symbol.
        Parameters:
        s - the symbol to associate with the given reference.
        ref - the reference to associate with the given symbol
        Throws:
        java.lang.IllegalArgumentException - If the given reference does not already exist or its "To" address is not the same as the symbol's address.
      • removeAssociation

        void removeAssociation​(Reference ref)
        Removes any symbol associations with the given reference.
        Parameters:
        ref - the reference for which any symbol association is to be removed.
        Throws:
        java.lang.IllegalArgumentException - if the given references does not exist.
      • delete

        void delete​(Reference ref)
        Deletes the given reference object
        Parameters:
        ref - the reference to be deleted.
      • getReferenceLevel

        byte getReferenceLevel​(Address toAddr)
        Returns the reference level for the references to the given address
        Parameters:
        toAddr - the address at which to find the highest reference level