Class AbstractSleighAssemblerBuilder<RP extends AssemblyResolvedPatterns,A extends GenericAssembler<RP>>
java.lang.Object
ghidra.app.plugin.assembler.sleigh.AbstractSleighAssemblerBuilder<RP,A>
- All Implemented Interfaces:
GenericAssemblerBuilder<RP,
A>
- Direct Known Subclasses:
SleighAssemblerBuilder
public abstract class AbstractSleighAssemblerBuilder<RP extends AssemblyResolvedPatterns,A extends GenericAssembler<RP>>
extends Object
implements GenericAssemblerBuilder<RP,A>
-
Field Summary
Modifier and TypeFieldDescriptionprotected Map
<String, AssemblySymbol> protected AssemblyContextGraph
protected static final DbgTimer
protected AssemblyDefaultContext
protected final AbstractAssemblyResolutionFactory
<RP, ?> protected boolean
protected AssemblyGrammar
protected final SleighLanguage
protected AssemblyParser
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addProduction
(AssemblyGrammar subgrammar, AssemblyNonTerminal lhs, AssemblySentential<AssemblyNonTerminal> rhs, DisjointPattern pattern, Constructor cons, List<Integer> indices) Extension point: Allows a chance to modify or derive a new production from a given one.protected void
Build the default context for the languageprotected void
Build the context transition graph for the languageprotected void
Build the full grammar for the languageprotected void
Build the parser for the languageprotected AssemblyGrammar
buildSubGrammar
(SubtableSymbol subtable) Build a portion of the grammar representing a table of constructorsprotected void
Do the actual work to construct an assembler from a SLEIGH languagegetAssembler
(AssemblySelector selector) Build an assembler with the given selector callbackgetAssembler
(AssemblySelector selector, Program program) Build an assembler with the given selector callback and program bindingprotected AssemblyGrammar
Get the built grammar for the languageprotected HandleTpl
getHandleTpl
(Constructor cons, OperandSymbol opsym) Obtain the p-code result handle for the given operandGet the language for which this instance builds an assemblerGet the ID of the language for which this instance builds an assemblerprotected AssemblyParser
Get the built parser for the languageprotected AssemblySymbol
getSymbolFor
(Constructor cons, OperandSymbol opsym) Convert the given operand symbol to anAssemblySymbol
Invert a name table to a map suitable for use withAssemblyStringMapTerminal
Invert a value map to a map suitable for use withAssemblyNumericMapTerminal
invVarnodeList
(VarnodeListSymbol vnlist) Invert a varnode list to a map suitable for use withAssemblyStringMapTerminal
protected abstract A
newAssembler
(AssemblySelector selector) protected abstract A
newAssembler
(AssemblySelector selector, Program program) protected abstract AbstractAssemblyResolutionFactory
<RP, ?>
-
Field Details
-
dbg
-
lang
-
factory
-
grammar
-
defaultContext
-
ctxGraph
-
parser
-
generated
protected boolean generated -
builtSymbols
-
-
Constructor Details
-
AbstractSleighAssemblerBuilder
-
-
Method Details
-
newResolutionFactory
-
newAssembler
-
newAssembler
-
getLanguageID
Description copied from interface:GenericAssemblerBuilder
Get the ID of the language for which this instance builds an assembler- Specified by:
getLanguageID
in interfaceGenericAssemblerBuilder<RP extends AssemblyResolvedPatterns,
A extends GenericAssembler<RP>> - Returns:
- the language ID
-
getLanguage
Description copied from interface:GenericAssemblerBuilder
Get the language for which this instance builds an assembler- Specified by:
getLanguage
in interfaceGenericAssemblerBuilder<RP extends AssemblyResolvedPatterns,
A extends GenericAssembler<RP>> - Returns:
- the language
-
generateAssembler
Do the actual work to construct an assembler from a SLEIGH language- Throws:
SleighException
- if there's an issue accessing the language
-
getAssembler
Description copied from interface:GenericAssemblerBuilder
Build an assembler with the given selector callback- Specified by:
getAssembler
in interfaceGenericAssemblerBuilder<RP extends AssemblyResolvedPatterns,
A extends GenericAssembler<RP>> - Parameters:
selector
- the selector callback- Returns:
- the built assembler
-
getAssembler
Description copied from interface:GenericAssemblerBuilder
Build an assembler with the given selector callback and program binding- Specified by:
getAssembler
in interfaceGenericAssemblerBuilder<RP extends AssemblyResolvedPatterns,
A extends GenericAssembler<RP>> - Parameters:
selector
- the selector callbackprogram
- the bound program- Returns:
- the built assembler
-
invVarnodeList
protected org.apache.commons.collections4.MultiValuedMap<String,Integer> invVarnodeList(VarnodeListSymbol vnlist) Invert a varnode list to a map suitable for use withAssemblyStringMapTerminal
- Parameters:
vnlist
- the varnode list symbol- Returns:
- the inverted string map
-
invValueMap
Invert a value map to a map suitable for use withAssemblyNumericMapTerminal
- Parameters:
vm
- the value map symbol- Returns:
- the inverted numeric map
-
invNameSymbol
protected org.apache.commons.collections4.MultiValuedMap<String,Integer> invNameSymbol(NameSymbol ns) Invert a name table to a map suitable for use withAssemblyStringMapTerminal
- Parameters:
ns
- the name symbol- Returns:
- the inverted string map
-
getSymbolFor
Convert the given operand symbol to anAssemblySymbol
For subtables, this results in a non-terminal, for all others, the result in a terminal.
- Parameters:
cons
- the constructor to which the operand belongsopsym
- the operand symbol to convert- Returns:
- the converted assembly grammar symbol
-
getHandleTpl
Obtain the p-code result handle for the given operandThis handles a special case, where a constructor prints just one operand and exports that same operand, often with an explicit size, or as an address in a given space. In such cases, the listing displays that operand according to that exported size.
For assembly, this gives a few opportunities: 1) We can/must ensure the specified value fits, by checking the size. 2) We can/must mask the goal when solving the defining pattern expression for the operand. 3)) We can/must check that a label's address space matches that represented by the operand, when used for a numeric terminal.
- Parameters:
cons
- the constructor from which the production is being derivedopsym
- the operand symbol corresponding to the grammatical symbol, whose size we wish to determine.- Returns:
- the size of the operand in bits
-
buildSubGrammar
Build a portion of the grammar representing a table of constructors- Parameters:
subtable
- the table- Returns:
- the partial grammar
-
addProduction
protected void addProduction(AssemblyGrammar subgrammar, AssemblyNonTerminal lhs, AssemblySentential<AssemblyNonTerminal> rhs, DisjointPattern pattern, Constructor cons, List<Integer> indices) Extension point: Allows a chance to modify or derive a new production from a given one.- Parameters:
subgrammar
- the sub-grammar for the sub-table symbol being processed- See Also:
-
buildGrammar
protected void buildGrammar()Build the full grammar for the language -
buildContext
protected void buildContext()Build the default context for the language -
buildContextGraph
protected void buildContextGraph()Build the context transition graph for the language -
buildParser
protected void buildParser()Build the parser for the language -
getGrammar
Get the built grammar for the language- Returns:
- the grammar
-
getParser
Get the built parser for the language- Returns:
- the parser
-