upgrade libdparse to 0.23.0

This commit is contained in:
WebFreak001 2023-05-17 20:51:03 +02:00 committed by Jan Jurzitza
parent 911ce077a5
commit eead318246
6 changed files with 28 additions and 15 deletions

View File

@ -6,7 +6,7 @@
"targetPath": "build", "targetPath": "build",
"targetType": "library", "targetType": "library",
"dependencies": { "dependencies": {
"libdparse": ">=0.20.0 <1.0.0", "libdparse": ">=0.23.0 <1.0.0",
"emsi_containers": "~>0.9.0" "emsi_containers": "~>0.9.0"
} }
} }

View File

@ -723,20 +723,20 @@ final class FirstPass : ASTVisitor
override void visit(const IfStatement ifs) override void visit(const IfStatement ifs)
{ {
if (ifs.identifier != tok!"" && ifs.thenStatement) if (ifs.condition && ifs.condition.identifier != tok!"" && ifs.thenStatement)
{ {
pushScope(ifs.thenStatement.startLocation, ifs.thenStatement.endLocation); pushScope(ifs.thenStatement.startLocation, ifs.thenStatement.endLocation);
scope(exit) popScope(); scope(exit) popScope();
SemanticSymbol* symbol = allocateSemanticSymbol(ifs.identifier.text, SemanticSymbol* symbol = allocateSemanticSymbol(ifs.condition.identifier.text,
CompletionKind.variableName, symbolFile, ifs.identifier.index); CompletionKind.variableName, symbolFile, ifs.condition.identifier.index);
if (ifs.type !is null) if (ifs.condition !is null && ifs.condition.type !is null)
addTypeToLookups(symbol.typeLookups, ifs.type); addTypeToLookups(symbol.typeLookups, ifs.condition.type);
symbol.parent = currentSymbol; symbol.parent = currentSymbol;
currentSymbol.addChild(symbol, true); currentSymbol.addChild(symbol, true);
currentScope.addSymbol(symbol.acSymbol, true); currentScope.addSymbol(symbol.acSymbol, true);
if (symbol.typeLookups.empty && ifs.expression !is null) if (symbol.typeLookups.empty && ifs.condition !is null && ifs.condition.expression !is null)
populateInitializer(symbol, ifs.expression, false); populateInitializer(symbol, ifs.condition.expression, false);
} }
ifs.accept(this); ifs.accept(this);
} }
@ -1125,6 +1125,9 @@ private:
auto lookup = TypeLookupsAllocator.instance.make!TypeLookup(TypeLookupKind.initializer); auto lookup = TypeLookupsAllocator.instance.make!TypeLookup(TypeLookupKind.initializer);
scope visitor = new InitializerVisitor(lookup, appendForeach, this); scope visitor = new InitializerVisitor(lookup, appendForeach, this);
symbol.typeLookups.insert(lookup); symbol.typeLookups.insert(lookup);
static if (is(T == typeof(feExpression)))
visitor.dynamicDispatch(initializer);
else
visitor.visit(initializer); visitor.visit(initializer);
} }
@ -1395,6 +1398,7 @@ class InitializerVisitor : ASTVisitor
} }
alias visit = ASTVisitor.visit; alias visit = ASTVisitor.visit;
alias dynamicDispatch = ASTVisitor.dynamicDispatch;
override void visit(const FunctionLiteralExpression exp) override void visit(const FunctionLiteralExpression exp)
{ {
@ -1476,7 +1480,7 @@ class InitializerVisitor : ASTVisitor
override void visit(const IndexExpression expr) override void visit(const IndexExpression expr)
{ {
expr.unaryExpression.accept(this); dynamicDispatch(expr.unaryExpression);
foreach (index; expr.indexes) foreach (index; expr.indexes)
if (index.high is null) if (index.high is null)
lookup.breadcrumbs.insert(ARRAY_SYMBOL_NAME); lookup.breadcrumbs.insert(ARRAY_SYMBOL_NAME);
@ -1568,10 +1572,10 @@ class InitializerVisitor : ASTVisitor
on = false; on = false;
} }
override void visit(const ExpressionNode expression) override void dynamicDispatch(const ExpressionNode expression)
{ {
on = true; on = true;
expression.accept(this); super.dynamicDispatch(expression);
if (appendForeach) if (appendForeach)
lookup.breadcrumbs.insert(internString("foreach")); lookup.breadcrumbs.insert(internString("foreach"));
on = false; on = false;

View File

@ -335,6 +335,8 @@ unittest
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S")); DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b")); DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
assert(S); assert(S);
assert(b);
assert(b.type);
assert(b.type is S); assert(b.type is S);
} }
{ {
@ -343,6 +345,8 @@ unittest
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S")); DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b")); DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
assert(S); assert(S);
assert(b);
assert(b.type);
assert(b.type is S); assert(b.type is S);
} }
{ {
@ -351,6 +355,8 @@ unittest
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S")); DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b")); DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
assert(S); assert(S);
assert(b);
assert(b.type);
assert(b.type.type is S); assert(b.type.type is S);
} }
{ {
@ -359,6 +365,8 @@ unittest
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S")); DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b")); DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
assert(S); assert(S);
assert(b);
assert(b.type);
assert(b.type.name == ARRAY_SYMBOL_NAME); assert(b.type.name == ARRAY_SYMBOL_NAME);
assert(b.type.type is S); assert(b.type.type is S);
} }
@ -368,6 +376,7 @@ unittest
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S")); DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b")); DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
assert(S); assert(S);
assert(b);
assert(b.type is S); assert(b.type is S);
} }
} }

View File

@ -8,7 +8,7 @@
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
":dsymbol": "*", ":dsymbol": "*",
"libdparse": ">=0.20.0 <0.23.0", "libdparse": ">=0.23.0 <0.24.0",
":common": "*", ":common": "*",
"emsi_containers": "~>0.9.0" "emsi_containers": "~>0.9.0"
}, },

View File

@ -3,7 +3,7 @@
"versions": { "versions": {
"dsymbol": "0.14.1", "dsymbol": "0.14.1",
"emsi_containers": "0.9.0", "emsi_containers": "0.9.0",
"libdparse": "0.22.0", "libdparse": "0.23.0",
"msgpack-d": "1.0.4", "msgpack-d": "1.0.4",
"stdx-allocator": "2.77.5" "stdx-allocator": "2.77.5"
} }

@ -1 +1 @@
Subproject commit 98bf0f4166578717e0b78472ff5054d6f918e797 Subproject commit 86c9bf44c96e1666eb175c749cc26f62c2008979