annotate dmd/PragmaDeclaration.d @ 4:d706d958e4e8

Step 2 of restoring GC functionality.
author korDen
date Mon, 26 Oct 2009 16:28:19 +0300
parents 7427ded8caf7
children fd4acc376c45
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.PragmaDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.AttribDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.StringExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.WANT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
4
d706d958e4e8 Step 2 of restoring GC functionality.
korDen
parents: 2
diff changeset
23 import core.memory;
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
24
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 class PragmaDeclaration : AttribDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 Expressions args; // array of Expression's
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 this(Loc loc, Identifier ident, Expressions args, Array decl)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 super(decl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 this.loc = loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 this.ident = ident;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 this.args = args;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 Dsymbol syntaxCopy(Dsymbol s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 //printf("PragmaDeclaration.syntaxCopy(%s)\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 PragmaDeclaration pd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 assert(!s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 pd = new PragmaDeclaration(loc, ident, Expression.arraySyntaxCopy(args), Dsymbol.arraySyntaxCopy(decl));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 return pd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 void semantic(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 // Should be merged with PragmaStatement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 //printf("\tPragmaDeclaration.semantic '%s'\n",toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 if (ident == Id.msg)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 if (args)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 for (size_t i = 0; i < args.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 Expression e = cast(Expression)args.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 e = e.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 if (e.op == TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 StringExp se = cast(StringExp)e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 writef("%.*s", cast(int)se.len, cast(char*)se.string_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 error("string expected for message, not '%s'", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 writef("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 else if (ident == Id.lib)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 if (!args || args.dim != 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 error("string expected for library name");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 Expression e = cast(Expression)args.data[0];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 e = e.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 args.data[0] = cast(void*)e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 if (e.op != TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 error("string expected for library name, not '%s'", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 else if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 StringExp se = cast(StringExp)e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 writef("library %.*s\n", cast(int)se.len, cast(char*)se.string_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 /// version (IN_GCC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 /// else if (ident == Id.GNU_asm)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 /// {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 /// if (! args || args.dim != 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 /// error("identifier and string expected for asm name");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 /// else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 /// {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 /// Expression *e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 /// Declaration *d = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 /// StringExp *s = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 /// e = (Expression *)args.data[0];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 /// e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 /// if (e.op == TOKvar)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 /// {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 /// d = ((VarExp *)e).var;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 /// if (! d.isFuncDeclaration() && ! d.isVarDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 /// d = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 /// if (!d)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 /// error("first argument of GNU_asm must be a function or variable declaration");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 /// e = (Expression *)args.data[1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 /// e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 /// e = e.optimize(WANTvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 /// if (e.op == TOKstring && ((StringExp *)e).sz == 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 /// s = ((StringExp *)e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 /// else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 /// error("second argument of GNU_asm must be a char string");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 /// if (d && s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 /// d.c_ident = Lexer.idPool((char*) s.string);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 /// goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 else if (ident == Id.startaddress)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 if (!args || args.dim != 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 error("function name expected for start address");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 Expression e = cast(Expression)args.data[0];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 e = e.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 args.data[0] = cast(void*)e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 Dsymbol sa = getDsymbol(e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 if (!sa || !sa.isFuncDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 error("function name expected for start address, not '%s'", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 /// version (TARGET_NET) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 /// else if (ident == Lexer.idPool("assembly"))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 /// {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 /// } // TARGET_NET
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 else if (global.params.ignoreUnsupportedPragmas)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 /* Print unrecognized pragmas
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 writef("pragma %s", ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 if (args)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 for (size_t i = 0; i < args.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 Expression e = cast(Expression)args.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 e = e.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 if (i == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 writef(" (");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 writef(",");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 writef("%s", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 if (args.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 writef(")");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 writef("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 error("unrecognized pragma(%s)", ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 if (decl)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 for (uint i = 0; i < decl.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 Dsymbol s = cast(Dsymbol)decl.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 s.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 Lnodecl:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 if (decl)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 error("pragma is missing closing ';'");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 void setScope(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 version (TARGET_NET) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 if (ident == Lexer.idPool("assembly"))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 if (!args || args.dim != 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 error("pragma has invalid number of arguments");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 Expression e = cast(Expression)args.data[0];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 e = e.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 args.data[0] = cast(void*)e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 if (e.op != TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 error("string expected, not '%s'", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 PragmaScope pragma_ = new PragmaScope(this, sc.parent, cast(StringExp)e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 assert(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 pragma_.setScope(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 //add to module members
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 assert(sc.module_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 assert(sc.module_.members);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 sc.module_.members.push(cast(void*)pragma_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 bool oneMember(Dsymbol* ps)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 {
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 string kind()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 void toObjFile(int multiobj) // compile to .obj file
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 if (ident == Id.lib)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 assert(args && args.dim == 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 Expression e = cast(Expression)args.data[0];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 assert(e.op == TOKstring);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 StringExp se = cast(StringExp)e;
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
256 char* name = cast(char*)GC.malloc(se.len + 1);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 memcpy(name, se.string_, se.len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 name[se.len] = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 version (OMFOBJ) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 /* The OMF format allows library names to be inserted
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 * into the object file. The linker will then automatically
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 * search that library, too.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 obj_includelib(name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 } else version (ELFOBJ_OR_MACHOBJ) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 /* The format does not allow embedded library names,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 * so instead append the library name to the list to be passed
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 * to the linker.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 global.params.libfiles.push(cast(void*) name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 error("pragma lib not supported");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 /// version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 else if (ident == Id.startaddress)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 assert(args && args.dim == 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 Expression e = cast(Expression)args.data[0];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 Dsymbol sa = getDsymbol(e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 FuncDeclaration f = sa.isFuncDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 assert(f);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 Symbol* s = f.toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 obj_startaddress(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 AttribDeclaration.toObjFile(multiobj);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 }