decompiler
1.0.0
|
A class for expanding macro directives within a p-code section. More...
#include <slgh_compile.hh>
Public Member Functions | |
MacroBuilder (SleighCompile *sl, vector< OpTpl *> &ovec, uint4 lbcnt) | |
Constructor. | |
void | setMacroOp (OpTpl *macroop) |
Establish the MACRO directive to expand. More... | |
bool | hasError (void) const |
Return true if there were errors during expansion. | |
virtual void | appendBuild (OpTpl *bld, int4 secnum) |
virtual void | delaySlot (OpTpl *op) |
virtual void | setLabel (OpTpl *op) |
virtual void | appendCrossBuild (OpTpl *bld, int4 secnum) |
Private Member Functions | |
bool | transferOp (OpTpl *op, vector< HandleTpl *> ¶ms) |
Given a cloned OpTpl, substitute parameters and add to the output list. More... | |
virtual void | dump (OpTpl *op) |
void | free (void) |
Free resources used by the builder. | |
void | reportError (const Location *loc, const string &val) |
Report error encountered expanding the macro. More... | |
Private Attributes | |
SleighCompile * | slgh |
The SLEIGH parsing object. | |
bool | haserror |
Set to true by the build() method if there was an error. | |
vector< OpTpl * > & | outvec |
The partial list of op templates to expand the macro into. | |
vector< HandleTpl * > | params |
List of parameters to substitute into the macro. | |
A class for expanding macro directives within a p-code section.
It is handed a (partial) list of p-code op templates (OpTpl). The macro directive is established with the setMacroOp() method. Then calling build() expands the macro into the list of OpTpls, providing parameter substitution. The class is derived from PcodeBuilder, where the dump() method, instead of emitting raw p-code, clones the macro templates into the list of OpTpls.
|
private |
Report error encountered expanding the macro.
The error is passed up to the main parse object and a note is made locally that an error occurred so parsing can be terminated immediately.
loc | is the parse location where the error occurred |
val | is the error message |
void ghidra::MacroBuilder::setMacroOp | ( | OpTpl * | macroop | ) |
Establish the MACRO directive to expand.
Given the op corresponding to the invocation, set up the specific parameters.
macroop | is the given MACRO directive op |
Referenced by ghidra::SleighCompile::expandMacros().
|
private |
Given a cloned OpTpl, substitute parameters and add to the output list.
VarnodesTpls used by the op are examined to see if they are derived from parameters of the macro. If so, details of the parameters actively passed as part of the specific macro invocation are substituted into the VarnodeTpl. Truncation operations on a macro parameter may cause additional CPUI_SUBPIECE operators to be inserted as part of the expansion and certain forms are not permitted.
op | is the cloned op to emit |
params | is the set of parameters specific to the macro invocation |
References ghidra::CPUI_SUBPIECE.