Package ghidra.program.model.lang
Class PcodeParser
java.lang.Object
ghidra.pcodeCPort.slgh_compile.PcodeCompile
ghidra.program.model.lang.PcodeParser
- Direct Known Subclasses:
SleighProgramCompiler.ErrorCollectingPcodeParser
public class PcodeParser
extends ghidra.pcodeCPort.slgh_compile.PcodeCompile
This class is intended to parse p-code snippets, typically from compiler specification files or
extensions. This is outside the normal SLEIGH compilation process, and the parser is built on top
of an existing SleighLanguage.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class wraps on existing SleighLanguage with the SleighBase interface expected by PcodeCompile. -
Field Summary
Fields inherited from class ghidra.pcodeCPort.slgh_compile.PcodeCompile
log, noplist -
Constructor Summary
ConstructorsModifierConstructorDescriptionPcodeParser(SleighLanguage language, long ubase) Build parser from an existing SleighLanguage.protectedPcodeParser(ghidra.pcodeCPort.sleighbase.SleighBase sleigh) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOperand(Location loc, String name, int index) Inject a symbol representing an "operand" to the pcode snippet.voidaddSymbol(ghidra.pcodeCPort.slghsymbol.SleighSymbol sym) longvoidcompilePcode(String pcodeStatements, String srcFile, int srcLine) Compile pcode semantic statements.VectorSTL<ghidra.pcodeCPort.semantics.OpTpl> createCrossBuild(Location where, ghidra.pcodeCPort.semantics.VarnodeTpl v, ghidra.pcodeCPort.slghsymbol.SectionSymbol second) VectorSTL<ghidra.pcodeCPort.semantics.OpTpl> createMacroUse(Location location, ghidra.pcodeCPort.slghsymbol.MacroSymbol sym, VectorSTL<ghidra.pcodeCPort.slgh_compile.ExprTree> param) ghidra.pcodeCPort.slgh_compile.SectionVectorfinalNamedSection(ghidra.pcodeCPort.slgh_compile.SectionVector vec, ghidra.pcodeCPort.semantics.ConstructTpl section) ghidra.pcodeCPort.slghsymbol.SleighSymbolfindSymbol(String nm) ghidra.pcodeCPort.slgh_compile.SectionVectorfirstNamedSection(ghidra.pcodeCPort.semantics.ConstructTpl main, ghidra.pcodeCPort.slghsymbol.SectionSymbol sym) ghidra.pcodeCPort.space.AddrSpaceghidra.pcodeCPort.space.AddrSpacelongghidra.pcodeCPort.sleighbase.SleighBaseghidra.pcodeCPort.space.AddrSpaceghidra.pcodeCPort.slghsymbol.SectionSymbolnewSectionSymbol(Location where, String text) ghidra.pcodeCPort.slgh_compile.SectionVectornextNamedSection(ghidra.pcodeCPort.slgh_compile.SectionVector vec, ghidra.pcodeCPort.semantics.ConstructTpl section, ghidra.pcodeCPort.slghsymbol.SectionSymbol sym) voidghidra.pcodeCPort.slgh_compile.SectionVectorstandaloneSection(ghidra.pcodeCPort.semantics.ConstructTpl main) translateConstructTpl(ghidra.pcodeCPort.semantics.ConstructTpl constructTpl) translateConstTpl(ghidra.pcodeCPort.semantics.ConstTpl constTpl) translateHandleTpl(ghidra.pcodeCPort.semantics.HandleTpl handleTpl) translateOpTpl(ghidra.pcodeCPort.semantics.OpTpl opTpl) translateVarnodeTpl(ghidra.pcodeCPort.semantics.VarnodeTpl varnodeTpl) Methods inherited from class ghidra.pcodeCPort.slgh_compile.PcodeCompile
addressOf, appendOp, assignBitRange, buildTemporary, buildTruncatedVarnode, createBitRange, createLoad, createOp, createOp, createOpConst, createOpNoOut, createOpNoOut, createOpOut, createOpOutUnary, createStore, createUserOp, createUserOpNoOut, createVariadic, defineLabel, entry, fillinZero, findInternalFunction, getErrors, getWarnings, isInternalFunction, matchSize, newLocalDefinition, newLocalDefinition, newOutput, newOutput, placeLabel, propagateSize, reportError, reportWarning, resetLabelCount, setEnforceLocalKey, setResultStarVarnode, setResultVarnode
-
Constructor Details
-
PcodeParser
protected PcodeParser(ghidra.pcodeCPort.sleighbase.SleighBase sleigh) -
PcodeParser
Build parser from an existing SleighLanguage.- Parameters:
language- is the existing languageubase- is the starting offset for allocating temporary registers
-
-
Method Details
-
addOperand
Inject a symbol representing an "operand" to the pcode snippet.This puts a placeholder in the resulting template, which gets filled in with the context specific storage locations when final p-code is generated
- Parameters:
loc- is location information for the operandname- of operand symbolindex- to use for the placeholder
-
addSymbol
public void addSymbol(ghidra.pcodeCPort.slghsymbol.SleighSymbol sym) - Specified by:
addSymbolin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
clearSymbols
public void clearSymbols() -
getNextTempOffset
public long getNextTempOffset() -
allocateTemp
public long allocateTemp()- Specified by:
allocateTempin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
createMacroUse
public VectorSTL<ghidra.pcodeCPort.semantics.OpTpl> createMacroUse(Location location, ghidra.pcodeCPort.slghsymbol.MacroSymbol sym, VectorSTL<ghidra.pcodeCPort.slgh_compile.ExprTree> param) - Specified by:
createMacroUsein classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
findSymbol
- Specified by:
findSymbolin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
getSleigh
public ghidra.pcodeCPort.sleighbase.SleighBase getSleigh() -
getConstantSpace
public ghidra.pcodeCPort.space.AddrSpace getConstantSpace()- Specified by:
getConstantSpacein classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
getDefaultSpace
public ghidra.pcodeCPort.space.AddrSpace getDefaultSpace()- Specified by:
getDefaultSpacein classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
getUniqueSpace
public ghidra.pcodeCPort.space.AddrSpace getUniqueSpace()- Specified by:
getUniqueSpacein classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
recordNop
- Specified by:
recordNopin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
translateConstructTpl
-
translateHandleTpl
-
translateOpTpl
-
translateVarnodeTpl
-
translateConstTpl
-
compilePcode
public ConstructTpl compilePcode(String pcodeStatements, String srcFile, int srcLine) throws SleighException Compile pcode semantic statements.- Parameters:
pcodeStatements- is the raw source to parsesrcFile- source filename from which pcodeStatements came (srcLine- line number in srcFile corresponding to pcodeStatements- Returns:
- ConstructTpl. A null may be returned or an exception thrown if parsing/compiling fails (see application log for errors).
- Throws:
SleighException- pcode compile error
-
newSectionSymbol
- Specified by:
newSectionSymbolin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
createCrossBuild
public VectorSTL<ghidra.pcodeCPort.semantics.OpTpl> createCrossBuild(Location where, ghidra.pcodeCPort.semantics.VarnodeTpl v, ghidra.pcodeCPort.slghsymbol.SectionSymbol second) - Specified by:
createCrossBuildin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
standaloneSection
public ghidra.pcodeCPort.slgh_compile.SectionVector standaloneSection(ghidra.pcodeCPort.semantics.ConstructTpl main) - Specified by:
standaloneSectionin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
firstNamedSection
public ghidra.pcodeCPort.slgh_compile.SectionVector firstNamedSection(ghidra.pcodeCPort.semantics.ConstructTpl main, ghidra.pcodeCPort.slghsymbol.SectionSymbol sym) - Specified by:
firstNamedSectionin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
nextNamedSection
public ghidra.pcodeCPort.slgh_compile.SectionVector nextNamedSection(ghidra.pcodeCPort.slgh_compile.SectionVector vec, ghidra.pcodeCPort.semantics.ConstructTpl section, ghidra.pcodeCPort.slghsymbol.SectionSymbol sym) - Specified by:
nextNamedSectionin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
finalNamedSection
public ghidra.pcodeCPort.slgh_compile.SectionVector finalNamedSection(ghidra.pcodeCPort.slgh_compile.SectionVector vec, ghidra.pcodeCPort.semantics.ConstructTpl section) - Specified by:
finalNamedSectionin classghidra.pcodeCPort.slgh_compile.PcodeCompile
-