Skip to content

Commit 682eca0

Browse files
authored
Merge pull request #75 from rainers/master
changes for Visual D 0.45.0-beta1
2 parents 1f9f2fb + 2d6b0ba commit 682eca0

30 files changed

+1479
-339
lines changed

CHANGES

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,3 +864,25 @@ Version history
864864
* bugzilla 17254: close and reopen completion box if results added
865865
* fix link to build log: replace spaces with %20
866866
* added VC project integration for VS2017
867+
868+
unreleased Version 0.45.0
869+
870+
* fixed Compile and Run/Debug if building through MS-COFF and not having VS selected in sc.ini
871+
* mago: fixed memory leaks that could also prohibit compilation due to PDB file still open
872+
* mago: add debugger options page to allow hiding internal locals and static members
873+
* cv2pdb: added support for AA display in mago
874+
* DParser: added support for function attributes @nogc and scope, align(expression)
875+
* added task list support for files loaded into the editor
876+
* read default DMD installation path from Visual D or DMD registry key, if not available in
877+
VS registry hive
878+
* new project option "Add import paths of project dependencies"
879+
* use generic file system tracking instead of compiler switch -deps=
880+
* fixed tracker.exe not found in VS2015 and VS2017
881+
* /MAPINFO: remove ancient options no longer supported by the MS linker
882+
* separated compile and link into two batches so compile skipped if only link inputs changed
883+
* fix crash when editing dub.json when part of a project
884+
* UCRT version detection: ignore directories that do not start with a digit (e.g. from DDK)
885+
* dependency monitoring: added option to specify files/folders to exclude from dependency check
886+
* mago: can now show registers in expressions
887+
* mago: show static members and base class with different icons
888+
* DParser: cache semantic results until next edit

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ dbuild15:
162162

163163
fake_dbuild15:
164164
if not exist msbuild\dbuild\obj\release-v15\nul md msbuild\dbuild\obj\release-v15
165+
if exist "$(PROGRAMFILES)\VisualD\msbuild\dbuild.15.0.dll" copy "$(PROGRAMFILES)\VisualD\msbuild\dbuild.15.0.dll" msbuild\dbuild\obj\release-v15
165166
if not exist msbuild\dbuild\obj\release-v15\dbuild.15.0.dll echo dummy >msbuild\dbuild\obj\release-v15\dbuild.15.0.dll
166167

167168
mago:

VERSION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define VERSION_MAJOR 0
2-
#define VERSION_MINOR 44
3-
#define VERSION_REVISION 2
4-
#define VERSION_BETA
5-
#define VERSION_BUILD 0
2+
#define VERSION_MINOR 45
3+
#define VERSION_REVISION 0
4+
#define VERSION_BETA -beta
5+
#define VERSION_BUILD 1

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ install:
6666
copy c:\projects\dm\bin\coffimplib.exe c:\projects\dmd2\windows\bin
6767
# Download & install Visual D
6868
- ps: |
69-
Start-FileDownload 'https://github.com/dlang/visuald/releases/download/v0.3.43/VisualD-v0.3.43.exe' -FileName 'VisualD-v0.3.43.exe'
70-
- .\VisualD-v0.3.43.exe /S
69+
Start-FileDownload 'https://github.com/dlang/visuald/releases/download/v0.44.2/VisualD-v0.44.2.exe' -FileName 'VisualD-v0.44.2.exe'
70+
- .\VisualD-v0.44.2.exe /S
7171
# configure DMD path
7272
- reg add "HKLM\SOFTWARE\Microsoft\VisualStudio\12.0\ToolsOptionsPages\Projects\Visual D Settings" /v DMDInstallDir /t REG_SZ /d c:\projects\dmd2 /reg:32 /f
7373
- reg add "HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\ToolsOptionsPages\Projects\Visual D Settings" /v DMDInstallDir /t REG_SZ /d c:\projects\dmd2 /reg:32 /f

c2d/ast.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,10 +1755,11 @@ class Statement : AST
17551755
break;
17561756

17571757
case Token.Default:
1758-
// treat as label, just skip and reparse
1758+
// treat as empty statement, though it should be a label
17591759
nextToken(tokIt);
17601760
checkToken(tokIt, Token.Colon);
1761-
goto L_reparse;
1761+
stmt = new Statement(type);
1762+
break;
17621763

17631764
case Token.Case:
17641765
// treat as statement, though it should be a label

c2d/c2d.visualdproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
<lib>1</lib>
211211
<subsystem>0</subsystem>
212212
<multiobj>0</multiobj>
213-
<singleFileCompilation>0</singleFileCompilation>
213+
<singleFileCompilation>3</singleFileCompilation>
214214
<oneobj>0</oneobj>
215215
<mscoff>0</mscoff>
216216
<trace>0</trace>
@@ -301,9 +301,9 @@
301301
<useStdLibPath>1</useStdLibPath>
302302
<cRuntime>1</cRuntime>
303303
<privatePhobos>0</privatePhobos>
304-
<additionalOptions />
304+
<additionalOptions>-of$(IntDir)\$(ProjectName).obj</additionalOptions>
305305
<preBuildCommand />
306-
<postBuildCommand />
306+
<postBuildCommand>dmd -lib $(IntDir)\$(ProjectName).obj -of$(OutDir)\$(ProjectName).lib</postBuildCommand>
307307
<filesToClean>*.obj</filesToClean>
308308
</Config>
309309
<Config name="Debug GDC" platform="Win32">

c2d/cpp2d.d

Lines changed: 121 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ static this()
564564

565565
string createModuleName(string filename)
566566
{
567+
string ext = extension(filename);
567568
filename = stripExtension(filename);
568569
filename = replace(filename, "\\", "/");
569570
string[] names = split(filename, "/");
@@ -586,6 +587,8 @@ string createModuleName(string filename)
586587
modname ~= '.';
587588
modname ~= safename;
588589
}
590+
if (ext != ".h" && ext != "")
591+
modname ~= "_" ~ ext[1 .. $];
589592
return modname;
590593
}
591594

@@ -606,13 +609,21 @@ string mapTokenText(Token tok)
606609
return tok.text;
607610
}
608611

609-
string createMappedTokenListText(TokenList tokList)
612+
string createMappedTokenListText(TokenList tokList, bool map)
610613
{
611-
string text;
614+
string text, prevtext;
612615
for(TokenIterator tokIt = tokList.begin(); !tokIt.atEnd(); ++tokIt)
613616
{
614617
Token tok = *tokIt;
615-
string mapped = mapTokenText(tok);
618+
string mapped = map ? mapTokenText(tok) : tok.text;
619+
if (mapped.length && prevtext.length)
620+
{
621+
char prevch = prevtext[$-1];
622+
char ch = mapped[0];
623+
if((isAlphaNum(ch) || ch == '_') && (isAlphaNum(prevch) || prevch == '_'))
624+
mapped = " " ~ mapped;
625+
}
626+
prevtext = mapped;
616627
text ~= tok.pretext ~ mapped;
617628
}
618629
return text;
@@ -1606,6 +1617,40 @@ void patchClassVarInit(Statement stmt)
16061617
}
16071618
}
16081619

1620+
void patchSwitchStatement(Statement swstmt)
1621+
{
1622+
ASTIterator swit = swstmt.children.begin() + 1; // skip expression
1623+
if (swit.atEnd())
1624+
return;
1625+
auto stmt = *swit; // compound statement
1626+
bool hasDefault = false;
1627+
if (stmt.children)
1628+
for(ASTIterator it = stmt.children.begin(); !it.atEnd(); ++it)
1629+
if (auto s = cast(Statement)(*it))
1630+
if (s._toktype == Token.Default)
1631+
{
1632+
hasDefault = true;
1633+
break;
1634+
}
1635+
1636+
if (!hasDefault)
1637+
{
1638+
auto insertPos = stmt.end - 1; // before "}"
1639+
TokenList tokList = new TokenList;
1640+
tokList.append(createToken(insertPos.pretext, "default", Token.Default, stmt.end.lineno));
1641+
tokList.append(createToken("", ":", Token.Colon, stmt.end.lineno));
1642+
tokList.append(createToken(" ", "break", Token.Break, stmt.end.lineno));
1643+
tokList.append(createToken("", ";", Token.Semicolon, stmt.end.lineno));
1644+
auto defstmt = new Statement(Token.Default);
1645+
defstmt.start = tokList.begin();
1646+
defstmt.end = tokList.end();
1647+
1648+
stmt.insertChildBefore(stmt.children.end(), defstmt, tokList, &insertPos);
1649+
1650+
stmt.verify();
1651+
}
1652+
}
1653+
16091654
void splitNonSimpleVarList(Declaration decl)
16101655
{
16111656
if(decl.children && decl.children.count() > 2)
@@ -1951,7 +1996,7 @@ void patchDeclType(DeclType dtype)
19511996
// simply add arguments to identifier
19521997
if(dvar2.start.type == Token.Identifier)
19531998
{
1954-
string argtext = createMappedTokenListText(tl);
1999+
string argtext = createMappedTokenListText(tl, true);
19552000
dvar2.start.text ~= argtext;
19562001
}
19572002
// bad insert position:
@@ -2051,6 +2096,8 @@ void patchAST(AST ast)
20512096
patchAsm(stmt);
20522097
if(stmt._toktype == Token.Return)
20532098
patchReturnExpressionType(stmt);
2099+
if(stmt._toktype == Token.Switch)
2100+
patchSwitchStatement(stmt);
20542101

20552102
patchClassVarInit(stmt);
20562103
}
@@ -2247,13 +2294,7 @@ class Source
22472294

22482295
string createTokenListText(int pass)
22492296
{
2250-
string text;
2251-
for(TokenIterator tokIt = _tokenList.begin(); !tokIt.atEnd(); ++tokIt)
2252-
{
2253-
Token tok = *tokIt;
2254-
string mapped = pass > 0 ? tok.text : mapTokenText(tok);
2255-
text ~= tok.pretext ~ mapped;
2256-
}
2297+
string text = createMappedTokenListText(_tokenList, pass <= 0);
22572298
return text;
22582299
}
22592300

@@ -2678,7 +2719,7 @@ class Cpp2DConverter
26782719
// cannot remove decl immediately, because iterators in iterateTopLevelDeclarations will become invalid
26792720
declsToRemove ~= decl;
26802721

2681-
currentSource._ast.verify();
2722+
decl._parent.verify();
26822723
}
26832724

26842725
void moveAllMethods()
@@ -2795,8 +2836,6 @@ class Cpp2DConverter
27952836
string fname = replace(modname, ".", "/");
27962837
if(pass == 0)
27972838
{
2798-
if (ext != ".h" && ext != "")
2799-
fname ~= "_" ~ ext[1 .. $];
28002839
fname ~= ".d";
28012840
}
28022841
else
@@ -2996,7 +3035,7 @@ string testDmdGen(string txt, int countRemove = 1, int countNoImpl = 0, TokenLis
29963035

29973036
TokenList tokenList = scanText(txt);
29983037

2999-
if(defines is null)
3038+
if(defines !is null)
30003039
{
30013040
expandPPdefines(tokenList, defines, MixinMode.ExpandDefine);
30023041
rescanPP(tokenList);
@@ -3741,7 +3780,6 @@ unittest
37413780

37423781
unittest
37433782
{
3744-
// force failure
37453783
string txt =
37463784
"#define A 1\n"
37473785
~ "#define B A\n"
@@ -3750,7 +3788,7 @@ unittest
37503788
;
37513789
string exp =
37523790
"enum A = 1;\n"
3753-
~ "alias B A;\n"
3791+
~ "alias A B;\n"
37543792
~ " auto C( )() { return B*B; }\n"
37553793
~ " auto SQR( ARG1 )(ARG1 a) { return a*a; }\n"
37563794
;
@@ -3771,13 +3809,77 @@ void cpp2d_test()
37713809
;
37723810

37733811
// PP.expandConditionals["EXP"] = true;
3774-
TokenList[string] defines = [ "EXP" : scanText("1") ];
37753812

3776-
string res = testDmdGen(txt, 0, 0, defines);
3813+
string res = testDmdGen(txt, 0, 0, null);
37773814
assert(res == exp);
37783815

3816+
TokenList[string] defines = [ "EXP" : scanText("1") ];
3817+
string exp2 = "enum WSL = 1; // comment\n";
3818+
string res2 = testDmdGen(txt, 0, 0, defines);
3819+
assert(res2 == exp2);
3820+
37793821
PP.expandConditionals = PP.expandConditionals.init;
37803822
}
37813823

3824+
unittest
3825+
{
3826+
string txt =
3827+
"void foo(int x) {\n"
3828+
~ " switch(x) {\n"
3829+
~ " case 0: return;\n"
3830+
~ " }\n"
3831+
~ "}\n"
3832+
;
3833+
string exp =
3834+
"void foo(int x) {\n"
3835+
~ " switch(x) {\n"
3836+
~ " case 0: return;\n"
3837+
~ " default: break;\n"
3838+
~ " }\n"
3839+
~ "}\n"
3840+
;
3841+
3842+
string res = testDmdGen(txt, 0, 0);
3843+
assert(res == exp);
3844+
}
3845+
3846+
unittest
3847+
{
3848+
string txt =
3849+
"void foo(int x) {\n"
3850+
~ " switch(x) {\n"
3851+
~ " default: break;\n"
3852+
~ " case 1: return;\n"
3853+
~ " }\n"
3854+
~ "}\n"
3855+
;
3856+
string exp =
3857+
"void foo(int x) {\n"
3858+
~ " switch(x) {\n"
3859+
~ " default: break;\n"
3860+
~ " case 1: return;\n"
3861+
~ " }\n"
3862+
~ "}\n"
3863+
;
3864+
3865+
string res = testDmdGen(txt, 0, 0);
3866+
assert(res == exp);
3867+
}
3868+
3869+
unittest
3870+
{
3871+
string rtxt = "case '0' => goto case; case '0'";
3872+
PatchRule rule;
3873+
bool rc = C2DIni.parsePatchRule(rule, rtxt);
3874+
3875+
string txt = "switch(x) { case '0': break; }";
3876+
auto tokenList = scanText(txt);
3877+
replaceTokenSequence(tokenList, rule.searchTokens, rule.replaceTokens, true);
3878+
string ntxt = tokenListToString(tokenList, true);
3879+
3880+
string exp = "switch(x) { goto case;case'0': break; }";
3881+
assert(exp == ntxt);
3882+
}
3883+
37823884
version(MAIN)
37833885
void main() {}

0 commit comments

Comments
 (0)