Mercurial > projects > ddmd
diff dmd/ConditionalDeclaration.d @ 79:43073c7c7769
updated to 2.035
also implemented a few missing functions
still crashes in Import.importAll though
author | Trass3r |
---|---|
date | Mon, 30 Aug 2010 03:57:51 +0200 |
parents | ad4792a1cfd6 |
children | e28b18c23469 |
line wrap: on
line diff
--- a/dmd/ConditionalDeclaration.d Sun Aug 29 14:39:08 2010 +0100 +++ b/dmd/ConditionalDeclaration.d Mon Aug 30 03:57:51 2010 +0200 @@ -24,13 +24,13 @@ override Dsymbol syntaxCopy(Dsymbol s) { - ConditionalDeclaration dd; - - assert(!s); - dd = new ConditionalDeclaration(condition.syntaxCopy(), - Dsymbol.arraySyntaxCopy(decl), - Dsymbol.arraySyntaxCopy(elsedecl)); - return dd; + ConditionalDeclaration dd; + + assert(!s); + dd = new ConditionalDeclaration(condition.syntaxCopy(), + Dsymbol.arraySyntaxCopy(decl), + Dsymbol.arraySyntaxCopy(elsedecl)); + return dd; } override bool oneMember(Dsymbol* ps) @@ -47,20 +47,20 @@ override void emitComment(Scope sc) { - //printf("ConditionalDeclaration.emitComment(sc = %p)\n", sc); - if (condition.inc) - { - AttribDeclaration.emitComment(sc); - } - else if (sc.docbuf) - { - /* If generating doc comment, be careful because if we're inside - * a template, then include(NULL, NULL) will fail. - */ - auto d = decl ? decl : elsedecl; - foreach(s; d) - s.emitComment(sc); - } + //printf("ConditionalDeclaration.emitComment(sc = %p)\n", sc); + if (condition.inc) + { + AttribDeclaration.emitComment(sc); + } + else if (sc.docbuf) + { + /* If generating doc comment, be careful because if we're inside + * a template, then include(NULL, NULL) will fail. + */ + auto d = decl ? decl : elsedecl; + foreach(s; d) + s.emitComment(sc); + } } // Decide if 'then' or 'else' code should be included @@ -72,7 +72,7 @@ return condition.include(sc, sd) ? decl : elsedecl; } - override void addComment(ubyte* comment) + override void addComment(string comment) { /* Because addComment is called by the parser, if we called * include() it would define a version before it was used. @@ -99,38 +99,72 @@ override void toCBuffer(OutBuffer buf, HdrGenState* hgs) { - condition.toCBuffer(buf, hgs); - if (decl || elsedecl) - { - buf.writenl(); - buf.writeByte('{'); - buf.writenl(); - if (decl) - { - foreach (Dsymbol s; decl) + condition.toCBuffer(buf, hgs); + if (decl || elsedecl) { - buf.writestring(" "); - s.toCBuffer(buf, hgs); + buf.writenl(); + buf.writeByte('{'); + buf.writenl(); + if (decl) + { + foreach (Dsymbol s; decl) + { + buf.writestring(" "); + s.toCBuffer(buf, hgs); + } + } + buf.writeByte('}'); + if (elsedecl) + { + buf.writenl(); + buf.writestring("else"); + buf.writenl(); + buf.writeByte('{'); + buf.writenl(); + foreach (Dsymbol s; elsedecl) + { + buf.writestring(" "); + s.toCBuffer(buf, hgs); + } + buf.writeByte('}'); + } } - } - buf.writeByte('}'); - if (elsedecl) - { + else + buf.writeByte(':'); buf.writenl(); - buf.writestring("else"); - buf.writenl(); - buf.writeByte('{'); - buf.writenl(); - foreach (Dsymbol s; elsedecl) - { - buf.writestring(" "); - s.toCBuffer(buf, hgs); - } - buf.writeByte('}'); + } + + override void toJsonBuffer(OutBuffer buf) + { + // writef("ConditionalDeclaration::toJsonBuffer()\n"); + if (condition.inc) + { + super.toJsonBuffer(buf); + } } + + override void importAll(Scope sc) + { + Dsymbols d = include(sc, null); + + //writef("\tConditionalDeclaration::importAll '%s', d = %p\n",toChars(), d); + if (d) + { + foreach (s; d) + s.importAll(sc); + } } - else - buf.writeByte(':'); - buf.writenl(); - } -} + + override void setScope(Scope sc) + { + Dsymbols d = include(sc, null); + + //writef("\tConditionalDeclaration::setScope '%s', d = %p\n",toChars(), d); + if (d) + { + foreach (s; d) + s.setScope(sc); + } + + } +} \ No newline at end of file