java.lang.Object
com.pnfsoftware.jeb.core.units.code.android.ir.compiler.Leaf
All Implemented Interfaces:
INode

public class Leaf extends Object implements INode
IR template element.

A leaf node is never null. Examples: an immediate or variable (atomic leaf, aka 'Terminal leaf') or memory access (composed leaf, aka 'Non-terminal leaf').

  • Field Details

    • FLAG_POSSIBLE_IMM

      public static final int FLAG_POSSIBLE_IMM
      Leaf flag allowing immediate expressions.
      See Also:
    • FLAG_POSSIBLE_VAR

      public static final int FLAG_POSSIBLE_VAR
      Leaf flag allowing variable expressions.
      See Also:
    • FLAG_POSSIBLE_NON_TERMINAL

      public static final int FLAG_POSSIBLE_NON_TERMINAL
      Leaf flag allowing non-terminal expressions.
      See Also:
    • FLAG_POSSIBLE_TERMINAL

      public static final int FLAG_POSSIBLE_TERMINAL
      Leaf flag allowing terminal expressions.
      See Also:
    • FLAG_POSSIBLE_ALL

      public static final int FLAG_POSSIBLE_ALL
      Leaf flag allowing any expression.
      See Also:
    • id

      public int id
      internal id assigned to this leaf; must be >= 0
    • optionalBitsize

      public int optionalBitsize
      optional requested size of the leaf; leave to 0 for any size.
    • flags

      public int flags
      type of allowed leaf; must be set, because the default value (0) means none
    • handler

      public INodeHandler handler
      optional custom handler used after a leaf was matched
    • value

      public Long value
      for Leaf representing IDImm.
  • Constructor Details

    • Leaf

      public Leaf(int id, int bitsize, int flags, INodeHandler handler)
      Create a wildcard leaf. Can be a terminal (e.g. imm or var) or non-terminal (e.g., complex expression).

      Gotcha: When using FLAG_LASTBIT_IMM, the id refers to the target expression to be examined.

      Parameters:
      id - a value in [0,1000[
      bitsize - optional bitsize
      flags - see FLAG_xxx
      handler - custom optional handler to do custom processing (custom checks) on a matched node
    • Leaf

      public Leaf(int id, int bitsize, int flags)
      Create a wildcard leaf. Can be a terminal (eg, EVar, EImm) or non-terminal (eg, complex expression).
      Parameters:
      id - a value in [0,1000[
      bitsize - optional bitsize
      flags - see FLAG_xxx
    • Leaf

      public Leaf(long value, int bitsize, int id)
      Create a fixed, pre-determined immediate constant leaf.
      Parameters:
      value - mandatory immediate value
      bitsize - optional, use 0 if unknown
      id - optional, use -1 if not needed, else an id in the [0,1000[ range; use if the leaf needs to be used in a subsequent substitution step
  • Method Details

    • setHandler

      public Leaf setHandler(INodeHandler h)
      Set the optional custom handler.
      Parameters:
      h - custom handler
      Returns:
      this leaf
    • toString

      public String toString()
      Overrides:
      toString in class Object