diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-07-20 14:23:46 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-07-20 14:23:46 +0200 |
commit | c9bc1e7c64fb73e8148b65dfe7a4521121331efc (patch) | |
tree | 273d33a86c629d95024db201b450d05e22309945 /src/libs/cplusplus/CppRewriter.cpp | |
parent | 99e862cfc9b39dc5bddd0efddf7d7c7a219b5107 (diff) | |
download | qt-creator-c9bc1e7c64fb73e8148b65dfe7a4521121331efc.tar.gz |
Revert "Try to fix the type rewriter."
This reverts commit 33b19f0210cd6ab1504071912caee91a95515c7c.
Diffstat (limited to 'src/libs/cplusplus/CppRewriter.cpp')
-rw-r--r-- | src/libs/cplusplus/CppRewriter.cpp | 104 |
1 files changed, 21 insertions, 83 deletions
diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp index 9b28a8102c..26c11596dd 100644 --- a/src/libs/cplusplus/CppRewriter.cpp +++ b/src/libs/cplusplus/CppRewriter.cpp @@ -34,7 +34,6 @@ #include <Literals.h> #include <Names.h> #include <Scope.h> -#include <cplusplus/Overview.h> #include <QtCore/QVarLengthArray> #include <QtCore/QDebug> @@ -121,7 +120,7 @@ public: { FullySpecifiedType ty = rewrite->env->apply(type->name(), rewrite); if (! ty->isUndefinedType()) - temps.append(ty); + temps.append(rewrite->rewriteType(ty)); else { const Name *name = rewrite->rewriteName(type->name()); temps.append(control()->namedType(name)); @@ -287,57 +286,39 @@ public: // attributes RewriteName rewriteName; }; -SubstitutionEnvironment::SubstitutionEnvironment() - : _scope(0) +ContextSubstitution::ContextSubstitution(const LookupContext &context, Scope *scope) + : _context(context), _scope(scope) { } -FullySpecifiedType SubstitutionEnvironment::apply(const Name *name, Rewrite *rewrite) const +ContextSubstitution::~ContextSubstitution() { - if (name) { - for (int index = _substs.size() - 1; index != -1; --index) { - const Substitution *subst = _substs.at(index); - - FullySpecifiedType ty = subst->apply(name, rewrite); - if (! ty->isUndefinedType()) - return ty; - } - } - - return FullySpecifiedType(); } -void SubstitutionEnvironment::enter(Substitution *subst) +FullySpecifiedType ContextSubstitution::apply(const Name *name, Rewrite *rewrite) const { - _substs.append(subst); -} + const QList<LookupItem> candidates = _context.lookup(name, _scope); -void SubstitutionEnvironment::leave() -{ - _substs.removeLast(); -} + foreach (const LookupItem &r, candidates) { + Symbol *s = r.declaration(); + if (s->isDeclaration() && s->isTypedef()) { + qDebug() << "resolved typedef:" << s->fileName() << s->line() << s->column(); -Scope *SubstitutionEnvironment::scope() const -{ - return _scope; -} + qDebug() << "scope is:" << r.scope()->owner()->fileName() + << r.scope()->owner()->line() + << r.scope()->owner()->column(); -Scope *SubstitutionEnvironment::switchScope(Scope *scope) -{ - Scope *previous = _scope; - _scope = scope; - return previous; -} + ContextSubstitution subst(_context, s->scope()); + rewrite->env->enter(&subst); + FullySpecifiedType ty = rewrite->rewriteType(s->type()); + rewrite->env->leave(); -const LookupContext &SubstitutionEnvironment::context() const -{ - return _context; + return ty; + } + } + return FullySpecifiedType(); } -void SubstitutionEnvironment::setContext(const LookupContext &context) -{ - _context = context; -} SubstitutionMap::SubstitutionMap() { @@ -366,49 +347,6 @@ FullySpecifiedType SubstitutionMap::apply(const Name *name, Rewrite *) const return FullySpecifiedType(); } - -UseQualifiedNames::UseQualifiedNames() -{ - -} - -UseQualifiedNames::~UseQualifiedNames() -{ - -} - -FullySpecifiedType UseQualifiedNames::apply(const Name *name, Rewrite *rewrite) const -{ - SubstitutionEnvironment *env = rewrite->env; - Scope *scope = env->scope(); - - if (! scope) - return FullySpecifiedType(); - - const LookupContext &context = env->context(); - Control *control = rewrite->control; - - const QList<LookupItem> results = context.lookup(name, scope); - foreach (const LookupItem &r, results) { - if (Symbol *d = r.declaration()) { - const Name *n = 0; - foreach (const Name *c, LookupContext::fullyQualifiedName(d)) { - if (! n) - n = c; - else - n = control->qualifiedNameId(n, c); - } - - return control->namedType(n); - } - - return r.type(); - } - - return FullySpecifiedType(); -} - - FullySpecifiedType CPlusPlus::rewriteType(const FullySpecifiedType &type, SubstitutionEnvironment *env, Control *control) |