Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
vczh committed Feb 17, 2020
1 parent a2987f0 commit c83c46a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Tools/CppDoc/Core/Source/Ast_Evaluate_ToTsys_IdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace symbol_totsys_impl
return;
case symbol_component::SymbolKind::GenericTypeArgument:
{
auto argumentKey = EvaluateGenericArgumentSymbol(symbol);
auto argumentKey = GetTemplateArgumentKey(symbol, pa.tsys.Obj());
ITsys* replacedType = nullptr;
if(pa.TryGetReplacedGenericArg(argumentKey, replacedType))
{
Expand Down
1 change: 1 addition & 0 deletions Tools/CppDoc/Core/Source/Ast_Resolving.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ namespace symbol_type_resolving

extern Ptr<TemplateSpec> GetTemplateSpecFromSymbol(Symbol* symbol);
extern ITsys* GetTemplateArgumentKey(const TemplateSpec::Argument& argument, ITsysAlloc* tsys);
extern ITsys* GetTemplateArgumentKey(Symbol* argumentSymbol, ITsysAlloc* tsys);
extern void CreateGenericFunctionHeader(const ParsingArguments& pa, Symbol* declSymbol, ITsys* parentDeclType, Ptr<TemplateSpec> spec, TypeTsysList& params, TsysGenericFunction& genericFunction);
extern void ResolveGenericParameters(
const ParsingArguments& invokerPa,
Expand Down
19 changes: 18 additions & 1 deletion Tools/CppDoc/Core/Source/Ast_Resolving_Generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace symbol_type_resolving
}

/***********************************************************************
CreateGenericFunctionHeader: Calculate enough information to create a generic function type
GetTemplateArgumentKey: Get an ITsys* for TsysGenericFunction keys
***********************************************************************/

ITsys* GetTemplateArgumentKey(const TemplateSpec::Argument& argument, ITsysAlloc* tsys)
Expand All @@ -47,6 +47,23 @@ namespace symbol_type_resolving
}
}

ITsys* GetTemplateArgumentKey(Symbol* argumentSymbol, ITsysAlloc* tsys)
{
switch (argumentSymbol->kind)
{
case symbol_component::SymbolKind::GenericTypeArgument:
return EvaluateGenericArgumentSymbol(argumentSymbol);
case symbol_component::SymbolKind::GenericValueArgument:
return tsys->DeclOf(argumentSymbol);
default:
throw TypeCheckerException();
}
}

/***********************************************************************
CreateGenericFunctionHeader: Calculate enough information to create a generic function type
***********************************************************************/

void CreateGenericFunctionHeader(const ParsingArguments& pa, Symbol* declSymbol, ITsys* parentDeclType, Ptr<TemplateSpec> spec, TypeTsysList& params, TsysGenericFunction& genericFunction)
{
if (!declSymbol) throw TypeCheckerException();
Expand Down
4 changes: 2 additions & 2 deletions Tools/CppDoc/Core/Source/Ast_Resolving_IFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace symbol_type_resolving
if (auto idType = dynamic_cast<IdType*>(involvedTypes[j]))
{
auto patternSymbol = idType->resolving->resolvedSymbols[0];
auto pattern = EvaluateGenericArgumentSymbol(patternSymbol);
auto pattern = GetTemplateArgumentKey(patternSymbol, pa.tsys.Obj());
if (patternSymbol->ellipsis)
{
callback(patternSymbol, pattern);
Expand All @@ -73,7 +73,7 @@ namespace symbol_type_resolving
if (auto idExpr = dynamic_cast<IdExpr*>(involvedExprs[j]))
{
auto patternSymbol = idExpr->resolving->resolvedSymbols[0];
auto pattern = pa.tsys->DeclOf(patternSymbol);
auto pattern = GetTemplateArgumentKey(patternSymbol, pa.tsys.Obj());
if (patternSymbol->ellipsis)
{
callback(patternSymbol, pattern);
Expand Down
13 changes: 4 additions & 9 deletions Tools/CppDoc/Core/Source/Ast_Resolving_IFT_CollectFreeTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,20 @@ namespace symbol_type_resolving
{
if (self->resolving && self->resolving->resolvedSymbols.Count() == 1)
{
auto symbol = self->resolving->resolvedSymbols[0];
if (freeTypeSymbols.Contains(symbol))
auto patternSymbol = self->resolving->resolvedSymbols[0];
if (freeTypeSymbols.Contains(patternSymbol))
{
involved = true;
involvedTypes.Add(self);
}
else if(includeParentDeclArguments)
{
switch (symbol->kind)
switch (patternSymbol->kind)
{
case symbol_component::SymbolKind::GenericTypeArgument:
case symbol_component::SymbolKind::GenericValueArgument:
{
// consistent with GetTemplateArgumentKey
auto pattern = symbol->kind ==
symbol_component::SymbolKind::GenericTypeArgument
? EvaluateGenericArgumentSymbol(symbol)
: pa.tsys->DeclOf(symbol)
;
auto pattern = GetTemplateArgumentKey(patternSymbol, pa.tsys.Obj());
ITsys* patternValue = nullptr;
if (pa.TryGetReplacedGenericArg(pattern, patternValue))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ namespace symbol_type_resolving
{
if (!involvedExprs.Contains(expr.Obj())) return;
auto idExpr = expr.Cast<IdExpr>();
auto symbol = idExpr->resolving->resolvedSymbols[0];
auto& outputContext = symbol->ellipsis ? variadicContext : taContext;
auto patternSymbol = idExpr->resolving->resolvedSymbols[0];
auto& outputContext = patternSymbol->ellipsis ? variadicContext : taContext;

// consistent with GetTemplateArgumentKey
auto pattern = pa.tsys->DeclOf(symbol);
auto pattern = GetTemplateArgumentKey(patternSymbol, pa.tsys.Obj());
SetInferredResult(outputContext, pattern, nullptr);
}

Expand Down Expand Up @@ -266,7 +266,7 @@ namespace symbol_type_resolving
auto& outputContext = patternSymbol->ellipsis ? variadicContext : taContext;

// consistent with GetTemplateArgumentKey
auto pattern = EvaluateGenericArgumentSymbol(patternSymbol);
auto pattern = GetTemplateArgumentKey(patternSymbol, pa.tsys.Obj());

switch (patternSymbol->kind)
{
Expand Down

0 comments on commit c83c46a

Please sign in to comment.