Saving progress + debugging bits on purpose

This commit is contained in:
ryuukk 2023-10-05 06:58:47 +02:00
parent 978c7a1bfa
commit 05c8e4fced
2 changed files with 59 additions and 3 deletions

View File

@ -253,7 +253,9 @@ final class FirstPass : ASTVisitor
{ {
processIdentifierOrTemplate(symbol, lookup, ctx, current, tip.identifierOrTemplateInstance); processIdentifierOrTemplate(symbol, lookup, ctx, current, tip.identifierOrTemplateInstance);
if (current) if (current)
{
current.calltip = buildCalltip(tip.identifierOrTemplateInstance.tokens); current.calltip = buildCalltip(tip.identifierOrTemplateInstance.tokens);
}
} }
if (tip.typeIdentifierPart) if (tip.typeIdentifierPart)
@ -297,6 +299,16 @@ final class FirstPass : ASTVisitor
if (part.typeIdentifierPart.identifierOrTemplateInstance) if (part.typeIdentifierPart.identifierOrTemplateInstance)
processIdentifierOrTemplate(symbol, lookup, ctx, newArg, part.typeIdentifierPart.identifierOrTemplateInstance); processIdentifierOrTemplate(symbol, lookup, ctx, newArg, part.typeIdentifierPart.identifierOrTemplateInstance);
} }
foreach(suffix; targ.type.typeSuffixes)
{
if (suffix.type)
current.calltip ~= "[.]";
else if (suffix.array)
current.calltip ~= "[]";
else if (suffix.star != tok!"")
current.calltip ~= "*";
}
} }
} }
else if (targs.templateSingleArgument) else if (targs.templateSingleArgument)
@ -371,6 +383,8 @@ final class FirstPass : ASTVisitor
calltip ~= "]"; calltip ~= "]";
else if (tk == tok!",") else if (tk == tok!",")
calltip ~= ","; calltip ~= ",";
else if (tk == tok!"*")
calltip ~= "*";
else if (tk == tok!"") else if (tk == tok!"")
calltip ~= " "; calltip ~= " ";
else else
@ -485,6 +499,16 @@ final class FirstPass : ASTVisitor
if (typeIdentifierPart.identifierOrTemplateInstance) if (typeIdentifierPart.identifierOrTemplateInstance)
lookup.ctx.calltip = buildCalltip(typeIdentifierPart.identifierOrTemplateInstance.tokens); lookup.ctx.calltip = buildCalltip(typeIdentifierPart.identifierOrTemplateInstance.tokens);
foreach(suffix; dec.type.typeSuffixes)
{
if (suffix.type)
lookup.ctx.calltip ~= "[.]";
else if (suffix.array)
lookup.ctx.calltip ~= "[]";
else if (suffix.star != tok!"")
lookup.ctx.calltip ~= "*";
}
processTypeIdentifierPart(symbol, lookup, &lookup.ctx, lookup.ctx.root, typeIdentifierPart); processTypeIdentifierPart(symbol, lookup, &lookup.ctx, lookup.ctx.root, typeIdentifierPart);
} }
} }

View File

@ -62,6 +62,8 @@ void secondPass(SemanticSymbol* currentSymbol, Scope* moduleScope, ref ModuleCac
if (currentSymbol.acSymbol.type && currentSymbol.typeLookups.length > 0) if (currentSymbol.acSymbol.type && currentSymbol.typeLookups.length > 0)
{ {
foreach(lookup; currentSymbol.typeLookups[]) { foreach(lookup; currentSymbol.typeLookups[]) {
writeln("lookup: ", lookup.breadcrumbs[]);
if (lookup.ctx.root) if (lookup.ctx.root)
{ {
auto type = currentSymbol.acSymbol.type; auto type = currentSymbol.acSymbol.type;
@ -171,6 +173,14 @@ DSymbol* createTypeWithTemplateArgs(DSymbol* type, TypeLookup* lookup, VariableC
assert(type); assert(type);
DSymbol* newType = GCAllocator.instance.make!DSymbol("dummy", CompletionKind.dummy, null); DSymbol* newType = GCAllocator.instance.make!DSymbol("dummy", CompletionKind.dummy, null);
newType.name = ti ? istring(ti.calltip) : istring(lookup.ctx.calltip); newType.name = ti ? istring(ti.calltip) : istring(lookup.ctx.calltip);
// TODO: need to set the name in first.d
if (newType.name.length == 0)
newType.name = type.name;
writeln(" >>", type.name, " > ", newType.name, " ::", ti );
writeln(" >> args: ", ti.args);
newType.kind = type.kind; newType.kind = type.kind;
newType.qualifier = type.qualifier; newType.qualifier = type.qualifier;
newType.protection = type.protection; newType.protection = type.protection;
@ -189,10 +199,12 @@ DSymbol* createTypeWithTemplateArgs(DSymbol* type, TypeLookup* lookup, VariableC
scope(exit) count++; scope(exit) count++;
if (count >= ti.args.length) if (count >= ti.args.length)
{ {
// warning("too many T for args available, investigate"); writeln("too many T for args available, investigate");
continue; continue;
} }
auto key = part.name; auto key = part.name;
writeln(" check: ", key);
DSymbol* first; DSymbol* first;
bool isBuiltin; bool isBuiltin;
foreach(i, crumb; ti.args[count].chain) foreach(i, crumb; ti.args[count].chain)
@ -219,20 +231,34 @@ DSymbol* createTypeWithTemplateArgs(DSymbol* type, TypeLookup* lookup, VariableC
auto result = moduleScope.getSymbolsAtGlobalScope(istring(argName)); auto result = moduleScope.getSymbolsAtGlobalScope(istring(argName));
if (result.length == 0) if (result.length == 0)
{ {
writeln(" modulescope: symbol not found: ", argName);
break; break;
} }
first = result[0]; first = result[0];
writeln(" modulescope: symbol found: ", argName, " -> ", first.name);
} }
else else
{
first = first.getFirstPartNamed(istring(argName)); first = first.getFirstPartNamed(istring(argName));
if (first)
writeln(" symbol found: ", argName, " -> ", first.name);
else
writeln(" symbol not found: ", argName);
}
} }
if (first is null) if (first is null)
continue; continue;
writeln(">> ok");
auto ca = ti.args[count]; auto ca = ti.args[count];
if (ca.chain.length > 0) if (ca.chain.length > 0)
mapping[key] = isBuiltin ? first : createTypeWithTemplateArgs(first, lookup, ca, cache, moduleScope, depth, null); {
auto stomap = isBuiltin ? first : createTypeWithTemplateArgs(first, lookup, ca, cache, moduleScope, depth, null);
mapping[key] = stomap;
writeln(" mapping[",key,"] -> ", stomap.name);
}
} }
} }
} }
@ -336,6 +362,12 @@ void resolveTemplate(DSymbol* variableSym, DSymbol* type, TypeLookup* lookup, Va
DSymbol* newType = createTypeWithTemplateArgs(type, lookup, current, cache, moduleScope, depth, mapping); DSymbol* newType = createTypeWithTemplateArgs(type, lookup, current, cache, moduleScope, depth, mapping);
writeln(">>", variableSym.name, " > ", newType.name); writeln(">>", variableSym.name, " > ", newType.name);
if (depth == 1)
{
newType.name = istring(lookup.ctx.calltip);
}
variableSym.type = newType; variableSym.type = newType;
variableSym.ownType = true; variableSym.ownType = true;
} }
@ -517,7 +549,7 @@ do
return; return;
} }
if (lastSuffix !is null) if (lastSuffix !is null && lastSuffix.qualifier == SymbolQualifier.none)
{ {
assert(suffix !is null); assert(suffix !is null);
typeSwap(currentSymbol); typeSwap(currentSymbol);