annotate dmd/StorageClassDeclaration.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents 96c0fff6897d
children cd48cb899aee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.StorageClassDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 74
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.AttribDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Token;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.STC;
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
13 import dmd.Id;
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
14 import dmd.Identifier;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 class StorageClassDeclaration: AttribDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 {
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
18 StorageClass stc;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
20 this(StorageClass stc, Dsymbols decl)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 170
diff changeset
22 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 super(decl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 this.stc = stc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
28 override Dsymbol syntaxCopy(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 {
51
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
30 StorageClassDeclaration scd;
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
31
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
32 assert(!s);
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
33 scd = new StorageClassDeclaration(stc, Dsymbol.arraySyntaxCopy(decl));
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
34 return scd;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
37 override void setScope(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 if (decl)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 {
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
41 StorageClass scstc = sc.stc;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 /* These sets of storage classes are mutually exclusive,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 * so choose the innermost or most recent one.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls);
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
54 if (stc & (STCsafe | STCtrusted | STCsystem))
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
55 scstc &= ~(STCsafe | STCtrusted | STCsystem);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 scstc |= stc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 setScopeNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
62 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 if (decl)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 {
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
66 StorageClass scstc = sc.stc;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 /* These sets of storage classes are mutually exclusive,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 * so choose the innermost or most recent one.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls);
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
79 if (stc & (STCsafe | STCtrusted | STCsystem))
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
80 scstc &= ~(STCsafe | STCtrusted | STCsystem);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 scstc |= stc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 semanticNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
87 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
92 static void stcToCBuffer(OutBuffer buf, StorageClass stc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 struct SCstring
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 {
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
96 StorageClass stc;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 TOK tok;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 };
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99
170
96c0fff6897d more global state cleanup
korDen
parents: 131
diff changeset
100 enum SCstring[] table =
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 [
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 { STCauto, TOKauto },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 { STCscope, TOKscope },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 { STCstatic, TOKstatic },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 { STCextern, TOKextern },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 { STCconst, TOKconst },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 { STCfinal, TOKfinal },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 { STCabstract, TOKabstract },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 { STCsynchronized, TOKsynchronized },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 { STCdeprecated, TOKdeprecated },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 { STCoverride, TOKoverride },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 { STClazy, TOKlazy },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 { STCalias, TOKalias },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 { STCout, TOKout },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 { STCin, TOKin },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 /// version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 /// { STCimmutable, TOKimmutable },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 /// { STCshared, TOKshared },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 /// { STCnothrow, TOKnothrow },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 /// { STCpure, TOKpure },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 /// { STCref, TOKref },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 /// { STCtls, TOKtls },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 /// { STCgshared, TOKgshared },
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
124 /// { STCproperty, TOKat },
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
125 /// { STCsafe, TOKat },
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
126 /// { STCtrusted, TOKat },
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 for (int i = 0; i < table.length; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 if (stc & table[i].stc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
134 enum TOK tok = table[i].tok;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
135 if (tok == TOKat)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
136 { Identifier id;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
137
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
138 if (stc & STCproperty)
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
139 id = Id.property;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
140 else if (stc & STCsafe)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
141 id = Id.safe;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
142 else if (stc & STCtrusted)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
143 id = Id.trusted;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
144 else
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
145 assert(0);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
146 buf.writestring(id.toChars());
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
147 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
148 else
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
149 buf.writestring(Token.toChars(tok));
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 buf.writeByte(' ');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
154 }