Apply some code review suggestions
This commit is contained in:
parent
5e809b1d4a
commit
7cbe5289f7
|
|
@ -254,6 +254,8 @@ final class FirstPass : ASTVisitor
|
||||||
|
|
||||||
if (tip.typeIdentifierPart)
|
if (tip.typeIdentifierPart)
|
||||||
processTypeIdentifierPart(symbol, lookup, ctx, current, tip.typeIdentifierPart);
|
processTypeIdentifierPart(symbol, lookup, ctx, current, tip.typeIdentifierPart);
|
||||||
|
|
||||||
|
// TODO: handle `tip.dot` and `tip.indexer`
|
||||||
}
|
}
|
||||||
|
|
||||||
void processTemplateArguments(SemanticSymbol* symbol, TypeLookup* lookup, VariableContext* ctx, VariableContext.TypeInstance* current, TemplateArguments targs)
|
void processTemplateArguments(SemanticSymbol* symbol, TypeLookup* lookup, VariableContext* ctx, VariableContext.TypeInstance* current, TemplateArguments targs)
|
||||||
|
|
@ -262,6 +264,7 @@ final class FirstPass : ASTVisitor
|
||||||
{
|
{
|
||||||
foreach(i, targ; targs.namedTemplateArgumentList.items)
|
foreach(i, targ; targs.namedTemplateArgumentList.items)
|
||||||
{
|
{
|
||||||
|
// TODO: handle targ.assignExpression
|
||||||
if (targ.type is null) continue;
|
if (targ.type is null) continue;
|
||||||
if (targ.type.type2 is null) continue;
|
if (targ.type.type2 is null) continue;
|
||||||
|
|
||||||
|
|
@ -271,14 +274,12 @@ final class FirstPass : ASTVisitor
|
||||||
if (targ.type.type2.builtinType == tok!"") continue;
|
if (targ.type.type2.builtinType == tok!"") continue;
|
||||||
auto builtInName = getBuiltinTypeName(targ.type.type2.builtinType);
|
auto builtInName = getBuiltinTypeName(targ.type.type2.builtinType);
|
||||||
auto newArg = GCAllocator.instance.make!(VariableContext.TypeInstance)();
|
auto newArg = GCAllocator.instance.make!(VariableContext.TypeInstance)();
|
||||||
newArg.parent = current;
|
|
||||||
newArg.chain ~= builtInName;
|
newArg.chain ~= builtInName;
|
||||||
current.args ~= newArg;
|
current.args ~= newArg;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto newArg = GCAllocator.instance.make!(VariableContext.TypeInstance)();
|
auto newArg = GCAllocator.instance.make!(VariableContext.TypeInstance)();
|
||||||
newArg.parent = current;
|
|
||||||
current.args ~= newArg;
|
current.args ~= newArg;
|
||||||
|
|
||||||
if (part.identifierOrTemplateInstance)
|
if (part.identifierOrTemplateInstance)
|
||||||
|
|
@ -296,7 +297,6 @@ final class FirstPass : ASTVisitor
|
||||||
{
|
{
|
||||||
auto singleArg = targs.templateSingleArgument;
|
auto singleArg = targs.templateSingleArgument;
|
||||||
auto arg = GCAllocator.instance.make!(VariableContext.TypeInstance)();
|
auto arg = GCAllocator.instance.make!(VariableContext.TypeInstance)();
|
||||||
arg.parent = current;
|
|
||||||
arg.name = singleArg.token.text;
|
arg.name = singleArg.token.text;
|
||||||
arg.chain ~= arg.name;
|
arg.chain ~= arg.name;
|
||||||
current.args ~= arg;
|
current.args ~= arg;
|
||||||
|
|
@ -318,6 +318,7 @@ final class FirstPass : ASTVisitor
|
||||||
buildChainTemplateOrIdentifier(symbol, lookup, ctx, tip.identifierOrTemplateInstance);
|
buildChainTemplateOrIdentifier(symbol, lookup, ctx, tip.identifierOrTemplateInstance);
|
||||||
if (tip.typeIdentifierPart)
|
if (tip.typeIdentifierPart)
|
||||||
buildChain(symbol, lookup, ctx, tip.typeIdentifierPart);
|
buildChain(symbol, lookup, ctx, tip.typeIdentifierPart);
|
||||||
|
// TODO: handle `tip.indexer`
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildChainTemplateOrIdentifier(SemanticSymbol* symbol, TypeLookup* lookup, VariableContext* ctx, IdentifierOrTemplateInstance iot)
|
void buildChainTemplateOrIdentifier(SemanticSymbol* symbol, TypeLookup* lookup, VariableContext* ctx, IdentifierOrTemplateInstance iot)
|
||||||
|
|
@ -330,10 +331,12 @@ final class FirstPass : ASTVisitor
|
||||||
{
|
{
|
||||||
if (iot.templateInstance.identifier != tok!"")
|
if (iot.templateInstance.identifier != tok!"")
|
||||||
lookup.breadcrumbs.insert(istring(iot.templateInstance.identifier.text));
|
lookup.breadcrumbs.insert(istring(iot.templateInstance.identifier.text));
|
||||||
|
|
||||||
|
// TODO: handle `iot.templateInstance.templateArguments`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void traverseUnaryExpression( SemanticSymbol* symbol, TypeLookup* lookup, VariableContext* ctx, UnaryExpression ue)
|
void traverseUnaryExpression(SemanticSymbol* symbol, TypeLookup* lookup, VariableContext* ctx, UnaryExpression ue)
|
||||||
{
|
{
|
||||||
if (PrimaryExpression pe = ue.primaryExpression)
|
if (PrimaryExpression pe = ue.primaryExpression)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -197,8 +197,7 @@ DSymbol* createTypeWithTemplateArgs(DSymbol* type, TypeLookup* lookup, VariableC
|
||||||
auto argName = crumb;
|
auto argName = crumb;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
if (m)
|
if (m && key in m)
|
||||||
if (key in m)
|
|
||||||
{
|
{
|
||||||
argName = m[key].name;
|
argName = m[key].name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,6 @@ struct VariableContext
|
||||||
string[] chain;
|
string[] chain;
|
||||||
TypeInstance*[] args;
|
TypeInstance*[] args;
|
||||||
string name;
|
string name;
|
||||||
TypeInstance* parent;
|
|
||||||
}
|
}
|
||||||
TypeInstance* root;
|
TypeInstance* root;
|
||||||
int num;
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue