Commit 3b113a2d authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Deprecate the old template instantiation.

parent e07c3401
......@@ -27,7 +27,7 @@
**
**************************************************************************/
#include "GenTemplateInstance.h"
#include "DeprecatedGenTemplateInstance.h"
#include "Overview.h"
#include <Control.h>
......@@ -47,7 +47,7 @@ namespace {
class ApplySubstitution
{
public:
ApplySubstitution(Control *control, Symbol *symbol, const GenTemplateInstance::Substitution &substitution);
ApplySubstitution(Control *control, Symbol *symbol, const DeprecatedGenTemplateInstance::Substitution &substitution);
~ApplySubstitution();
inline Control *control() const { return _control; }
......@@ -311,13 +311,13 @@ private:
public: // attributes
Control *_control;
Symbol *symbol;
GenTemplateInstance::Substitution substitution;
DeprecatedGenTemplateInstance::Substitution substitution;
ApplyToType applyToType;
ApplyToName applyToName;
};
ApplySubstitution::ApplySubstitution(Control *control, Symbol *symbol,
const GenTemplateInstance::Substitution &substitution)
const DeprecatedGenTemplateInstance::Substitution &substitution)
: _control(control), symbol(symbol),
substitution(substitution),
applyToType(this), applyToName(this)
......@@ -363,24 +363,24 @@ FullySpecifiedType ApplySubstitution::applySubstitution(int index) const
} // end of anonymous namespace
GenTemplateInstance::GenTemplateInstance(Control *control, const Substitution &substitution)
DeprecatedGenTemplateInstance::DeprecatedGenTemplateInstance(Control *control, const Substitution &substitution)
: _symbol(0),
_control(control),
_substitution(substitution)
{ }
FullySpecifiedType GenTemplateInstance::gen(Symbol *symbol)
FullySpecifiedType DeprecatedGenTemplateInstance::gen(Symbol *symbol)
{
ApplySubstitution o(_control, symbol, _substitution);
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 (const TemplateNameId *templId = className->asTemplateNameId()) {
if (Class *klass = candidate->enclosingSymbol()->asClass()) {
GenTemplateInstance::Substitution subst;
DeprecatedGenTemplateInstance::Substitution subst;
for (unsigned i = 0; i < templId->templateArgumentCount(); ++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);
}
}
......
......@@ -27,8 +27,8 @@
**
**************************************************************************/
#ifndef GENTEMPLATEINSTANCE_H
#define GENTEMPLATEINSTANCE_H
#ifndef CPLUSPLUS_DEPRECATEDGENTEMPLATEINSTANCE_H
#define CPLUSPLUS_DEPRECATEDGENTEMPLATEINSTANCE_H
#include <TypeVisitor.h>
#include <NameVisitor.h>
......@@ -41,7 +41,7 @@
namespace CPlusPlus {
class CPLUSPLUS_EXPORT GenTemplateInstance
class CPLUSPLUS_EXPORT DeprecatedGenTemplateInstance
{
public:
typedef QList< QPair<const Identifier *, FullySpecifiedType> > Substitution;
......@@ -50,7 +50,7 @@ public:
static FullySpecifiedType instantiate(const Name *className, Symbol *candidate, Control *control);
private:
GenTemplateInstance(Control *control, const Substitution &substitution);
DeprecatedGenTemplateInstance(Control *control, const Substitution &substitution);
FullySpecifiedType gen(Symbol *symbol);
private:
......@@ -61,4 +61,4 @@ private:
} // end of namespace CPlusPlus
#endif // GENTEMPLATEINSTANCE_H
#endif // CPLUSPLUS_DEPRECATEDGENTEMPLATEINSTANCE_H
......@@ -31,7 +31,7 @@
#include "ResolveExpression.h"
#include "Overview.h"
#include "CppBindings.h"
#include "GenTemplateInstance.h"
#include "DeprecatedGenTemplateInstance.h"
#include <CoreTypes.h>
#include <Symbols.h>
......
......@@ -30,7 +30,7 @@
#include "ResolveExpression.h"
#include "LookupContext.h"
#include "Overview.h"
#include "GenTemplateInstance.h"
#include "DeprecatedGenTemplateInstance.h"
#include <Control.h>
#include <AST.h>
......@@ -604,7 +604,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
foreach (Symbol *overload, binding->find(arrowOp)) {
if (overload->type()->isFunctionType()) {
FullySpecifiedType overloadTy = GenTemplateInstance::instantiate(binding->templateId(), overload, control());
FullySpecifiedType overloadTy = DeprecatedGenTemplateInstance::instantiate(binding->templateId(), overload, control());
Function *instantiatedFunction = overloadTy->asFunctionType();
Q_ASSERT(instantiatedFunction != 0);
......@@ -641,7 +641,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
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 *)
......
......@@ -39,7 +39,7 @@ HEADERS += \
$$PWD/DeprecatedLookupContext.h \
$$PWD/CppBindings.h \
$$PWD/ASTParent.h \
$$PWD/GenTemplateInstance.h \
$$PWD/DeprecatedGenTemplateInstance.h \
$$PWD/FindUsages.h \
$$PWD/CheckUndefinedSymbols.h \
$$PWD/DependencyTable.h \
......@@ -66,7 +66,7 @@ SOURCES += \
$$PWD/DeprecatedLookupContext.cpp \
$$PWD/CppBindings.cpp \
$$PWD/ASTParent.cpp \
$$PWD/GenTemplateInstance.cpp \
$$PWD/DeprecatedGenTemplateInstance.cpp \
$$PWD/FindUsages.cpp \
$$PWD/CheckUndefinedSymbols.cpp \
$$PWD/DependencyTable.cpp \
......
......@@ -15,7 +15,7 @@
#include <Names.h>
#include <Literals.h>
#include <DiagnosticClient.h>
#include <GenTemplateInstance.h>
#include <DeprecatedGenTemplateInstance.h>
#include <Overview.h>
#include <ExpressionUnderCursor.h>
#include <Names.h>
......@@ -436,7 +436,7 @@ void tst_Semantic::template_instance_1()
FullySpecifiedType templArgs[] = { control.integerType(IntegerType::Int) };
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;
oo.setShowReturnTypes(true);
......
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