diff --git a/src/actypes.d b/src/actypes.d index 01ee93e..9e2e914 100644 --- a/src/actypes.d +++ b/src/actypes.d @@ -547,18 +547,18 @@ static this() STRING_LITERAL_SYMBOL_NAME = internString("*string"); WSTRING_LITERAL_SYMBOL_NAME = internString("*wstring"); - auto bool_ = allocate!ACSymbol(Mallocator.it, internString("bool"), CompletionKind.keyword); - auto int_ = allocate!ACSymbol(Mallocator.it, internString("int"), CompletionKind.keyword); - auto long_ = allocate!ACSymbol(Mallocator.it, internString("long"), CompletionKind.keyword); - auto byte_ = allocate!ACSymbol(Mallocator.it, internString("byte"), CompletionKind.keyword); - auto char_ = allocate!ACSymbol(Mallocator.it, internString("char"), CompletionKind.keyword); - auto dchar_ = allocate!ACSymbol(Mallocator.it, internString("dchar"), CompletionKind.keyword); - auto short_ = allocate!ACSymbol(Mallocator.it, internString("short"), CompletionKind.keyword); - auto ubyte_ = allocate!ACSymbol(Mallocator.it, internString("ubyte"), CompletionKind.keyword); - auto uint_ = allocate!ACSymbol(Mallocator.it, internString("uint"), CompletionKind.keyword); - auto ulong_ = allocate!ACSymbol(Mallocator.it, internString("ulong"), CompletionKind.keyword); - auto ushort_ = allocate!ACSymbol(Mallocator.it, internString("ushort"), CompletionKind.keyword); - auto wchar_ = allocate!ACSymbol(Mallocator.it, internString("wchar"), CompletionKind.keyword); + auto bool_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[13], CompletionKind.keyword); + auto int_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[0], CompletionKind.keyword); + auto long_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[8], CompletionKind.keyword); + auto byte_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[19], CompletionKind.keyword); + auto char_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[10], CompletionKind.keyword); + auto dchar_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[12], CompletionKind.keyword); + auto short_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[6], CompletionKind.keyword); + auto ubyte_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[20], CompletionKind.keyword); + auto uint_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[1], CompletionKind.keyword); + auto ulong_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[9], CompletionKind.keyword); + auto ushort_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[7], CompletionKind.keyword); + auto wchar_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[11], CompletionKind.keyword); auto alignof_ = allocate!ACSymbol(Mallocator.it, internString("alignof"), CompletionKind.keyword); auto mangleof_ = allocate!ACSymbol(Mallocator.it, internString("mangleof"), CompletionKind.keyword); @@ -619,17 +619,17 @@ static this() s.parts.insert(init); } - auto cdouble_ = allocate!ACSymbol(Mallocator.it, internString("cdouble"), CompletionKind.keyword); - auto cent_ = allocate!ACSymbol(Mallocator.it, internString("cent"), CompletionKind.keyword); - auto cfloat_ = allocate!ACSymbol(Mallocator.it, internString("cfloat"), CompletionKind.keyword); - auto creal_ = allocate!ACSymbol(Mallocator.it, internString("creal"), CompletionKind.keyword); - auto double_ = allocate!ACSymbol(Mallocator.it, internString("double"), CompletionKind.keyword); - auto float_ = allocate!ACSymbol(Mallocator.it, internString("float"), CompletionKind.keyword); - auto idouble_ = allocate!ACSymbol(Mallocator.it, internString("idouble"), CompletionKind.keyword); - auto ifloat_ = allocate!ACSymbol(Mallocator.it, internString("ifloat"), CompletionKind.keyword); - auto ireal_ = allocate!ACSymbol(Mallocator.it, internString("ireal"), CompletionKind.keyword); - auto real_ = allocate!ACSymbol(Mallocator.it, internString("real"), CompletionKind.keyword); - auto ucent_ = allocate!ACSymbol(Mallocator.it, internString("ucent"), CompletionKind.keyword); + auto cdouble_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[21], CompletionKind.keyword); + auto cent_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[15], CompletionKind.keyword); + auto cfloat_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[22], CompletionKind.keyword); + auto creal_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[23], CompletionKind.keyword); + auto double_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[2], CompletionKind.keyword); + auto float_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[4], CompletionKind.keyword); + auto idouble_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[3], CompletionKind.keyword); + auto ifloat_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[5], CompletionKind.keyword); + auto ireal_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[18], CompletionKind.keyword); + auto real_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[17], CompletionKind.keyword); + auto ucent_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[16], CompletionKind.keyword); ACSymbol*[11] floatTypeArray; floatTypeArray[0] = cdouble_; @@ -689,7 +689,7 @@ static this() ifloat_.parts.insert(allocate!ACSymbol(Mallocator.it, internString("re"), CompletionKind.keyword, float_)); idouble_.parts.insert(allocate!ACSymbol(Mallocator.it, internString("re"), CompletionKind.keyword, double_)); - auto void_ = allocate!ACSymbol(Mallocator.it, internString("void"), CompletionKind.keyword); + auto void_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[14], CompletionKind.keyword); builtinSymbols.insert(bool_); bool_.type = bool_; diff --git a/src/conversion/first.d b/src/conversion/first.d index 3dc3db2..f1447ed 100644 --- a/src/conversion/first.d +++ b/src/conversion/first.d @@ -870,12 +870,19 @@ class InitializerVisitor : ASTVisitor semanticSymbol.initializer.insert(internString("[]")); } - override void visit(const ArgumentList) {} - - override void visit(const Expression initializer) + override void visit(const Initializer initializer) { on = true; initializer.accept(this); + on = false; + } + + override void visit(const ArgumentList) {} + + override void visit(const Expression expression) + { + on = true; + expression.accept(this); if (appendForeach) semanticSymbol.initializer.insert(internString("foreach")); on = false; diff --git a/src/conversion/second.d b/src/conversion/second.d index b6f6fe7..ef358f6 100644 --- a/src/conversion/second.d +++ b/src/conversion/second.d @@ -54,8 +54,8 @@ public: */ void run() { - rootSymbol.acSymbol.parts.insert(builtinSymbols[]); assignToScopes(rootSymbol.acSymbol); + moduleScope.symbols.insert(builtinSymbols[]); resolveImports(moduleScope); } diff --git a/src/conversion/third.d b/src/conversion/third.d index 3e22f75..b16f3b9 100644 --- a/src/conversion/third.d +++ b/src/conversion/third.d @@ -224,6 +224,7 @@ private: slice.popFront(); literal = false; } + immutable string leftmostType = literal ? slice.front[1 .. $] : slice.front; auto symbols = moduleScope.getSymbolsByNameAndCursor(internString( literal ? slice.front[1 .. $] : slice.front), location); diff --git a/tests/tc006/expected1.txt b/tests/tc006/expected1.txt new file mode 100644 index 0000000..9a132a4 --- /dev/null +++ b/tests/tc006/expected1.txt @@ -0,0 +1,8 @@ +identifiers +alignof k +init k +mangleof k +max k +min k +sizeof k +stringof k diff --git a/tests/tc006/expected2.txt b/tests/tc006/expected2.txt new file mode 100644 index 0000000..1f0d82d --- /dev/null +++ b/tests/tc006/expected2.txt @@ -0,0 +1,9 @@ +identifiers +alignof k +init k +mangleof k +sizeof k +stringof k +tupleof k +x v +y v diff --git a/tests/tc006/expected3.txt b/tests/tc006/expected3.txt new file mode 100644 index 0000000..9a132a4 --- /dev/null +++ b/tests/tc006/expected3.txt @@ -0,0 +1,8 @@ +identifiers +alignof k +init k +mangleof k +max k +min k +sizeof k +stringof k diff --git a/tests/tc006/expected4.txt b/tests/tc006/expected4.txt new file mode 100644 index 0000000..1f0d82d --- /dev/null +++ b/tests/tc006/expected4.txt @@ -0,0 +1,9 @@ +identifiers +alignof k +init k +mangleof k +sizeof k +stringof k +tupleof k +x v +y v diff --git a/tests/tc006/file.d b/tests/tc006/file.d new file mode 100644 index 0000000..458ba4a --- /dev/null +++ b/tests/tc006/file.d @@ -0,0 +1,23 @@ +struct S { int x; int y; } + +S doStuff(int x) { return S(); } + +void main(string[] args) +{ + auto a = 10; + auto b = S(1, 2); + int c = 4; + auto d = doStuff(); + { + a. + } + { + b. + } + { + c. + } + { + d. + } +} diff --git a/tests/tc006/run.sh b/tests/tc006/run.sh new file mode 100755 index 0000000..75b5e43 --- /dev/null +++ b/tests/tc006/run.sh @@ -0,0 +1,14 @@ +set -e +set -u + +dcd-client file.d -c162 > actual1.txt +diff actual1.txt expected1.txt + +dcd-client file.d -c173 > actual2.txt +diff actual2.txt expected2.txt + +dcd-client file.d -c184 > actual3.txt +diff actual3.txt expected3.txt + +dcd-client file.d -c195 > actual4.txt +diff actual4.txt expected4.txt