Interface ICElement
- 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
Each AST element implements this interface or one of the sub-interfaces.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPhysicalOffset(Long offset) voidaddPhysicalOffsets(Collection<Long> offsets) Deep duplication of the element.evaluate(CMethodState state, CEnvironment environment) format()Generate a full-form text version of this element.voidgenerate(COutputSink out) Generate the visual representation of the AST element.Retrieve a piece of data attached to this AST element.This convenience method returns the type of C AST element held by this object.Get the closest physical offset or address that matches this high-level pseudo-code element.Get the physical offsets of instructions matching this AST element.Get the list of AST elements that constitute this AST element.booleanreplaceSubElement(ICElement oldElement, ICElement newElement) Replace one element by another one.voidAttach a piece of data to this AST element.voidsetPhysicalOffsets(Collection<Long> offsets) toString()Generate a short-form text version of this element.booleanvisitDepthPost(ICVisitor visitor) Depth-first search, post-order visit of an expression tree or sub-tree.booleanvisitDepthPost(ICVisitor visitor, ICElement parent) Depth-first search, post-order visit of an expression tree or sub-tree.booleanvisitDepthPost(ICVisitor visitor, ICElement parent, CVisitResults results) Depth-first search, post-order visit of an expression tree or sub-tree.booleanvisitDepthPre(ICVisitor visitor) Depth-first search, pre-order visit of an expression tree or sub-tree.booleanvisitDepthPre(ICVisitor visitor, ICElement parent) Depth-first search, pre-order visit of an expression tree or sub-tree.booleanvisitDepthPre(ICVisitor visitor, ICElement parent, CVisitResults results) Depth-first search, pre-order visit of an expression tree or sub-tree.
-
Method Details
-
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 orvisitDepthPost(ICVisitor)methods.- Returns:
- the list of constituting elements, may be empty but never null
-
replaceSubElement
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 replacednewElement- 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
- Parameters:
offsets-
-
addPhysicalOffset
- Parameters:
offset-
-
addPhysicalOffsets
- Parameters:
offsets-
-
generate
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. -
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,ICTypeandICLabelare not duplicated. -
visitDepthPost
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_DSTflag.- Parameters:
visitor- the visitor object- Returns:
- true if the visit was successful
-
visitDepthPost
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_DSTflag.- Parameters:
visitor- the visitor objectparent-- Returns:
- true if the visit was successful
-
visitDepthPost
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_DSTflag.- Parameters:
visitor- the visitor objectparent-results-- Returns:
- true if the visit was successful
-
visitDepthPre
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_DSTflag.- Parameters:
visitor- the visitor object- Returns:
- true if the visit was successful
-
visitDepthPre
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_DSTflag.- Parameters:
visitor- the visitor objectparent-- Returns:
- true if the visit was successful
-
visitDepthPre
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_DSTflag.- Parameters:
visitor- the visitor objectparent-results-- Returns:
- true if the visit was successful
-
evaluate
- Parameters:
state- input state, can be updatedenvironment-- Returns:
- evaluation result if any, can be null
-
setData
Attach a piece of data to this AST element.- Parameters:
key-value-
-
getData
Retrieve a piece of data attached to this AST element.- Parameters:
key-- Returns:
-