Commit 743e00f1 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Improved name substitution.

parent 4f3b2f93
......@@ -42,6 +42,7 @@
#include <NameVisitor.h>
#include <QtCore/QList>
#include <QtCore/QVarLengthArray>
#include <QtCore/QtDebug>
using namespace CPlusPlus;
......@@ -68,13 +69,27 @@ public:
protected:
FullySpecifiedType subst(Name *name)
{
if (TemplateNameId *t = name->asTemplateNameId()) {
QVarLengthArray<FullySpecifiedType, 8> args(t->templateArgumentCount());
for (unsigned i = 0; i < t->templateArgumentCount(); ++i)
args[i] = subst(t->templateArgumentAt(i));
TemplateNameId *n = _control->templateNameId(t->identifier(),
args.data(), args.size());
return FullySpecifiedType(_control->namedType(n));
} else if (name->isQualifiedNameId()) {
// ### implement me
}
for (int i = 0; i < _substitution.size(); ++i) {
const QPair<Name *, FullySpecifiedType> s = _substitution.at(i);
if (name->isEqualTo(s.first))
return s.second;
}
return _control->namedType(name);
return FullySpecifiedType(_control->namedType(name));
}
FullySpecifiedType subst(const FullySpecifiedType &ty)
......@@ -116,7 +131,10 @@ protected:
}
virtual void visit(NamedType *ty)
{ _type.setType(subst(ty->name()).type()); } // ### merge the specifiers
{
Name *name = ty->name();
_type.setType(subst(name).type());
}
virtual void visit(Function *ty)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment