Internals: Prep for type method. No functional change intended.
This commit is contained in:
parent
cb550e5357
commit
451e961e03
|
|
@ -314,14 +314,13 @@ string AstVar::verilogKwd() const {
|
||||||
|
|
||||||
class AstVar::VlArgTypeRecursed {
|
class AstVar::VlArgTypeRecursed {
|
||||||
public:
|
public:
|
||||||
bool m_isRef; // Is it a reference?
|
|
||||||
string m_type; // The base type, e.g.: "Foo_t"s
|
string m_type; // The base type, e.g.: "Foo_t"s
|
||||||
string m_dims; // Array dimensions, e.g.: "[3][2][1]"
|
string m_dims; // Array dimensions, e.g.: "[3][2][1]"
|
||||||
string render(const string& name) const {
|
string render(const string& name, bool isRef) const {
|
||||||
string out;
|
string out;
|
||||||
out += m_type;
|
out += m_type;
|
||||||
out += " ";
|
out += " ";
|
||||||
out += m_isRef ? "(&" + name + ")" : name;
|
out += isRef ? "(&" + name + ")" : name;
|
||||||
out += m_dims;
|
out += m_dims;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
@ -333,21 +332,22 @@ string AstVar::vlArgType(bool named, bool forReturn, bool forFunc, const string&
|
||||||
string ostatic;
|
string ostatic;
|
||||||
if (isStatic() && namespc.empty()) ostatic = "static ";
|
if (isStatic() && namespc.empty()) ostatic = "static ";
|
||||||
|
|
||||||
|
bool isRef = isDpiOpenArray() || (forFunc && (isWritable() || direction().isRefOrConstRef()));
|
||||||
|
|
||||||
VlArgTypeRecursed info = vlArgTypeRecurse(forFunc, dtypep(), false);
|
VlArgTypeRecursed info = vlArgTypeRecurse(forFunc, dtypep(), false);
|
||||||
|
if (forFunc && isReadOnly() && isRef) ostatic = ostatic + "const ";
|
||||||
|
|
||||||
string oname;
|
string oname;
|
||||||
if (named) {
|
if (named) {
|
||||||
if (!namespc.empty()) oname += namespc + "::";
|
if (!namespc.empty()) oname += namespc + "::";
|
||||||
oname += VIdProtect::protectIf(name(), protect());
|
oname += VIdProtect::protectIf(name(), protect());
|
||||||
}
|
}
|
||||||
return ostatic + info.render(oname);
|
return ostatic + info.render(oname, isRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
AstVar::VlArgTypeRecursed AstVar::vlArgTypeRecurse(bool forFunc, const AstNodeDType* dtypep,
|
AstVar::VlArgTypeRecursed AstVar::vlArgTypeRecurse(bool forFunc, const AstNodeDType* dtypep,
|
||||||
bool compound) const {
|
bool compound) const {
|
||||||
VlArgTypeRecursed info;
|
VlArgTypeRecursed info;
|
||||||
info.m_isRef
|
|
||||||
= isDpiOpenArray() || (forFunc && (isWritable() || direction().isRefOrConstRef()));
|
|
||||||
|
|
||||||
dtypep = dtypep->skipRefp();
|
dtypep = dtypep->skipRefp();
|
||||||
if (const AstAssocArrayDType* adtypep = VN_CAST_CONST(dtypep, AssocArrayDType)) {
|
if (const AstAssocArrayDType* adtypep = VN_CAST_CONST(dtypep, AssocArrayDType)) {
|
||||||
|
|
@ -410,8 +410,6 @@ AstVar::VlArgTypeRecursed AstVar::vlArgTypeRecurse(bool forFunc, const AstNodeDT
|
||||||
|
|
||||||
UASSERT_OBJ(!compound || info.m_dims.empty(), this, "Declaring C array inside compound type");
|
UASSERT_OBJ(!compound || info.m_dims.empty(), this, "Declaring C array inside compound type");
|
||||||
|
|
||||||
if (forFunc && isReadOnly() && info.m_isRef) { info.m_type = "const " + info.m_type; }
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue