Properly build new array symbol

This commit is contained in:
ryuukk 2023-10-09 03:16:23 +02:00
parent 0471759b6c
commit 2f63d750ba
1 changed files with 21 additions and 4 deletions

View File

@ -299,7 +299,7 @@ DSymbol* createTypeWithTemplateArgs(DSymbol* type, TypeLookup* lookup, VariableC
} }
} }
writeln(""); writeln("-");
assert(newType); assert(newType);
string[] T_names; string[] T_names;
@ -309,7 +309,8 @@ DSymbol* createTypeWithTemplateArgs(DSymbol* type, TypeLookup* lookup, VariableC
{ {
T_names ~= part.name; T_names ~= part.name;
} }
else if (part.type && part.type.kind == CompletionKind.typeTmpParam) else
if (part.type && part.type.kind == CompletionKind.typeTmpParam)
{ {
print_tab(depth); writeln("part: ", part.name,": ", part.type.name); print_tab(depth); writeln("part: ", part.name,": ", part.type.name);
@ -342,18 +343,34 @@ DSymbol* createTypeWithTemplateArgs(DSymbol* type, TypeLookup* lookup, VariableC
print_tab(depth); writeln("array: ", part.name,": ", arrTypeTSymbol.name,"[]"); print_tab(depth); writeln("array: ", part.name,": ", arrTypeTSymbol.name,"[]");
DSymbol* newPart = GCAllocator.instance.make!DSymbol(part.name, part.kind, null);
newPart.qualifier = part.qualifier;
newPart.protection = part.protection;
newPart.symbolFile = part.symbolFile;
newPart.doc = part.doc;
newPart.callTip = part.callTip;
// create new array shit
if (arrTypeTSymbol.name in mapping) if (arrTypeTSymbol.name in mapping)
{ {
auto result = mapping[arrTypeTSymbol.name]; auto result = mapping[arrTypeTSymbol.name];
arrSymbol.type = result;
print_tab(depth); writeln(" ", arrTypeTSymbol.name, " =>: ", result.name); print_tab(depth); writeln(" ", arrTypeTSymbol.name, " =>: ", result.name);
auto newarr = GCAllocator.instance.make!DSymbol(arrSymbol.name , arrSymbol.kind, result);
newarr.ownType = false;
newPart.type = newarr;
newPart.ownType = true;
} }
newType.addChild(part, false); newType.addChild(newPart, false);
} }
else else
{ {
print_tab(depth); writeln("missing part: ", part.name,": ", part.type);
// BUG: doing it recursively messes with the mapping // BUG: doing it recursively messes with the mapping
// i need to debug this and figure out perhaps a better way to do this stuff // i need to debug this and figure out perhaps a better way to do this stuff
// maybe move the VariableContext to the symbol directly // maybe move the VariableContext to the symbol directly