mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Marshaling of hasThisPointer property
This commit is contained in:
parent
afa4994576
commit
db139d2b81
4 changed files with 32 additions and 20 deletions
|
@ -3683,8 +3683,6 @@ void FuncProto::saveXml(ostream &s) const
|
||||||
a_v_b(s,"constructor",true);
|
a_v_b(s,"constructor",true);
|
||||||
if (isDestructor())
|
if (isDestructor())
|
||||||
a_v_b(s,"destructor",true);
|
a_v_b(s,"destructor",true);
|
||||||
if (hasThisPointer())
|
|
||||||
a_v_b(s,"hasthis",true);
|
|
||||||
s << ">\n";
|
s << ">\n";
|
||||||
ProtoParameter *outparam = store->getOutput();
|
ProtoParameter *outparam = store->getOutput();
|
||||||
s << " <returnsym";
|
s << " <returnsym";
|
||||||
|
@ -3828,10 +3826,6 @@ void FuncProto::restoreXml(const Element *el,Architecture *glb)
|
||||||
if (xml_readbool(el->getAttributeValue(i)))
|
if (xml_readbool(el->getAttributeValue(i)))
|
||||||
flags |= is_destructor;
|
flags |= is_destructor;
|
||||||
}
|
}
|
||||||
else if (attrname == "hasthis") {
|
|
||||||
if (xml_readbool(el->getAttributeValue(i)))
|
|
||||||
flags |= has_thisptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (mod != (ProtoModel *)0) // If a model was specified
|
if (mod != (ProtoModel *)0) // If a model was specified
|
||||||
setModel(mod); // This sets extrapop to model default
|
setModel(mod); // This sets extrapop to model default
|
||||||
|
|
|
@ -37,7 +37,7 @@ PrintLanguage *PrintJavaCapability::buildLanguage(Architecture *glb)
|
||||||
PrintJava::PrintJava(Architecture *glb,const string &nm) : PrintC(glb,nm)
|
PrintJava::PrintJava(Architecture *glb,const string &nm) : PrintC(glb,nm)
|
||||||
|
|
||||||
{
|
{
|
||||||
option_NULL = true; // Automatically use 'null' token
|
resetDefaultsPrintJava();
|
||||||
nullToken = "null"; // Java standard lower-case 'null'
|
nullToken = "null"; // Java standard lower-case 'null'
|
||||||
mods |= hide_thisparam; // turn on hiding of 'this' parameter
|
mods |= hide_thisparam; // turn on hiding of 'this' parameter
|
||||||
if (castStrategy != (CastStrategy *)0)
|
if (castStrategy != (CastStrategy *)0)
|
||||||
|
@ -46,6 +46,13 @@ PrintJava::PrintJava(Architecture *glb,const string &nm) : PrintC(glb,nm)
|
||||||
castStrategy = new CastStrategyJava();
|
castStrategy = new CastStrategyJava();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintJava::resetDefaults(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
PrintC::resetDefaults();
|
||||||
|
resetDefaultsPrintJava();
|
||||||
|
}
|
||||||
|
|
||||||
void PrintJava::docFunction(const Funcdata *fd)
|
void PrintJava::docFunction(const Funcdata *fd)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -148,6 +155,13 @@ bool PrintJava::isArrayType(const Datatype *ct)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintJava::resetDefaultsPrintJava(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
option_NULL = true; // Automatically use 'null' token
|
||||||
|
option_convention = false; // Automatically hide convention name
|
||||||
|
}
|
||||||
|
|
||||||
/// Assuming the given Varnode is a dereferenced pointer, determine whether
|
/// Assuming the given Varnode is a dereferenced pointer, determine whether
|
||||||
/// it needs to be represented using '[0]' syntax.
|
/// it needs to be represented using '[0]' syntax.
|
||||||
/// \param vn is the given Varnode
|
/// \param vn is the given Varnode
|
||||||
|
|
|
@ -56,9 +56,11 @@ class PrintJava : public PrintC {
|
||||||
static OpToken instanceof; ///< The \b instanceof keyword
|
static OpToken instanceof; ///< The \b instanceof keyword
|
||||||
static bool isArrayType(const Datatype *ct); ///< Does the given data-type reference a java array
|
static bool isArrayType(const Datatype *ct); ///< Does the given data-type reference a java array
|
||||||
static bool needZeroArray(const Varnode *vn); ///< Do we need '[0]' syntax.
|
static bool needZeroArray(const Varnode *vn); ///< Do we need '[0]' syntax.
|
||||||
|
void resetDefaultsPrintJava(void); ///< Set options that are specific to Java
|
||||||
virtual void printUnicode(ostream &s,int4 onechar) const;
|
virtual void printUnicode(ostream &s,int4 onechar) const;
|
||||||
public:
|
public:
|
||||||
PrintJava(Architecture *g,const string &nm="java-language"); ///< Constructor
|
PrintJava(Architecture *g,const string &nm="java-language"); ///< Constructor
|
||||||
|
virtual void resetDefaults(void);
|
||||||
virtual void docFunction(const Funcdata *fd);
|
virtual void docFunction(const Funcdata *fd);
|
||||||
virtual void pushTypeStart(const Datatype *ct,bool noident);
|
virtual void pushTypeStart(const Datatype *ct,bool noident);
|
||||||
virtual void pushTypeEnd(const Datatype *ct);
|
virtual void pushTypeEnd(const Datatype *ct);
|
||||||
|
|
|
@ -52,7 +52,9 @@ public class FunctionPrototype {
|
||||||
private boolean isDestruct; // Function is an object destructor
|
private boolean isDestruct; // Function is an object destructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a FunctionPrototype backed by a local symbolmap
|
* Construct a FunctionPrototype backed by a local symbolmap.
|
||||||
|
* This is only a partial initialization. It is intended to be followed either by
|
||||||
|
* grabFromFunction() or readPrototypeXML()
|
||||||
*
|
*
|
||||||
* @param ls is the LocalSymbolMap backing the prototype
|
* @param ls is the LocalSymbolMap backing the prototype
|
||||||
* @param func is the function using the symbolmap
|
* @param func is the function using the symbolmap
|
||||||
|
@ -102,7 +104,7 @@ public class FunctionPrototype {
|
||||||
noreturn = false;
|
noreturn = false;
|
||||||
custom = false;
|
custom = false;
|
||||||
extrapop = model.getExtrapop();
|
extrapop = model.getExtrapop();
|
||||||
hasThis = false;
|
hasThis = model.hasThisPointer();
|
||||||
isConstruct = false;
|
isConstruct = false;
|
||||||
isDestruct = false;
|
isDestruct = false;
|
||||||
// FIXME: If the FunctionDefinition has no parameters
|
// FIXME: If the FunctionDefinition has no parameters
|
||||||
|
@ -126,6 +128,11 @@ public class FunctionPrototype {
|
||||||
*/
|
*/
|
||||||
void grabFromFunction(Function f, int overrideExtrapop, boolean doOverride) {
|
void grabFromFunction(Function f, int overrideExtrapop, boolean doOverride) {
|
||||||
modelname = f.getCallingConventionName();
|
modelname = f.getCallingConventionName();
|
||||||
|
PrototypeModel protoModel = f.getCallingConvention();
|
||||||
|
if (protoModel == null) {
|
||||||
|
protoModel = f.getProgram().getCompilerSpec().getDefaultCallingConvention();
|
||||||
|
}
|
||||||
|
hasThis = protoModel.hasThisPointer();
|
||||||
modellock =
|
modellock =
|
||||||
((modelname != null) && (modelname != Function.UNKNOWN_CALLING_CONVENTION_STRING));
|
((modelname != null) && (modelname != Function.UNKNOWN_CALLING_CONVENTION_STRING));
|
||||||
injectname = f.getCallFixup();
|
injectname = f.getCallFixup();
|
||||||
|
@ -164,10 +171,6 @@ public class FunctionPrototype {
|
||||||
extrapop = overrideExtrapop;
|
extrapop = overrideExtrapop;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PrototypeModel protoModel = f.getCallingConvention();
|
|
||||||
if (protoModel == null) {
|
|
||||||
protoModel = f.getProgram().getCompilerSpec().getDefaultCallingConvention();
|
|
||||||
}
|
|
||||||
if (purge == Function.INVALID_STACK_DEPTH_CHANGE ||
|
if (purge == Function.INVALID_STACK_DEPTH_CHANGE ||
|
||||||
purge == Function.UNKNOWN_STACK_DEPTH_CHANGE) {
|
purge == Function.UNKNOWN_STACK_DEPTH_CHANGE) {
|
||||||
extrapop = protoModel.getExtrapop();
|
extrapop = protoModel.getExtrapop();
|
||||||
|
@ -343,9 +346,6 @@ public class FunctionPrototype {
|
||||||
if (custom) {
|
if (custom) {
|
||||||
SpecXmlUtils.encodeBooleanAttribute(res, "custom", custom);
|
SpecXmlUtils.encodeBooleanAttribute(res, "custom", custom);
|
||||||
}
|
}
|
||||||
if (hasThis) {
|
|
||||||
SpecXmlUtils.encodeBooleanAttribute(res, "hasthis", hasThis);
|
|
||||||
}
|
|
||||||
if (isConstruct) {
|
if (isConstruct) {
|
||||||
SpecXmlUtils.encodeBooleanAttribute(res, "constructor", isConstruct);
|
SpecXmlUtils.encodeBooleanAttribute(res, "constructor", isConstruct);
|
||||||
}
|
}
|
||||||
|
@ -421,6 +421,12 @@ public class FunctionPrototype {
|
||||||
throws PcodeXMLException {
|
throws PcodeXMLException {
|
||||||
XmlElement node = parser.start("prototype");
|
XmlElement node = parser.start("prototype");
|
||||||
modelname = node.getAttribute("model");
|
modelname = node.getAttribute("model");
|
||||||
|
PrototypeModel protoModel =
|
||||||
|
dtmanage.getProgram().getCompilerSpec().getCallingConvention(modelname);
|
||||||
|
if (protoModel == null) {
|
||||||
|
throw new PcodeXMLException("Bad prototype model name: " + modelname);
|
||||||
|
}
|
||||||
|
hasThis = protoModel.hasThisPointer();
|
||||||
String val = node.getAttribute("extrapop");
|
String val = node.getAttribute("extrapop");
|
||||||
if (val.equals("unknown")) {
|
if (val.equals("unknown")) {
|
||||||
extrapop = PrototypeModel.UNKNOWN_EXTRAPOP;
|
extrapop = PrototypeModel.UNKNOWN_EXTRAPOP;
|
||||||
|
@ -452,10 +458,6 @@ public class FunctionPrototype {
|
||||||
if (node.hasAttribute("custom")) {
|
if (node.hasAttribute("custom")) {
|
||||||
custom = SpecXmlUtils.decodeBoolean(node.getAttribute("custom"));
|
custom = SpecXmlUtils.decodeBoolean(node.getAttribute("custom"));
|
||||||
}
|
}
|
||||||
hasThis = false;
|
|
||||||
if (node.hasAttribute("hasthis")) {
|
|
||||||
hasThis = SpecXmlUtils.decodeBoolean(node.getAttribute("hasthis"));
|
|
||||||
}
|
|
||||||
isConstruct = false;
|
isConstruct = false;
|
||||||
if (node.hasAttribute("constructor")) {
|
if (node.hasAttribute("constructor")) {
|
||||||
isConstruct = SpecXmlUtils.decodeBoolean(node.getAttribute("constructor"));
|
isConstruct = SpecXmlUtils.decodeBoolean(node.getAttribute("constructor"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue