Mercurial > projects > ddmd
diff dmd/Parser.d @ 74:7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Sun, 29 Aug 2010 09:43:40 +0100 |
parents | 51605de93870 |
children | ad4792a1cfd6 |
line wrap: on
line diff
--- a/dmd/Parser.d Sat Aug 28 19:42:41 2010 +0400 +++ b/dmd/Parser.d Sun Aug 29 09:43:40 2010 +0100 @@ -222,9 +222,9 @@ //nextToken(); // start up the scanner } - Array parseModule() + Dsymbols parseModule() { - Array decldefs; + typeof(return) decldefs; // ModuleDeclation leads off if (token.value == TOK.TOKmodule) @@ -299,15 +299,15 @@ nextToken(); nextToken(); - return new Array(); + return new Dsymbols(); } - Array parseDeclDefs(int once) + Dsymbols parseDeclDefs(int once) { Dsymbol s; - Array decldefs; - Array a; - Array aelse; + Dsymbols decldefs; + Dsymbols a; + Dsymbols aelse; PROT prot; STC stc; STC storageClass; @@ -315,7 +315,7 @@ ubyte* comment; //printf("Parser.parseDeclDefs()\n"); - decldefs = new Array(); + decldefs = new Dsymbols(); do { comment = token.blockComment; @@ -733,7 +733,7 @@ continue; } if (s) - { decldefs.push(cast(void*)s); + { decldefs.push(s); addComment(s, comment); } } while (!once); @@ -748,9 +748,9 @@ * Ends with scanner past closing ';' */ version (DMDV2) { - Array parseAutoDeclarations(STC storageClass, ubyte* comment) + Dsymbols parseAutoDeclarations(STC storageClass, ubyte* comment) { - Array a = new Array; + auto a = new Dsymbols; while (true) { @@ -759,9 +759,9 @@ assert(token.value == TOKassign); nextToken(); // skip over '=' Initializer init = parseInitializer(); - VarDeclaration v = new VarDeclaration(loc, null, ident, init); + auto v = new VarDeclaration(loc, null, ident, init); v.storage_class = storageClass; - a.push(cast(void*)v); + a.push(v); if (token.value == TOKsemicolon) { nextToken(); @@ -789,9 +789,9 @@ /******************************************** * Parse declarations after an align, protection, or extern decl. */ - Array parseBlock() + Dsymbols parseBlock() { - Array a = null; + Dsymbols a = null; Dsymbol ss; //printf("parseBlock()\n"); @@ -874,7 +874,7 @@ TemplateDeclaration tempdecl; Identifier id; TemplateParameters tpl; - Array decldefs; + Dsymbols decldefs; Expression constraint = null; Loc loc = this.loc; @@ -1245,9 +1245,9 @@ if (tpl) { // Wrap a template around function fd - Array decldefs = new Array(); - decldefs.push(cast(void*)fd); - TemplateDeclaration tempdecl = new TemplateDeclaration(fd.loc, fd.ident, tpl, null, decldefs); + auto decldefs = new Dsymbols(); + decldefs.push(fd); + auto tempdecl = new TemplateDeclaration(fd.loc, fd.ident, tpl, null, decldefs); tempdecl.literal = 1; // it's a template 'literal' tiargs.push(cast(void*)tempdecl); goto L1; @@ -1594,10 +1594,9 @@ parseContracts(f); // Wrap a template around it - Array decldefs = new Array(); - decldefs.push(cast(void*)f); - TemplateDeclaration tempdecl = - new TemplateDeclaration(loc, f.ident, tpl, constraint, decldefs); + auto decldefs = new Dsymbols(); + decldefs.push(f); + auto tempdecl = new TemplateDeclaration(loc, f.ident, tpl, constraint, decldefs); return tempdecl; } @@ -1903,7 +1902,7 @@ else if (token.value == TOK.TOKlcurly) { //printf("enum definition\n"); - e.members = new Array(); + e.members = new Dsymbols(); nextToken(); ubyte* comment = token.blockComment; while (token.value != TOK.TOKrcurly) @@ -1946,8 +1945,8 @@ error("if type, there must be an initializer"); } - EnumMember em = new EnumMember(loc, ident, value, type); - e.members.push(cast(void*)em); + auto em = new EnumMember(loc, ident, value, type); + e.members.push(em); if (token.value == TOK.TOKrcurly) { ; @@ -2050,7 +2049,7 @@ { //printf("aggregate definition\n"); nextToken(); - Array decl = parseDeclDefs(0); + auto decl = parseDeclDefs(0); if (token.value != TOK.TOKrcurly) error("} expected following member declarations in aggregate"); nextToken(); @@ -2072,10 +2071,9 @@ if (tpl) { // Wrap a template around the aggregate declaration - Array decldefs = new Array(); - decldefs.push(cast(void*)a); - TemplateDeclaration tempdecl = - new TemplateDeclaration(loc, id, tpl, constraint, decldefs); + auto decldefs = new Dsymbols(); + decldefs.push(a); + auto tempdecl = new TemplateDeclaration(loc, id, tpl, constraint, decldefs); return tempdecl; } @@ -2126,7 +2124,7 @@ return baseclasses; } - Import parseImport(Array decldefs, int isstatic) + Import parseImport(Dsymbols decldefs, int isstatic) { Import s; Identifier id; @@ -2170,7 +2168,7 @@ } s = new Import(loc, a, id, aliasid, isstatic); - decldefs.push(cast(void*)s); + decldefs.push(s); /* Look for * : alias=name, alias=name; @@ -2687,14 +2685,14 @@ return ts; } - Array parseDeclarations(STC storage_class) + Dsymbols parseDeclarations(STC storage_class) { STC stc; Type ts; Type t; Type tfirst; Identifier ident; - Array a; + Dsymbols a; TOK tok = TOK.TOKreserved; ubyte* comment = token.blockComment; LINK link = linkage; @@ -2719,8 +2717,8 @@ nextToken(); check(TOK.TOKthis); check(TOK.TOKsemicolon); - a = new Array(); - a.push(cast(void*)s); + a = new Dsymbols(); + a.push(s); addComment(s, comment); return a; } @@ -2810,8 +2808,8 @@ { AggregateDeclaration s = cast(AggregateDeclaration)parseAggregate(); s.storage_class |= storage_class; - a = new Array(); - a.push(cast(void*)s); + a = new Dsymbols(); + a.push(s); addComment(s, comment); return a; } @@ -2837,7 +2835,7 @@ L2: tfirst = null; - a = new Array(); + a = new Dsymbols(); while (1) { @@ -2873,13 +2871,13 @@ } v.storage_class = storage_class; if (link == linkage) - a.push(cast(void*)v); + a.push(v); else { - Array ax = new Array(); - ax.push(cast(void*)v); + auto ax = new Dsymbols(); + ax.push(v); Dsymbol s = new LinkDeclaration(link, ax); - a.push(cast(void*)s); + a.push(s); } switch (token.value) { case TOK.TOKsemicolon: @@ -2899,7 +2897,7 @@ } else if (t.ty == TY.Tfunction) { - TypeFunction tf = cast(TypeFunction)t; + auto tf = cast(TypeFunction)t; Expression constraint = null; static if (false) { if (Argument.isTPL(tf.parameters)) @@ -2922,8 +2920,8 @@ } else { - Array ax = new Array(); - ax.push(cast(void*)f); + auto ax = new Dsymbols(); + ax.push(f); s = new LinkDeclaration(link, ax); } /* A template parameter list means it's a function template @@ -2931,14 +2929,14 @@ if (tpl) { // Wrap a template around the function declaration - Array decldefs = new Array(); - decldefs.push(cast(void*)s); - TemplateDeclaration tempdecl = + auto decldefs = new Dsymbols(); + decldefs.push(s); + auto tempdecl = new TemplateDeclaration(loc, s.ident, tpl, constraint, decldefs); s = tempdecl; } addComment(s, comment); - a.push(cast(void*)s); + a.push(s); } else { @@ -2952,13 +2950,13 @@ VarDeclaration v = new VarDeclaration(loc, t, ident, init); v.storage_class = storage_class; if (link == linkage) - a.push(cast(void*)v); + a.push(v); else { - Array ax = new Array(); - ax.push(cast(void*)v); - Dsymbol s = new LinkDeclaration(link, ax); - a.push(cast(void*)s); + auto ax = new Dsymbols(); + ax.push(v); + auto s = new LinkDeclaration(link, ax); + a.push(s); } switch (token.value) { case TOK.TOKsemicolon: @@ -3213,7 +3211,7 @@ } // case TOK.TOKtypeof: Ldeclaration: - { Array a; + { Dsymbols a; a = parseDeclarations(STC.STCundefined); if (a.dim > 1) @@ -6054,7 +6052,7 @@ else { nextToken(); - Array decl = parseDeclDefs(0); + auto decl = parseDeclDefs(0); if (token.value != TOKrcurly) error("class member expected"); nextToken();