Class CodeUtil

java.lang.Object
com.pnfsoftware.jeb.core.units.code.CodeUtil

public class CodeUtil extends Object
Utility routines for code units.
  • Method Details

    • findCodeItemReference

      public static String findCodeItemReference(ICodeUnit unit, ICodeItem item, int pos)
      Find a reference to a code item.
      Parameters:
      unit - code unit
      item - code item
      pos - reference index
      Returns:
      reference address, or null
    • getMethodByName

      public static ICodeMethod getMethodByName(ICodeUnit unit, String partialName, boolean failIfAmbiguous)
      Get a method/routine by name.
      Parameters:
      unit - code unit
      partialName - full or partial method name
      failIfAmbiguous - true to fail on ambiguous partial matches
      Returns:
      matching method, or null
    • getFieldByName

      public static ICodeField getFieldByName(ICodeUnit unit, String partialName, boolean failIfAmbiguous)
      Get a field by name.
      Parameters:
      unit - code unit
      partialName - full or partial field name
      failIfAmbiguous - true to fail on ambiguous partial matches
      Returns:
      matching field, or null
    • collectClasses

      @Deprecated public static List<ICodeClass> collectClasses(ICodeUnit unit, boolean internal, boolean topLevel, Pattern addressFilter)
      Deprecated.
      Kept for legacy
      Collect classes.
      Parameters:
      unit - code unit
      internal - true to collect internal classes only
      topLevel - true to collect non-inner classes only
      addressFilter - optional address filter
      Returns:
      collected classes
    • collectClasses

      public static List<ICodeClass> collectClasses(ICodeUnit unit, boolean internal, boolean topLevel, Pattern addressFilter, boolean fullMatch)
      Collect classes.
      Parameters:
      unit - ICodeUnit containing classes (see ICodeUnit.getClasses()
      internal - true to collect internal classes only
      topLevel - true to collect non-inner classes only
      addressFilter - optional filter on ICodeItem.getAddress()
      fullMatch - true if pattern must match the entire addresses. false if we only intend a search into the address.
      Returns:
      collected classes
    • collectMethods

      @Deprecated public static List<ICodeMethod> collectMethods(ICodeUnit unit, boolean internal, boolean topLevel, Pattern addressFilter)
      Deprecated.
      Kept for legacy
      Collect methods.
      Parameters:
      unit - code unit
      internal - true to collect internal methods only
      topLevel - true to collect orphaned methods only
      addressFilter - optional address filter
      Returns:
      collected methods
    • collectMethods

      public static List<ICodeMethod> collectMethods(ICodeUnit unit, boolean internal, boolean topLevel, Pattern addressFilter, boolean fullMatch)
      Collect methods.
      Parameters:
      unit - ICodeUnit containing methods (see ICodeUnit.getMethods()
      internal - true to collect internal methods only
      topLevel - true to collect orphaned methods only (not belonging to any class)
      addressFilter - optional filter on ICodeItem.getAddress()
      fullMatch - true if pattern must match the entire addresses. false if we only intend a search into the address.
      Returns:
      collected methods
    • createCallgraphBuilder

      public static IAddressableDigraphBuilder createCallgraphBuilder(ICodeUnit unit)
      Create a call graph builder for a code unit.
      Parameters:
      unit - code unit
      Returns:
      call graph builder, or null