From 7cbe5289f76c6472390a9a44b4775b63682346ac Mon Sep 17 00:00:00 2001 From: ryuukk Date: Wed, 9 Aug 2023 18:51:26 +0200 Subject: [PATCH] Apply some code review suggestions --- dsymbol/src/dsymbol/conversion/first.d | 11 +++++++---- dsymbol/src/dsymbol/conversion/second.d | 3 +-- dsymbol/src/dsymbol/type_lookup.d | 2 -- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dsymbol/src/dsymbol/conversion/first.d b/dsymbol/src/dsymbol/conversion/first.d index af012fc..ba3ec6e 100644 --- a/dsymbol/src/dsymbol/conversion/first.d +++ b/dsymbol/src/dsymbol/conversion/first.d @@ -254,6 +254,8 @@ final class FirstPass : ASTVisitor if (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) @@ -262,6 +264,7 @@ final class FirstPass : ASTVisitor { foreach(i, targ; targs.namedTemplateArgumentList.items) { + // TODO: handle targ.assignExpression if (targ.type 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; auto builtInName = getBuiltinTypeName(targ.type.type2.builtinType); auto newArg = GCAllocator.instance.make!(VariableContext.TypeInstance)(); - newArg.parent = current; newArg.chain ~= builtInName; current.args ~= newArg; continue; } auto newArg = GCAllocator.instance.make!(VariableContext.TypeInstance)(); - newArg.parent = current; current.args ~= newArg; if (part.identifierOrTemplateInstance) @@ -296,7 +297,6 @@ final class FirstPass : ASTVisitor { auto singleArg = targs.templateSingleArgument; auto arg = GCAllocator.instance.make!(VariableContext.TypeInstance)(); - arg.parent = current; arg.name = singleArg.token.text; arg.chain ~= arg.name; current.args ~= arg; @@ -318,6 +318,7 @@ final class FirstPass : ASTVisitor buildChainTemplateOrIdentifier(symbol, lookup, ctx, tip.identifierOrTemplateInstance); if (tip.typeIdentifierPart) buildChain(symbol, lookup, ctx, tip.typeIdentifierPart); + // TODO: handle `tip.indexer` } void buildChainTemplateOrIdentifier(SemanticSymbol* symbol, TypeLookup* lookup, VariableContext* ctx, IdentifierOrTemplateInstance iot) @@ -330,10 +331,12 @@ final class FirstPass : ASTVisitor { if (iot.templateInstance.identifier != tok!"") 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) { diff --git a/dsymbol/src/dsymbol/conversion/second.d b/dsymbol/src/dsymbol/conversion/second.d index 0b615c1..96c2f2b 100644 --- a/dsymbol/src/dsymbol/conversion/second.d +++ b/dsymbol/src/dsymbol/conversion/second.d @@ -197,8 +197,7 @@ DSymbol* createTypeWithTemplateArgs(DSymbol* type, TypeLookup* lookup, VariableC auto argName = crumb; if (i == 0) { - if (m) - if (key in m) + if (m && key in m) { argName = m[key].name; } diff --git a/dsymbol/src/dsymbol/type_lookup.d b/dsymbol/src/dsymbol/type_lookup.d index f7f79de..c417c53 100644 --- a/dsymbol/src/dsymbol/type_lookup.d +++ b/dsymbol/src/dsymbol/type_lookup.d @@ -48,8 +48,6 @@ struct VariableContext string[] chain; TypeInstance*[] args; string name; - TypeInstance* parent; } TypeInstance* root; - int num; } \ No newline at end of file