gtirb.symbol module

gtirb.symbol.Payload

A type hint representing the possible Symbol payloads.

alias of Union[Block, int]

class gtirb.symbol.Symbol(name, uuid=None, payload=None, at_end=False, module=None)[source]

Bases: Node

Represents a symbol, which maps a name to an object in the IR.

Variables:
  • ~.name – The name of this symbol.

  • ~.at_end – True if this symbol is at the end of its referent, rather than at the beginning. Has no meaning for integral symbols.

__init__(name, uuid=None, payload=None, at_end=False, module=None)[source]
Parameters:
  • name (str) – The name of this symbol.

  • uuid (typing.Optional[uuid.UUID]) – The UUID of this Symbol, or None if a new UUID needs generated via uuid.uuid4(). Defaults to None.

  • payload (typing.Union[gtirb.block.Block, int, None]) – The value this symbol points to. May be an address, a Node, or None.

  • at_end (bool) – True if this symbol is at the end of its referent, rather than at the beginning.

  • module (typing.Optional[gtirb.module.Module]) – The Module this symbol belongs to.

deep_eq(other)[source]

Check: is self structurally equal to other?

This method should be used only when deep structural equality checks are actually needed, and not for all equality checks. Typically the default implmentation of __eq__, which checks pointer equality, is sufficient; Nodes are cached such that references to two Nodes with the same UUID refer to the same exact object. Use this method when you have manually constructed Nodes that may share the same UUID despite being different objects, and you need to check for structural equality.

Return type:

bool

property ir: IR | None

Get the IR this node ultimately belongs to.

property module: Module | None
name

A descriptor that will notify a parent when the value is set and can be otherwise used like a normal attribute.

property referent: Block | None

The object referred to by a Symbol, which is Block or None. value and referent are mutually exclusive.

property value: int | None

The value of a Symbol, which is an integer or None. value and referent are mutually exclusive.