2 // Copyright (c) 1999-2005 by Digital Mars
4 // written by Walter Bright
5 // http://www.digitalmars.com
6 // License for redistribution is by either the Artistic License
7 // in artistic.txt, or the GNU General Public License in gnu.txt.
8 // See the included readme.txt for details.
15 #include "identifier.h"
21 /* ================================================== */
23 /* DebugSymbol's happen for statements like:
28 DebugSymbol::DebugSymbol(Loc loc
, Identifier
*ident
)
34 DebugSymbol::DebugSymbol(Loc loc
, unsigned level
)
41 Dsymbol
*DebugSymbol::syntaxCopy(Dsymbol
*s
)
44 DebugSymbol
*ds
= new DebugSymbol(loc
, ident
);
49 int DebugSymbol::addMember(Scope
*sc
, ScopeDsymbol
*sd
, int memnum
)
51 //printf("DebugSymbol::addMember('%s') %s\n", sd->toChars(), toChars());
54 // Do not add the member to the symbol table,
55 // just make sure subsequent debug declarations work.
60 error("declaration must be at module level");
63 if (findCondition(m
->debugidsNot
, ident
))
64 error("defined after use");
66 m
->debugids
= new Array();
67 m
->debugids
->push(ident
->toChars());
73 error("level declaration must be at module level");
75 m
->debuglevel
= level
;
80 void DebugSymbol::semantic(Scope
*sc
)
82 //printf("DebugSymbol::semantic() %s\n", toChars());
85 void DebugSymbol::toCBuffer(OutBuffer
*buf
, HdrGenState
*hgs
)
87 buf
->writestring("debug = ");
89 buf
->writestring(ident
->toChars());
91 buf
->printf("%u", level
);
92 buf
->writestring(";");
96 char *DebugSymbol::kind()
101 /* ================================================== */
103 /* VersionSymbol's happen for statements like:
104 * version = identifier;
108 VersionSymbol::VersionSymbol(Loc loc
, Identifier
*ident
)
114 VersionSymbol::VersionSymbol(Loc loc
, unsigned level
)
121 Dsymbol
*VersionSymbol::syntaxCopy(Dsymbol
*s
)
124 VersionSymbol
*ds
= new VersionSymbol(loc
, ident
);
129 int VersionSymbol::addMember(Scope
*sc
, ScopeDsymbol
*sd
, int memnum
)
131 //printf("VersionSymbol::addMember('%s') %s\n", sd->toChars(), toChars());
134 // Do not add the member to the symbol table,
135 // just make sure subsequent debug declarations work.
139 VersionCondition::checkPredefined(loc
, ident
->toChars());
141 error("declaration must be at module level");
144 if (findCondition(m
->versionidsNot
, ident
))
145 error("defined after use");
147 m
->versionids
= new Array();
148 m
->versionids
->push(ident
->toChars());
154 error("level declaration must be at module level");
156 m
->versionlevel
= level
;
161 void VersionSymbol::semantic(Scope
*sc
)
165 void VersionSymbol::toCBuffer(OutBuffer
*buf
, HdrGenState
*hgs
)
167 buf
->writestring("version = ");
169 buf
->writestring(ident
->toChars());
171 buf
->printf("%u", level
);
172 buf
->writestring(";");
176 char *VersionSymbol::kind()