All Known Subinterfaces:
ICArrayElement, ICAssignment, ICBlock, ICBreak, ICCall, ICClass, ICCompound, ICConditionalStatement, ICConstant<T>, ICConstantFloat<T>, ICConstantFloat32, ICConstantFloat64, ICConstantInteger<T>, ICConstantInteger32, ICConstantInteger64, ICConstantIntegerLarge, ICConstantPointer, ICConstantString, ICContinue, ICControlBreaker, ICCustomStatement, ICDecl, ICDecompilableElement, ICDoWhileStm, ICExpression, ICField, ICForStm, ICGenericBreakable, ICGenericLoop, ICGenericWhileLoop, ICGoto, ICIdentifier, ICIfStm, ICInstanceField, ICJumpFar, ICLabel, ICLeftExpression, ICMethod, ICOperation, ICPredicate, ICReturn, ICSource, ICSourceElement, ICStatement, ICSwitchStm, ICTerminalStatement, ICThrow, ICTuple, ICType, ICWhileStm

@Ser public interface ICElement
Top-level interface for all elements of a C Abstract Syntax Tree.

Each AST element implements this interface or one of the sub-interfaces.

  • Method Details

    • getSubElements

      List<ICElement> getSubElements()
      Get the list of AST elements that constitute this AST element. Typically, for simple statements, it may be expression. For complex expressions, it may be simpler expressions. For compound statements, it may more statements and expressions. Etc.

      Be careful to manage properly possible infinite loops (in particular on recursive calls, when sub element may be the current method). Use CUtil.isClassMethodField(ICElement) to avoid infinite recursing or visitDepthPost(ICVisitor) methods.

      Returns:
      the list of constituting elements, may be empty but never null
    • replaceSubElement

      boolean replaceSubElement(ICElement oldElement, ICElement newElement)
      Replace one element by another one. Only the references are compared, no equals/deep compare. At most one element is replaced.
      Parameters:
      oldElement - the element to be replaced
      newElement - the new element
      Returns:
    • getPhysicalOffset

      Long getPhysicalOffset()
      Get the closest physical offset or address that matches this high-level pseudo-code element.
      Returns:
      an offset/address, null if none
    • getPhysicalOffsets

      Collection<Long> getPhysicalOffsets()
      Get the physical offsets of instructions matching this AST element.
      Returns:
    • setPhysicalOffsets

      void setPhysicalOffsets(Collection<Long> offsets)
      Parameters:
      offsets -
    • addPhysicalOffset

      void addPhysicalOffset(Long offset)
      Parameters:
      offset -
    • addPhysicalOffsets

      void addPhysicalOffsets(Collection<Long> offsets)
      Parameters:
      offsets -
    • generate

      void generate(COutputSink out)
      Generate the visual representation of the AST element. The output is directed into a sink, that represents the current output state for the whole AST. Every AST statement must implement this method.
      Parameters:
      out - where the AST element should be generated; the sink also contains attributes indicating how the element should be generated.
    • getElementType

      CElementType getElementType()
      This convenience method returns the type of C AST element held by this object.
      Returns:
    • toString

      String toString()
      Generate a short-form text version of this element.
      Overrides:
      toString in class Object
      Returns:
    • format

      String format()
      Generate a full-form text version of this element.
      Returns:
    • duplicate

      ICElement duplicate()
      Deep duplication of the element. Sub-elements are duplicated.

      Note: ICClass, ICMethod, ICField, ICIdentifier, ICConstant, ICType and ICLabel are not duplicated.

    • visitDepthPost

      boolean visitDepthPost(ICVisitor visitor)
      Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.

      This method disregards the IVisitResults.FLAG_SKIP_ASSIGN_DST flag.

      Parameters:
      visitor - the visitor object
      Returns:
      true if the visit was successful
    • visitDepthPost

      boolean visitDepthPost(ICVisitor visitor, ICElement parent)
      Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.

      This method disregards the IVisitResults.FLAG_SKIP_ASSIGN_DST flag.

      Parameters:
      visitor - the visitor object
      parent -
      Returns:
      true if the visit was successful
    • visitDepthPost

      boolean visitDepthPost(ICVisitor visitor, ICElement parent, CVisitResults results)
      Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.

      This method disregards the IVisitResults.FLAG_SKIP_ASSIGN_DST flag.

      Parameters:
      visitor - the visitor object
      parent -
      results -
      Returns:
      true if the visit was successful
    • visitDepthPre

      boolean visitDepthPre(ICVisitor visitor)
      Depth-first search, pre-order visit of an expression tree or sub-tree. The node being visited may be replaced, but the client code is responsible for notifying the visitor.

      This method disregards the IVisitResults.FLAG_SKIP_ASSIGN_DST flag.

      Parameters:
      visitor - the visitor object
      Returns:
      true if the visit was successful
    • visitDepthPre

      boolean visitDepthPre(ICVisitor visitor, ICElement parent)
      Depth-first search, pre-order visit of an expression tree or sub-tree. The node being visited may be replaced, but the client code is responsible for notifying the visitor.

      This method disregards the IVisitResults.FLAG_SKIP_ASSIGN_DST flag.

      Parameters:
      visitor - the visitor object
      parent -
      Returns:
      true if the visit was successful
    • visitDepthPre

      boolean visitDepthPre(ICVisitor visitor, ICElement parent, CVisitResults results)
      Depth-first search, pre-order visit of an expression tree or sub-tree. The node being visited may be replaced, but the client code is responsible for notifying the visitor.

      This method disregards the IVisitResults.FLAG_SKIP_ASSIGN_DST flag.

      Parameters:
      visitor - the visitor object
      parent -
      results -
      Returns:
      true if the visit was successful
    • evaluate

      Long evaluate(CMethodState state, CEnvironment environment)
      Parameters:
      state - input state, can be updated
      environment -
      Returns:
      evaluation result if any, can be null
    • setData

      void setData(String key, Object value)
      Attach a piece of data to this AST element.
      Parameters:
      key -
      value -
    • getData

      Object getData(Object key)
      Retrieve a piece of data attached to this AST element.
      Parameters:
      key -
      Returns: