Deprecate the old template instantiation.

This commit is contained in:
Roberto Raggi
2010-05-20 13:44:38 +02:00
parent e07c34017e
commit 3b113a2d74
6 changed files with 22 additions and 22 deletions

View File

@@ -27,7 +27,7 @@
** **
**************************************************************************/ **************************************************************************/
#include "GenTemplateInstance.h" #include "DeprecatedGenTemplateInstance.h"
#include "Overview.h" #include "Overview.h"
#include <Control.h> #include <Control.h>
@@ -47,7 +47,7 @@ namespace {
class ApplySubstitution class ApplySubstitution
{ {
public: public:
ApplySubstitution(Control *control, Symbol *symbol, const GenTemplateInstance::Substitution &substitution); ApplySubstitution(Control *control, Symbol *symbol, const DeprecatedGenTemplateInstance::Substitution &substitution);
~ApplySubstitution(); ~ApplySubstitution();
inline Control *control() const { return _control; } inline Control *control() const { return _control; }
@@ -311,13 +311,13 @@ private:
public: // attributes public: // attributes
Control *_control; Control *_control;
Symbol *symbol; Symbol *symbol;
GenTemplateInstance::Substitution substitution; DeprecatedGenTemplateInstance::Substitution substitution;
ApplyToType applyToType; ApplyToType applyToType;
ApplyToName applyToName; ApplyToName applyToName;
}; };
ApplySubstitution::ApplySubstitution(Control *control, Symbol *symbol, ApplySubstitution::ApplySubstitution(Control *control, Symbol *symbol,
const GenTemplateInstance::Substitution &substitution) const DeprecatedGenTemplateInstance::Substitution &substitution)
: _control(control), symbol(symbol), : _control(control), symbol(symbol),
substitution(substitution), substitution(substitution),
applyToType(this), applyToName(this) applyToType(this), applyToName(this)
@@ -363,24 +363,24 @@ FullySpecifiedType ApplySubstitution::applySubstitution(int index) const
} // end of anonymous namespace } // end of anonymous namespace
GenTemplateInstance::GenTemplateInstance(Control *control, const Substitution &substitution) DeprecatedGenTemplateInstance::DeprecatedGenTemplateInstance(Control *control, const Substitution &substitution)
: _symbol(0), : _symbol(0),
_control(control), _control(control),
_substitution(substitution) _substitution(substitution)
{ } { }
FullySpecifiedType GenTemplateInstance::gen(Symbol *symbol) FullySpecifiedType DeprecatedGenTemplateInstance::gen(Symbol *symbol)
{ {
ApplySubstitution o(_control, symbol, _substitution); ApplySubstitution o(_control, symbol, _substitution);
return o.apply(symbol->type()); return o.apply(symbol->type());
} }
FullySpecifiedType GenTemplateInstance::instantiate(const Name *className, Symbol *candidate, Control *control) FullySpecifiedType DeprecatedGenTemplateInstance::instantiate(const Name *className, Symbol *candidate, Control *control)
{ {
if (className) { if (className) {
if (const TemplateNameId *templId = className->asTemplateNameId()) { if (const TemplateNameId *templId = className->asTemplateNameId()) {
if (Class *klass = candidate->enclosingSymbol()->asClass()) { if (Class *klass = candidate->enclosingSymbol()->asClass()) {
GenTemplateInstance::Substitution subst; DeprecatedGenTemplateInstance::Substitution subst;
for (unsigned i = 0; i < templId->templateArgumentCount(); ++i) { for (unsigned i = 0; i < templId->templateArgumentCount(); ++i) {
FullySpecifiedType templArgTy = templId->templateArgumentAt(i); FullySpecifiedType templArgTy = templId->templateArgumentAt(i);
@@ -395,7 +395,7 @@ FullySpecifiedType GenTemplateInstance::instantiate(const Name *className, Symbo
} }
} }
GenTemplateInstance inst(control, subst); DeprecatedGenTemplateInstance inst(control, subst);
return inst.gen(candidate); return inst.gen(candidate);
} }
} }

View File

@@ -27,8 +27,8 @@
** **
**************************************************************************/ **************************************************************************/
#ifndef GENTEMPLATEINSTANCE_H #ifndef CPLUSPLUS_DEPRECATEDGENTEMPLATEINSTANCE_H
#define GENTEMPLATEINSTANCE_H #define CPLUSPLUS_DEPRECATEDGENTEMPLATEINSTANCE_H
#include <TypeVisitor.h> #include <TypeVisitor.h>
#include <NameVisitor.h> #include <NameVisitor.h>
@@ -41,7 +41,7 @@
namespace CPlusPlus { namespace CPlusPlus {
class CPLUSPLUS_EXPORT GenTemplateInstance class CPLUSPLUS_EXPORT DeprecatedGenTemplateInstance
{ {
public: public:
typedef QList< QPair<const Identifier *, FullySpecifiedType> > Substitution; typedef QList< QPair<const Identifier *, FullySpecifiedType> > Substitution;
@@ -50,7 +50,7 @@ public:
static FullySpecifiedType instantiate(const Name *className, Symbol *candidate, Control *control); static FullySpecifiedType instantiate(const Name *className, Symbol *candidate, Control *control);
private: private:
GenTemplateInstance(Control *control, const Substitution &substitution); DeprecatedGenTemplateInstance(Control *control, const Substitution &substitution);
FullySpecifiedType gen(Symbol *symbol); FullySpecifiedType gen(Symbol *symbol);
private: private:
@@ -61,4 +61,4 @@ private:
} // end of namespace CPlusPlus } // end of namespace CPlusPlus
#endif // GENTEMPLATEINSTANCE_H #endif // CPLUSPLUS_DEPRECATEDGENTEMPLATEINSTANCE_H

View File

@@ -31,7 +31,7 @@
#include "ResolveExpression.h" #include "ResolveExpression.h"
#include "Overview.h" #include "Overview.h"
#include "CppBindings.h" #include "CppBindings.h"
#include "GenTemplateInstance.h" #include "DeprecatedGenTemplateInstance.h"
#include <CoreTypes.h> #include <CoreTypes.h>
#include <Symbols.h> #include <Symbols.h>

View File

@@ -30,7 +30,7 @@
#include "ResolveExpression.h" #include "ResolveExpression.h"
#include "LookupContext.h" #include "LookupContext.h"
#include "Overview.h" #include "Overview.h"
#include "GenTemplateInstance.h" #include "DeprecatedGenTemplateInstance.h"
#include <Control.h> #include <Control.h>
#include <AST.h> #include <AST.h>
@@ -604,7 +604,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
foreach (Symbol *overload, binding->find(arrowOp)) { foreach (Symbol *overload, binding->find(arrowOp)) {
if (overload->type()->isFunctionType()) { if (overload->type()->isFunctionType()) {
FullySpecifiedType overloadTy = GenTemplateInstance::instantiate(binding->templateId(), overload, control()); FullySpecifiedType overloadTy = DeprecatedGenTemplateInstance::instantiate(binding->templateId(), overload, control());
Function *instantiatedFunction = overloadTy->asFunctionType(); Function *instantiatedFunction = overloadTy->asFunctionType();
Q_ASSERT(instantiatedFunction != 0); Q_ASSERT(instantiatedFunction != 0);
@@ -641,7 +641,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
FullySpecifiedType ResolveExpression::instantiate(const Name *className, Symbol *candidate) const FullySpecifiedType ResolveExpression::instantiate(const Name *className, Symbol *candidate) const
{ {
return GenTemplateInstance::instantiate(className, candidate, _context.control()); return DeprecatedGenTemplateInstance::instantiate(className, candidate, _context.control());
} }
bool ResolveExpression::visit(PostIncrDecrAST *) bool ResolveExpression::visit(PostIncrDecrAST *)

View File

@@ -39,7 +39,7 @@ HEADERS += \
$$PWD/DeprecatedLookupContext.h \ $$PWD/DeprecatedLookupContext.h \
$$PWD/CppBindings.h \ $$PWD/CppBindings.h \
$$PWD/ASTParent.h \ $$PWD/ASTParent.h \
$$PWD/GenTemplateInstance.h \ $$PWD/DeprecatedGenTemplateInstance.h \
$$PWD/FindUsages.h \ $$PWD/FindUsages.h \
$$PWD/CheckUndefinedSymbols.h \ $$PWD/CheckUndefinedSymbols.h \
$$PWD/DependencyTable.h \ $$PWD/DependencyTable.h \
@@ -66,7 +66,7 @@ SOURCES += \
$$PWD/DeprecatedLookupContext.cpp \ $$PWD/DeprecatedLookupContext.cpp \
$$PWD/CppBindings.cpp \ $$PWD/CppBindings.cpp \
$$PWD/ASTParent.cpp \ $$PWD/ASTParent.cpp \
$$PWD/GenTemplateInstance.cpp \ $$PWD/DeprecatedGenTemplateInstance.cpp \
$$PWD/FindUsages.cpp \ $$PWD/FindUsages.cpp \
$$PWD/CheckUndefinedSymbols.cpp \ $$PWD/CheckUndefinedSymbols.cpp \
$$PWD/DependencyTable.cpp \ $$PWD/DependencyTable.cpp \

View File

@@ -15,7 +15,7 @@
#include <Names.h> #include <Names.h>
#include <Literals.h> #include <Literals.h>
#include <DiagnosticClient.h> #include <DiagnosticClient.h>
#include <GenTemplateInstance.h> #include <DeprecatedGenTemplateInstance.h>
#include <Overview.h> #include <Overview.h>
#include <ExpressionUnderCursor.h> #include <ExpressionUnderCursor.h>
#include <Names.h> #include <Names.h>
@@ -436,7 +436,7 @@ void tst_Semantic::template_instance_1()
FullySpecifiedType templArgs[] = { control.integerType(IntegerType::Int) }; FullySpecifiedType templArgs[] = { control.integerType(IntegerType::Int) };
const Name *templId = control.templateNameId(control.findOrInsertIdentifier("QList"), templArgs, 1); const Name *templId = control.templateNameId(control.findOrInsertIdentifier("QList"), templArgs, 1);
FullySpecifiedType genTy = GenTemplateInstance::instantiate(templId, decl, &control); FullySpecifiedType genTy = DeprecatedGenTemplateInstance::instantiate(templId, decl, &control);
Overview oo; Overview oo;
oo.setShowReturnTypes(true); oo.setShowReturnTypes(true);