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
FieldsModifier and TypeFieldDescriptionprotected Map<String, AssemblySymbol> protected AssemblyContextGraphprotected static final DbgTimerprotected AssemblyDefaultContextprotected final AbstractAssemblyResolutionFactory<RP, ?> protected booleanprotected AssemblyGrammarprotected final SleighLanguageprotected AssemblyParser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddProduction(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 voidBuild the default context for the languageprotected voidBuild the context transition graph for the languageprotected voidBuild the full grammar for the languageprotected voidBuild the parser for the languageprotected AssemblyGrammarbuildSubGrammar(SubtableSymbol subtable) Build a portion of the grammar representing a table of constructorsprotected voidDo 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 AssemblyGrammarGet the built grammar for the languageprotected HandleTplgetHandleTpl(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 AssemblyParserGet the built parser for the languageprotected AssemblySymbolgetSymbolFor(Constructor cons, OperandSymbol opsym) Convert the given operand symbol to anAssemblySymbolInvert a name table to a map suitable for use withAssemblyStringMapTerminalInvert a value map to a map suitable for use withAssemblyNumericMapTerminalinvVarnodeList(VarnodeListSymbol vnlist) Invert a varnode list to a map suitable for use withAssemblyStringMapTerminalprotected abstract AnewAssembler(AssemblySelector selector) protected abstract AnewAssembler(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:GenericAssemblerBuilderGet the ID of the language for which this instance builds an assembler- Specified by:
getLanguageIDin interfaceGenericAssemblerBuilder<RP extends AssemblyResolvedPatterns,A extends GenericAssembler<RP>> - Returns:
- the language ID
-
getLanguage
Description copied from interface:GenericAssemblerBuilderGet the language for which this instance builds an assembler- Specified by:
getLanguagein 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:GenericAssemblerBuilderBuild an assembler with the given selector callback- Specified by:
getAssemblerin interfaceGenericAssemblerBuilder<RP extends AssemblyResolvedPatterns,A extends GenericAssembler<RP>> - Parameters:
selector- the selector callback- Returns:
- the built assembler
-
getAssembler
Description copied from interface:GenericAssemblerBuilderBuild an assembler with the given selector callback and program binding- Specified by:
getAssemblerin 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 anAssemblySymbolFor 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
-