"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "projects/CodeThorn/src/ClassHierarchyWriter.C" between
rose-0.11.53.0.tar.gz and rose-0.11.54.0.tar.gz

About: ROSE is a compiler infrastructure to build source-to-source program transformation and analysis tools for large-scale C, C++, UPC, Fortran, OpenMP, Java, Python and PHP applications.

ClassHierarchyWriter.C  (rose-0.11.53.0):ClassHierarchyWriter.C  (rose-0.11.54.0)
skipping to change at line 178 skipping to change at line 178
bool skipEmpty = true bool skipEmpty = true
) )
{ {
if (skipEmpty && functions.size() == 0) if (skipEmpty && functions.size() == 0)
return; return;
os << " " << desc << ": "; os << " " << desc << ": ";
for (const ct::OverrideDesc& fn: functions) for (const ct::OverrideDesc& fn: functions)
{ {
const ct::FunctionId funid = fn.functionId(); const ct::FunctionKeyType funid = fn.functionId();
const ct::VirtualFunctionDesc& other = vfuns.at(funid); const ct::VirtualFunctionDesc& other = vfuns.at(funid);
os << className(other.classId()) os << className(other.classId())
<< "::" << funcName(funid) << "::" << funcName(funid)
<< " #" << funid.getIdCode() << " #" << funid
<< (fn.covariantReturn() ? " (covariant)" : "") << (fn.covariantReturn() ? " (covariant)" : "")
<< ", "; << ", ";
} }
os << std::endl; os << std::endl;
} }
void printOverriders( std::ostream& os, void printOverriders( std::ostream& os,
ct::ClassNameFn& className, ct::ClassNameFn& className,
ct::FuncNameFn& funcName, ct::FuncNameFn& funcName,
skipping to change at line 227 skipping to change at line 227
ct::ClassNameFn& className, ct::ClassNameFn& className,
ct::FuncNameFn& funcName, ct::FuncNameFn& funcName,
const ct::VirtualFunctionAnalysis& vfuns, const ct::VirtualFunctionAnalysis& vfuns,
const ct::ClassAnalysis::value_type& clazz, const ct::ClassAnalysis::value_type& clazz,
bool withOverridden = false bool withOverridden = false
) )
{ {
os << "Class " << className(clazz.first) << "\n" os << "Class " << className(clazz.first) << "\n"
<< std::endl; << std::endl;
for (ct::FunctionId vfnId : clazz.second.virtualFunctions()) for (ct::FunctionKeyType vfnId : clazz.second.virtualFunctions())
{ {
const ct::VirtualFunctionDesc& vfn = vfuns.at(vfnId); const ct::VirtualFunctionDesc& vfn = vfuns.at(vfnId);
if (!printsData(vfn, withOverridden)) if (!printsData(vfn, withOverridden))
continue; continue;
os << " Function " << funcName(vfnId) os << " Function " << funcName(vfnId)
<< " #" << vfnId.getIdCode() << " #" << vfnId
<< (vfn.isPureVirtual() ? " (pure virtual)" : "") << (vfn.isPureVirtual() ? " (pure virtual)" : "")
<< std::endl; << std::endl;
printOverriders(os, className, funcName, vfuns, vfn); printOverriders(os, className, funcName, vfuns, vfn);
if (withOverridden) if (withOverridden)
printOverridden(os, className, funcName, vfuns, vfn); printOverridden(os, className, funcName, vfuns, vfn);
} }
os << std::endl; os << std::endl;
} }
void writeVirtualBaseOrder( std::ostream& os,
ct::ClassNameFn& className,
const ct::ClassAnalysis::value_type& clazz
)
{
const ct::ClassData::VirtualBaseOrderContainer& vbases = clazz.second.virtua
lBaseClassOrder();
if (vbases.empty())
return;
os << "Class " << className(clazz.first) << "\n "
<< std::flush;
for (ct::ClassKeyType basecls : vbases)
os << className(basecls) << ", ";
os << '\n' << std::endl;
}
struct ObjectLayoutElementPrinter : boost::static_visitor<void> struct ObjectLayoutElementPrinter : boost::static_visitor<void>
{ {
ObjectLayoutElementPrinter(std::ostream& out, ClassNameFn& classNamer, Var NameFn& varNamer) ObjectLayoutElementPrinter(std::ostream& out, ct::ClassNameFn& classNamer, ct::VarNameFn& varNamer)
: os(out), className(classNamer), varName(varNamer) : os(out), className(classNamer), varName(varNamer)
{} {}
virtual std::string escapeName(std::string s) const virtual std::string escapeName(std::string s) const
{ {
return s; return s;
} }
virtual void operator()(const Subobject& subobj) const virtual void operator()(const ct::Subobject& subobj) const
{ {
out() << "subobj " << escapeName(className(subobj.ref)) out() << "subobj " << escapeName(className(subobj.ref))
<< (subobj.isVirtual ? " (virtual)" : ""); << (subobj.isVirtual ? " (virtual)" : "");
} }
virtual void operator()(const Field& fld) const virtual void operator()(const ct::Field& fld) const
{ {
out() << "field " << escapeName(varName(fld.id)); out() << "field " << escapeName(varName(fld.id));
} }
virtual void operator()(const VTable& vtbl) const virtual void operator()(const ct::VTable& vtbl) const
{ {
out() << "vtable " << escapeName(className(vtbl.ref)) out() << "vtable " << escapeName(className(vtbl.ref))
<< (vtbl.isPrimary ? " (primary)" : ""); << (vtbl.isPrimary ? " (primary)" : "");
} }
virtual void printEntry(const ObjectLayoutEntry& el) const virtual void printEntry(const ct::ObjectLayoutEntry& el) const
{ {
boost::apply_visitor(*this, el.element()); boost::apply_visitor(*this, el.element());
} }
virtual void printClassHeader(ClassKeyType key) const virtual void printClassHeader(ct::ClassKeyType key) const
{ {
out() << "class " << escapeName(className(key)); out() << "class " << escapeName(className(key));
} }
virtual void printClassFooter() const {} virtual void printClassFooter() const {}
std::ostream& out() const { return os; } std::ostream& out() const { return os; }
private: private:
std::ostream& os; std::ostream& os;
ClassNameFn& className; ct::ClassNameFn& className;
VarNameFn& varName; ct::VarNameFn& varName;
}; };
struct InheritanceEdgeDot : std::tuple<const void*, const void*, bool, bool> struct InheritanceEdgeDot : std::tuple<const void*, const void*, bool, bool>
{ {
using base = std::tuple<const void*, const void*, bool, bool>; using base = std::tuple<const void*, const void*, bool, bool>;
using base::base; using base::base;
const void* subobj() const { return std::get<0>(*this); } const void* subobj() const { return std::get<0>(*this); }
const void* clazz() const { return std::get<1>(*this); } const void* clazz() const { return std::get<1>(*this); }
bool isVirtual() const { return std::get<2>(*this); } bool isVirtual() const { return std::get<2>(*this); }
bool isDirect() const { return std::get<3>(*this); } bool isDirect() const { return std::get<3>(*this); }
}; };
struct ObjectLayoutElementPrinterDot : ObjectLayoutElementPrinter struct ObjectLayoutElementPrinterDot : ObjectLayoutElementPrinter
{ {
using base = ObjectLayoutElementPrinter; using base = ObjectLayoutElementPrinter;
ObjectLayoutElementPrinterDot(std::ostream& out, ClassNameFn& classNamer, ObjectLayoutElementPrinterDot( std::ostream& out,
VarNameFn& varNamer, ClassFilterFn incl) ct::ClassNameFn& classNamer,
ct::VarNameFn& varNamer,
ct::ClassFilterFn incl
)
: base(out, classNamer, varNamer), include(incl), edges(), currentClass() : base(out, classNamer, varNamer), include(incl), edges(), currentClass()
{} {}
void elem_begin(const void* elem) const; void elem_begin(const void* elem) const;
void elem_end() const; void elem_end() const;
void class_begin(const void* elem) const; void class_begin(const void* elem) const;
void class_end() const; void class_end() const;
template <class ClassElem> template <class ClassElem>
void elem(const ClassElem& el) const void elem(const ClassElem& el) const
{ {
elem_begin(&el); elem_begin(&el);
base::operator()(el); base::operator()(el);
elem_end(); elem_end();
} }
void operator()(const Field& el) const override { elem(el); } void operator()(const ct::Field& el) const override { elem(el); }
void operator()(const VTable& el) const override { elem(el); } void operator()(const ct::VTable& el) const override { elem(el); }
void operator()(const Subobject& el) const override void operator()(const ct::Subobject& el) const override
{ {
elem(el); elem(el);
if (include(el.ref)) if (include(el.ref))
edges.emplace_back(&el, el.ref, el.isVirtual, el.isDirect); edges.emplace_back(&el, el.ref, el.isVirtual, el.isDirect);
} }
void printClassHeader(ClassKeyType key) const override void printClassHeader(ct::ClassKeyType key) const override
{ {
currentClass = key; currentClass = key;
class_begin(key); class_begin(key);
out() << "="; out() << "=";
base::printClassHeader(key); base::printClassHeader(key);
out() << "="; out() << "=";
} }
void printClassFooter() const override void printClassFooter() const override
skipping to change at line 365 skipping to change at line 388
out() << "p" << std::hex << currentClass << ":p" << std::hex << rel.su bobj() out() << "p" << std::hex << currentClass << ":p" << std::hex << rel.su bobj()
<< " -> p" << std::hex << rel.clazz() << ":0" << " -> p" << std::hex << rel.clazz() << ":0"
<< "[color=" << "[color="
<< (rel.isVirtual() ? "red" : "green") << (rel.isVirtual() ? "red" : "green")
<< (rel.isDirect() ? "" : " style=dotted") << (rel.isDirect() ? "" : " style=dotted")
<< "]" << "]"
<< ';' << std::endl; << ';' << std::endl;
} }
edges.clear(); edges.clear();
currentClass = ClassKeyType{}; currentClass = ct::ClassKeyType{};
} }
std::string escapeName(std::string s) const override std::string escapeName(std::string s) const override
{ {
std::string res; std::string res;
res.reserve(s.size()); res.reserve(s.size());
for (char c : s) for (char c : s)
{ {
if ((c == '<') || (c == '>')) if ((c == '<') || (c == '>'))
res += '\\'; res += '\\';
res += c; res += c;
} }
return res; return res;
} }
private: private:
ClassFilterFn include; ct::ClassFilterFn include;
mutable std::vector<InheritanceEdgeDot> edges; mutable std::vector<InheritanceEdgeDot> edges;
mutable ClassKeyType currentClass; mutable ct::ClassKeyType currentClass;
}; };
void ObjectLayoutElementPrinterDot::elem_begin(const void* elem) const void ObjectLayoutElementPrinterDot::elem_begin(const void* elem) const
{ {
out() << "|<p" << std::hex << (elem) << ">"; out() << "|<p" << std::hex << (elem) << ">";
} }
void ObjectLayoutElementPrinterDot::elem_end() const {} void ObjectLayoutElementPrinterDot::elem_end() const {}
void ObjectLayoutElementPrinterDot::class_begin(const void* elem) const void ObjectLayoutElementPrinterDot::class_begin(const void* elem) const
skipping to change at line 412 skipping to change at line 435
void ObjectLayoutElementPrinterDot::class_end() const void ObjectLayoutElementPrinterDot::class_end() const
{ {
out() << "\"];" << std::endl; out() << "\"];" << std::endl;
} }
struct ObjectLayoutElementPrinterTxt : ObjectLayoutElementPrinter struct ObjectLayoutElementPrinterTxt : ObjectLayoutElementPrinter
{ {
using base = ObjectLayoutElementPrinter; using base = ObjectLayoutElementPrinter;
using base::base; using base::base;
void printEntry(const ObjectLayoutEntry& el) const override void printEntry(const ct::ObjectLayoutEntry& el) const override
{ {
out() << el.offset() << " "; out() << el.offset() << " ";
base::printEntry(el); base::printEntry(el);
} }
void printClassHeader(ClassKeyType key) const override void printClassHeader(ct::ClassKeyType key) const override
{ {
base::printClassHeader(key); base::printClassHeader(key);
out() << std::endl; out() << std::endl;
} }
}; };
void prnClassLayout( const ObjectLayoutElementPrinter& printer, void prnClassLayout( const ObjectLayoutElementPrinter& printer,
ClassFilterFn include, ct::ClassFilterFn include,
const ObjectLayoutContainer& cont const ct::ObjectLayoutContainer& cont
) )
{ {
for (const ObjectLayoutContainer::value_type& entry : cont) for (const ct::ObjectLayoutContainer::value_type& entry : cont)
{ {
if (!include) continue; if (!include) continue;
printer.printClassHeader(entry.first); printer.printClassHeader(entry.first);
for (const ObjectLayoutEntry& elem : entry.second) for (const ct::ObjectLayoutEntry& elem : entry.second)
printer.printEntry(elem); printer.printEntry(elem);
printer.printClassFooter(); printer.printClassFooter();
} }
} }
} }
namespace CodeThorn namespace CodeThorn
{ {
skipping to change at line 501 skipping to change at line 524
className, className,
funcName, funcName,
vfuns, vfuns,
elem, elem,
overridden overridden
); );
} }
); );
} }
void virtualBaseClassInitOrderTxt( std::ostream& os,
ClassNameFn& className,
ClassFilterFn include,
const ClassAnalysis& classes
)
{
topDownTraversal( classes,
[&os, &className, &include]
(const ClassAnalysis::value_type& elem) -> void
{
if (!include(elem.first)) return;
writeVirtualBaseOrder( os,
className,
elem
);
}
);
}
void classLayoutTxt( std::ostream& os, void classLayoutTxt( std::ostream& os,
ClassNameFn& className, ClassNameFn& className,
VarNameFn& varName, VarNameFn& varName,
ClassFilterFn include, ClassFilterFn include,
const ObjectLayoutContainer& classLayout const ObjectLayoutContainer& classLayout
) )
{ {
prnClassLayout(ObjectLayoutElementPrinterTxt{os, className, varName}, include, classLayout); prnClassLayout(ObjectLayoutElementPrinterTxt{os, className, varName}, include, classLayout);
} }
 End of changes. 25 change blocks. 
28 lines changed or deleted 71 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)