Sorry this was not supposed to be committed.

Revert "Revert "Try to fix the type rewriter.""

This reverts commit c9bc1e7c64.
This commit is contained in:
Roberto Raggi
2010-07-20 15:04:50 +02:00
parent 3b48da9391
commit f895cbb472
4 changed files with 122 additions and 61 deletions

View File

@@ -51,51 +51,27 @@ public:
class CPLUSPLUS_EXPORT SubstitutionEnvironment
{
Q_DISABLE_COPY(SubstitutionEnvironment)
QList<Substitution *> substs;
public:
SubstitutionEnvironment() {}
SubstitutionEnvironment();
FullySpecifiedType apply(const Name *name, Rewrite *rewrite) const
{
if (name) {
for (int index = substs.size() - 1; index != -1; --index) {
const Substitution *subst = substs.at(index);
FullySpecifiedType apply(const Name *name, Rewrite *rewrite) const;
FullySpecifiedType ty = subst->apply(name, rewrite);
if (! ty->isUndefinedType())
return ty;
}
}
void enter(Substitution *subst);
void leave();
return FullySpecifiedType();
}
Scope *scope() const;
Scope *switchScope(Scope *scope);
void enter(Substitution *subst)
{
substs.append(subst);
}
void leave()
{
substs.removeLast();
}
};
class CPLUSPLUS_EXPORT ContextSubstitution: public Substitution
{
public:
ContextSubstitution(const LookupContext &context, Scope *scope);
virtual ~ContextSubstitution();
virtual FullySpecifiedType apply(const Name *name, Rewrite *rewrite) const;
const LookupContext &context() const;
void setContext(const LookupContext &context);
private:
LookupContext _context;
QList<Substitution *> _substs;
Scope *_scope;
LookupContext _context;
};
class CPLUSPLUS_EXPORT SubstitutionMap: public Substitution
{
public:
@@ -109,6 +85,17 @@ private:
QList<QPair<const Name *, FullySpecifiedType> > _map;
};
class CPLUSPLUS_EXPORT UseQualifiedNames: public Substitution
{
public:
UseQualifiedNames();
virtual ~UseQualifiedNames();
virtual FullySpecifiedType apply(const Name *name, Rewrite *rewrite) const;
};
CPLUSPLUS_EXPORT FullySpecifiedType rewriteType(const FullySpecifiedType &type,
SubstitutionEnvironment *env,
Control *control);