Class AssemblyConstructorSemantic
- java.lang.Object
- 
- ghidra.app.plugin.assembler.sleigh.sem.AssemblyConstructorSemantic
 
- 
- All Implemented Interfaces:
- java.lang.Comparable<AssemblyConstructorSemantic>
 
 public class AssemblyConstructorSemantic extends java.lang.Object implements java.lang.Comparable<AssemblyConstructorSemantic> Describes a SLEIGH constructor semantic These are collected and associated with productions in the grammar based on the given constructor's print pieces.
- 
- 
Field SummaryFields Modifier and Type Field Description protected Constructorconsprotected static DbgTimerdbgprotected com.google.common.collect.ImmutableList<java.lang.Integer>indicesprotected java.util.Set<AssemblyResolvedConstructor>patternsprotected static RecursiveDescentSolversolverprotected com.google.common.collect.ImmutableSet<AssemblyResolvedConstructor>upatterns
 - 
Constructor SummaryConstructors Constructor Description AssemblyConstructorSemantic(Constructor cons, java.util.List<java.lang.Integer> indices)Build a new SLEIGH constructor semantic
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPattern(AssemblyResolvedConstructor pat)voidaddPattern(DisjointPattern pat)AssemblyResolvedConstructorapplyForward(AssemblyResolvedConstructor outer)Apply just context transformations in the forward (disassembly) directionintcompareTo(AssemblyConstructorSemantic that)protected voidcomputeAllForbids()Initialize upatterns with an unmodifiable copy of patterns, with forbidden patterns addedConstructorgetConstructor()Get the SLEIGH constructorintgetOperandIndex(int printpos)Convert the index of a print piece to its associated operand indexjava.util.Iterator<java.lang.Integer>getOperandIndexIterator()Get an iterator over the operand indices If this iterator is advanced for each non-terminal, while simultaneously iterating over the RHS of the associated production, then this will identify the corresponding operand index for each non-terminalcom.google.common.collect.ImmutableList<java.lang.Integer>getOperandIndices()Get the list of operand indices in print piece orderjava.util.Collection<AssemblyResolvedConstructor>getPatterns()Get the associated encoding patterns for the constructorAssemblyResolutionsolveContextChanges(AssemblyResolvedConstructor res, java.util.Map<java.lang.String,java.lang.Long> vals, java.util.Map<java.lang.Integer,java.lang.Object> opvals)Solve this constructor's context changesjava.lang.StringtoString()protected AssemblyResolvedConstructorwithComputedForbids(AssemblyResolvedConstructor pat)Add the list of forbidden patterns to one of the constructor's patterns SLEIGH disambiguates multiple matching pattern by two rules.
 
- 
- 
- 
Field Detail- 
solverprotected static final RecursiveDescentSolver solver 
 - 
dbgprotected static final DbgTimer dbg 
 - 
patternsprotected final java.util.Set<AssemblyResolvedConstructor> patterns 
 - 
consprotected final Constructor cons 
 - 
indicesprotected final com.google.common.collect.ImmutableList<java.lang.Integer> indices 
 - 
upatternsprotected com.google.common.collect.ImmutableSet<AssemblyResolvedConstructor> upatterns 
 
- 
 - 
Constructor Detail- 
AssemblyConstructorSemanticpublic AssemblyConstructorSemantic(Constructor cons, java.util.List<java.lang.Integer> indices) Build a new SLEIGH constructor semantic- Parameters:
- pattern- the encoding pattern associated with the constructor
- cons- the SLEIGH constructor
- indices- the indices of RHS non-terminals in the associated production that represent an operand in the SLEIGH constructor
 
 
- 
 - 
Method Detail- 
addPatternpublic void addPattern(DisjointPattern pat) 
 - 
addPatternpublic void addPattern(AssemblyResolvedConstructor pat) 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
getConstructorpublic Constructor getConstructor() Get the SLEIGH constructor- Returns:
- the constructor
 
 - 
getPatternspublic java.util.Collection<AssemblyResolvedConstructor> getPatterns() Get the associated encoding patterns for the constructor- Returns:
- the patterns
 
 - 
getOperandIndexpublic int getOperandIndex(int printpos) Convert the index of a print piece to its associated operand index- Parameters:
- printpos- position excluding whitespace and string tokens.
- Returns:
- the operand index
 
 - 
getOperandIndicespublic com.google.common.collect.ImmutableList<java.lang.Integer> getOperandIndices() Get the list of operand indices in print piece order- Returns:
- the list
 
 - 
getOperandIndexIteratorpublic java.util.Iterator<java.lang.Integer> getOperandIndexIterator() Get an iterator over the operand indices If this iterator is advanced for each non-terminal, while simultaneously iterating over the RHS of the associated production, then this will identify the corresponding operand index for each non-terminal- Returns:
- the iterator
 
 - 
computeAllForbidsprotected void computeAllForbids() Initialize upatterns with an unmodifiable copy of patterns, with forbidden patterns added
 - 
withComputedForbidsprotected AssemblyResolvedConstructor withComputedForbids(AssemblyResolvedConstructor pat) Add the list of forbidden patterns to one of the constructor's patterns SLEIGH disambiguates multiple matching pattern by two rules. First, if one is more specific than ("specializes") another, i.e., it matches on more bits than another pattern, the more specific pattern is chosen. Second, if the two are equally special, then the one that occurs first in the SLEIGH specification is taken. So, during resolution, if a less-special or later-occurring constructor is chosen, we must prevent continued resolution from matching the more-special or earlier-occurring pattern(s). Essentially, this states, "you may choose any value matching my pattern, except those that match these forbidden patterns." This takes a given pattern, and searches the rest of the language for any patterns that would take precedence, and combines them as forbidden patterns with the given pattern.- Parameters:
- pat2- the given pattern
 
 - 
solveContextChangespublic AssemblyResolution solveContextChanges(AssemblyResolvedConstructor res, java.util.Map<java.lang.String,java.lang.Long> vals, java.util.Map<java.lang.Integer,java.lang.Object> opvals) Solve this constructor's context changes- Parameters:
- res- the combined resolution requirements derived from the subconstructors
- vals- any defined symbols (usually- inst_start, and- inst_next)
- opvals- a map from operand index to operand value
- Returns:
- the resolution with context changes applied in reverse, or an error
 
 Each value in opvalsmust either be a numeric value, e.g., an index from a varnode list, or anotherAssemblyResolvedConstructorfor a subconstructor operand. It's helpful to think of the SLEIGH disassembly process here. Normally, once the appropriate constructor has been identified (by matching patterns), its context changes are applied, and then its operands parsed (possibly parsing subconstructor operands). Thus,rescan be thought of as the intermediate result between applying context changes and parsing operands, except in reverse. The output of this method corresponds to the state before context changes were applied, i.e., immediately after selecting the constructor. Thus, in reverse, the context is solved immediately before applying the selected constructor patterns.
- See Also:
- AssemblyTreeResolver#resolveSelectedChildren(AssemblyProduction, List, List, Collection)
 
 - 
applyForwardpublic AssemblyResolvedConstructor applyForward(AssemblyResolvedConstructor outer) Apply just context transformations in the forward (disassembly) direction- Parameters:
- outer- the state before context changes
- Returns:
- the state after context changes
 
 Unlike the usual disassembly process, this method does not take into account any information
 from the instruction encoding. Any context bits that depend on it are set to unknown
 (x) in the output. This method is used to pre-compute a context transition graph in order to quickly resolve purely-recursive semantics on the root constructor table.
 
 - 
compareTopublic int compareTo(AssemblyConstructorSemantic that) - Specified by:
- compareToin interface- java.lang.Comparable<AssemblyConstructorSemantic>
 
 
- 
 
-