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
Modifier and TypeClassDescriptionstatic class
This 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
ModifierConstructorDescriptionPcodeParser
(SleighLanguage language, long ubase) Build parser from an existing SleighLanguage.protected
PcodeParser
(ghidra.pcodeCPort.sleighbase.SleighBase sleigh) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOperand
(Location loc, String name, int index) Inject a symbol representing an "operand" to the pcode snippet.void
addSymbol
(ghidra.pcodeCPort.slghsymbol.SleighSymbol sym) long
void
compilePcode
(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.SectionVector
finalNamedSection
(ghidra.pcodeCPort.slgh_compile.SectionVector vec, ghidra.pcodeCPort.semantics.ConstructTpl section) ghidra.pcodeCPort.slghsymbol.SleighSymbol
findSymbol
(String nm) ghidra.pcodeCPort.slgh_compile.SectionVector
firstNamedSection
(ghidra.pcodeCPort.semantics.ConstructTpl main, ghidra.pcodeCPort.slghsymbol.SectionSymbol sym) ghidra.pcodeCPort.space.AddrSpace
ghidra.pcodeCPort.space.AddrSpace
long
ghidra.pcodeCPort.sleighbase.SleighBase
ghidra.pcodeCPort.space.AddrSpace
ghidra.pcodeCPort.slghsymbol.SectionSymbol
newSectionSymbol
(Location where, String text) ghidra.pcodeCPort.slgh_compile.SectionVector
nextNamedSection
(ghidra.pcodeCPort.slgh_compile.SectionVector vec, ghidra.pcodeCPort.semantics.ConstructTpl section, ghidra.pcodeCPort.slghsymbol.SectionSymbol sym) void
ghidra.pcodeCPort.slgh_compile.SectionVector
standaloneSection
(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:
addSymbol
in classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
clearSymbols
public void clearSymbols() -
getNextTempOffset
public long getNextTempOffset() -
allocateTemp
public long allocateTemp()- Specified by:
allocateTemp
in 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:
createMacroUse
in classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
findSymbol
- Specified by:
findSymbol
in classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
getSleigh
public ghidra.pcodeCPort.sleighbase.SleighBase getSleigh() -
getConstantSpace
public ghidra.pcodeCPort.space.AddrSpace getConstantSpace()- Specified by:
getConstantSpace
in classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
getDefaultSpace
public ghidra.pcodeCPort.space.AddrSpace getDefaultSpace()- Specified by:
getDefaultSpace
in classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
getUniqueSpace
public ghidra.pcodeCPort.space.AddrSpace getUniqueSpace()- Specified by:
getUniqueSpace
in classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
recordNop
- Specified by:
recordNop
in 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:
newSectionSymbol
in 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:
createCrossBuild
in classghidra.pcodeCPort.slgh_compile.PcodeCompile
-
standaloneSection
public ghidra.pcodeCPort.slgh_compile.SectionVector standaloneSection(ghidra.pcodeCPort.semantics.ConstructTpl main) - Specified by:
standaloneSection
in 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:
firstNamedSection
in 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:
nextNamedSection
in 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:
finalNamedSection
in classghidra.pcodeCPort.slgh_compile.PcodeCompile
-