stm8dce.asm_analysis API documentation
Description: This module provides classes and functions helpful for analyzing SDCC generated STM8 assembly code.

# Module `stm8dce.asm_analysis`

This module provides classes and functions helpful for analyzing SDCC generated STM8 assembly code.

## Functions

`def constant_by_filename_name(constants, filename, name)`

  Returns a constant object matching by filename and name from a list of constants.

  ## Args

  `constants` :`list`
    List of Constant objects.
  `filename` :`str`
    Filename to match.
  `name` :`str`
    Name of the constant to match.

  ## Returns

  `Constant`
    Matching Constant object.

  ## Raises

  `SystemExit`
    If multiple definitions for the constant are found.
`def constants_by_name(constants, name)`

  Returns a list of constant objects with the specified name.

  ## Args

  `constants` :`list`
    List of Constant objects.
  `name` :`str`
    Name of the constant to match.

  ## Returns

  `list`
    List of matching Constant objects.
`def function_by_filename_name(functions, filename, name)`

  Returns a function object matching by filename and name from a list of functions.

  ## Args

  `functions` :`list`
    List of Function objects.
  `filename` :`str`
    Filename to match.
  `name` :`str`
    Name of the function to match.

  ## Returns

  `Function`
    Matching Function object.

  ## Raises

  `SystemExit`
    If multiple definitions for the function are found.
`def functions_by_name(functions, name)`

  Returns a list of function objects with the specified name.

  ## Args

  `functions` :`list`
    List of Function objects.
  `name` :`str`
    Name of the function to match.

  ## Returns

  `list`
    List of matching Function objects.
`def functions_referencing_external(functions, external_symbol)`

  Returns a list of function objects referencing an external symbol.

  ## Args

  `functions` :`list`
    List of Function objects.
  `external_symbol` :`str`
    Name of the external symbol to match.

  ## Returns

  `list`
    List of matching Function objects.
`def interrupt_handlers(functions)`

  Returns a list of all interrupt handlers in the list of functions.

  ## Args

  `functions` :`list`
    List of Function objects.

  ## Returns

  `list`
    List of interrupt handler Function objects.
`def traverse_calls(functions, top)`

  Traverse all calls made by a function and return a list of all traversed functions.

  ## Args

  `functions` :`list`
    List of Function objects.
  `top` :`Function`
    The top function to start traversal from.

  ## Returns

  `list`
    List of all traversed Function objects.

## Classes

`class Constant`

  Class to store constant definitions.

  Input Attributes: path (str): Path of the file the constant is defined in. name (str): Name of the constant. start_line_number (int): Start line of the constant. end_line_number (int): End line of the constant.

  Generated Attributes: global_defs (list): List of resolved global definitions associated with the constant (See resolve_globals).

  The intended use of this class is to first parse the input attributes and then call the resolve_* functions

  ### Methods

  `def __init__(self, path, start_line_number, name)`

    Initialize self. See help(type(self)) for accurate signature.

  `def __repr__(self)`

    Return repr(self).

  `def __str__(self)`

    Return str(self).

  `def print(self)`

    Prints the details of the constant.

  `def resolve_globals(self, globals)`

    Resolves global definitions for the constant.

    ## Args

    `globals` :`list`
      List of all GlobalDef objects.
`class Function`

  Class to store function definitions.

  Input Attributes: path (str): Path of the file the function is defined in. name (str): Name of the function. start_line_number (int): Start line of the function. end_line_number (int): End line of the function. calls_str (list): List of calls made by the function. long_read_labels_str (list): List of long read labels.

  Generated Attributes: calls (list): List of resolved functions called by the function (See resolve_calls). constants (list): List of resolved constants read by the function (See resolve_constants). global_defs (list): List of resolved global definitions used by the function (See resolve_globals). fptrs (list): List of resolved function pointers assigned by the function (See resolve_fptrs). isr_def (IntDef): Resolved interrupt definition associated with the function (See resolve_isr). empty (bool): Indicates if the function is empty.

  The intended use of this class is to first parse the input attributes and then call the resolve_* functions to resolve the generated attributes.

  ### Methods

  `def __init__(self, path, start_line_number, name)`

    Initialize self. See help(type(self)) for accurate signature.

  `def __repr__(self)`

    Return repr(self).

  `def __str__(self)`

    Return str(self).

  `def print(self)`

    Prints the details of the function.

  `def resolve_calls(self, functions)`

    Resolves function calls for the function.

    Precondition: Globals of all functions have been resolved first.

    ## Args

    `functions` :`list`
      List of all Function objects.
  `def resolve_constants(self, constants)`

    Resolves constants for the function.

    ## Args

    `constants` :`list`
      List of all Constant objects.
  `def resolve_fptrs(self, functions)`

    Resolves function pointers assigned by the function.

    ## Args

    `functions` :`list`
      List of all Function objects.
  `def resolve_globals(self, globals)`

    Resolves global definitions for the function.

    ## Args

    `globals` :`list`
      List of all GlobalDef objects.
  `def resolve_isr(self, interrupts)`

    Resolves interrupt definitions for the function.

    ## Args

    `interrupts` :`list`
      List of all IntDef objects.
`class GlobalDef`

  Class to store global definitions.

  ## Attributes

  `path` :`str`
    Path of the file the global is defined in.
  `name` :`str`
    Name of the global.
  `line_number` :`int`
    Line number of the global definition.

  ### Methods

  `def __init__(self, path, line_number, name)`

    Initialize self. See help(type(self)) for accurate signature.

  `def __repr__(self)`

    Return repr(self).

  `def __str__(self)`

    Return str(self).

  `def print(self)`

    Prints the details of the global definition.

`class IntDef`

  Class to store interrupt definitions. Equivalent to GlobalDef, but prints differently.

  ## Attributes

  `path` :`str`
    Path of the file the interrupt is defined in.
  `name` :`str`
    Name of the interrupt.
  `line_number` :`int`
    Line number of the interrupt definition.

  ### Methods

  `def __init__(self, path, line_number, name)`

    Initialize self. See help(type(self)) for accurate signature.

  `def __repr__(self)`

    Return repr(self).

  `def __str__(self)`

    Return str(self).

  `def print(self)`

    Prints the details of the interrupt definition.