annotate dmd/Declaration.d @ 192:eb38fdcb3e62 default tip

updated to compile with dmd2.062
author korDen
date Sat, 02 Mar 2013 01:25:52 -0800
parents 83a36bdd5d14
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.Declaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 96
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Type;
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
6 import dmd.TypedefDeclaration;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.PROT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.LINK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Identifier;
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
10 import dmd.Json;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.STC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.VarDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17
183
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
18 version (CPP_MANGLE)
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
19 {
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
20 import dmd.backend.glue;
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
21 import std.conv : to;
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
22 }
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
23
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 184
diff changeset
24 import dmd.DDMDExtensions;
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 184
diff changeset
25
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import std.stdio : writef;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import core.stdc.ctype;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import core.stdc.stdio : sprintf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 string mangle(Declaration sthis)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 scope OutBuffer buf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 string id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 Dsymbol s = sthis;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 //printf(".mangle(%s)\n", sthis.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 do
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 //printf("mangle: s = %p, '%s', parent = %p\n", s, s.toChars(), s.parent);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 if (s.ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 FuncDeclaration fd = s.isFuncDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 if (s !is sthis && fd)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 id = mangle(fd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 buf.prependstring(id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 id = s.ident.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 int len = id.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 char tmp[len.sizeof * 3 + 1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 buf.prependstring(id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 len = sprintf(tmp.ptr, "%d".ptr, len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 buf.prependstring(tmp[0..len]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 buf.prependstring("0");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 s = s.parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 } while (s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 // buf.prependstring("_D");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 L1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 //printf("deco = '%s'\n", sthis.type.deco ? sthis.type.deco : "null");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 //printf("sthis.type = %s\n", sthis.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 FuncDeclaration fd = sthis.isFuncDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 if (fd && (fd.needThis() || fd.isNested()))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 buf.writeByte(Type.needThisPrefix());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 if (sthis.type.deco)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 buf.writestring(sthis.type.deco);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 {
96
acd69f84627e further work
Trass3r
parents: 79
diff changeset
77 debug
acd69f84627e further work
Trass3r
parents: 79
diff changeset
78 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 if (!fd.inferRetType)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 writef("%s\n", fd.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 }
96
acd69f84627e further work
Trass3r
parents: 79
diff changeset
82 assert(fd && fd.inferRetType);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 id = buf.extractString();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 return id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 class Declaration : Dsymbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 {
188
83a36bdd5d14 Missed one in last commit.
Abscissa
parents: 187
diff changeset
91 mixin insertMemberExtension!(typeof(this));
83a36bdd5d14 Missed one in last commit.
Abscissa
parents: 187
diff changeset
92
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 Type type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 Type originalType; // before semantic analysis
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
95 StorageClass storage_class = STC.STCundefined;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 PROT protection = PROT.PROTundefined;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 LINK linkage = LINK.LINKdefault;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 int inuse; // used to detect cycles
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 this(Identifier id)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 139
diff changeset
102 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 super(id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 68
diff changeset
106 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 68
diff changeset
110 override string kind()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 68
diff changeset
115 override uint size(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 /*************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 * Check to see if declaration can be modified in this context (sc).
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 * Issue error if not.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 void checkModify(Loc loc, Scope sc, Type t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 if (sc.incontract && isParameter())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 error(loc, "cannot modify parameter '%s' in contract", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 if (isCtorinit())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 // It's only modifiable if inside the right constructor
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 Dsymbol s = sc.func;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 while (true)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 FuncDeclaration fd = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 if (s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 fd = s.isFuncDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 if (fd && ((fd.isCtorDeclaration() && storage_class & STC.STCfield) ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 (fd.isStaticCtorDeclaration() && !(storage_class & STC.STCfield))) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 fd.toParent() == toParent()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 VarDeclaration v = isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 assert(v);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 v.ctorinit = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 //printf("setting ctorinit\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 if (s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 s = s.toParent2();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 string p = isStatic() ? "static " : "";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 error(loc, "can only initialize %sconst %s inside %sconstructor", p, toChars(), p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 VarDeclaration v = isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 if (v && v.canassign == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 string p = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 if (isConst())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 p = "const";
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 131
diff changeset
172 else if (isImmutable())
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 p = "immutable";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 else if (storage_class & STC.STCmanifest)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 p = "enum";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 else if (!t.isAssignable())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 p = "struct with immutable members";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 if (p)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 error(loc, "cannot modify %s", p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 68
diff changeset
186 override void emitComment(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
191 override void toJsonBuffer(OutBuffer buf)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
192 {
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
193 //writef("Declaration.toJsonBuffer()\n");
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
194 buf.writestring("{\n");
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
195
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
196 JsonProperty(buf, Pname, toChars());
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
197 JsonProperty(buf, Pkind, kind());
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
198 if (type)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
199 JsonProperty(buf, Ptype, type.toChars());
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
200
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
201 if (comment)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
202 JsonProperty(buf, Pcomment, comment);
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
203
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
204 if (loc.linnum)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
205 JsonProperty(buf, Pline, loc.linnum);
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
206
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
207 TypedefDeclaration td = isTypedefDeclaration();
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
208 if (td)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
209 {
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
210 JsonProperty(buf, "base", td.basetype.toChars());
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
211 }
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
212
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
213 JsonRemoveComma(buf);
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
214 buf.writestring("}\n");
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
215 }
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
216
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 68
diff changeset
217 override void toDocBuffer(OutBuffer buf)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 68
diff changeset
222 override string mangle()
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
223 /+out (result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 try
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 int len = result.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 assert(len > 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 //printf("mangle: '%s' => '%s'\n", toChars(), result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 for (int i = 0; i < len; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 assert(result[i] == '_' || result[i] == '@' || isalnum(result[i]) || result[i] & 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 } catch {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 writef("Incorrect mangle: '%s'\n", result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 }
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
240 body+/
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 {
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 16
diff changeset
242 version(Bug3602) { writef( "Bug3602: Uncomment outblock when fixed\n" ); }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 //writef("Declaration.mangle(this = %p, '%s', parent = '%s', linkage = %d)\n", this, toChars(), parent ? parent.toChars() : "null", linkage);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 if (!parent || parent.isModule() || linkage == LINK.LINKcpp) // if at global scope
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 // If it's not a D declaration, no mangling
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 switch (linkage)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 case LINK.LINKd:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 case LINK.LINKc:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 case LINK.LINKwindows:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 case LINK.LINKpascal:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 return ident.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 case LINK.LINKcpp:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 version (CPP_MANGLE) {
184
9f4e5ac4f0a3 One step closer to building on posix.
Jacob Carlborg <doob@me.com>
parents: 183
diff changeset
259 return cpp_mangle(this);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 // Windows C++ mangling is done by C++ back end
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 return ident.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 case LINK.LINKdefault:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 error("forward declaration");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 return ident.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 writef("'%s', linkage = %d\n", toChars(), linkage);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 string p = .mangle(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 scope OutBuffer buf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 buf.writestring("_D");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 buf.writestring(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 p = buf.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 buf.data = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 //writef("Declaration.mangle(this = %p, '%s', parent = '%s', linkage = %d) = %s\n", this, toChars(), parent ? parent.toChars() : "null", linkage, p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 return p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
285 bool isStatic() { return (storage_class & STC.STCstatic) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 bool isDelete()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 bool isDataseg()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 bool isThreadlocal()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 {
68
ee3a9f34dc48 final bits of codegen implementation to compile Phobos
korDen
parents: 22
diff changeset
299 return false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 bool isCodeseg()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
307 bool isCtorinit() { return (storage_class & STC.STCctorinit) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
309 bool isFinal() { return (storage_class & STC.STCfinal) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 bool isAbstract() { return (storage_class & STC.STCabstract) != 0; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 bool isConst() { return (storage_class & STC.STCconst) != 0; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
315 bool isImmutable() { return (storage_class & STC.STCimmutable) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
317 bool isAuto() { return (storage_class & STC.STCauto) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
319 bool isScope() { return (storage_class & (STC.STCscope | STC.STCauto)) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
321 bool isSynchronized() { return (storage_class & STC.STCsynchronized) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
323 bool isParameter() { return (storage_class & STC.STCparameter) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 68
diff changeset
325 override bool isDeprecated() { return (storage_class & STC.STCdeprecated) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
327 bool isOverride() { return (storage_class & STC.STCoverride) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
329 bool isIn() { return (storage_class & STC.STCin) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
331 bool isOut() { return (storage_class & STC.STCout) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332
139
bc45b1c53019 made StorageClass type-safe
Trass3r
parents: 135
diff changeset
333 bool isRef() { return (storage_class & STC.STCref) != 0; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 68
diff changeset
335 override PROT prot()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 return protection;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 68
diff changeset
340 override Declaration isDeclaration() { return this; }
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
341 }