annotate dmd/PragmaDeclaration.d @ 187:b0d41ff5e0df

Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author Abscissa
date Tue, 07 Jun 2011 23:37:34 -0400
parents 0622fff7810a
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.PragmaDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 95
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.AttribDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.StringExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.WANT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23
180
0622fff7810a Fixed a few memory allocation related issues
korDen
parents: 178
diff changeset
24 import core.stdc.stdlib : malloc;
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
25
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 180
diff changeset
26 import dmd.DDMDExtensions;
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 180
diff changeset
27
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 class PragmaDeclaration : AttribDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 180
diff changeset
30 mixin insertMemberExtension!(typeof(this));
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 180
diff changeset
31
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 Expressions args; // array of Expression's
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 72
diff changeset
34 this(Loc loc, Identifier ident, Expressions args, Dsymbols decl)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 162
diff changeset
36 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 super(decl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 this.loc = loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 this.ident = ident;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 this.args = args;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
43 override Dsymbol syntaxCopy(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 //printf("PragmaDeclaration.syntaxCopy(%s)\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 PragmaDeclaration pd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 assert(!s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 pd = new PragmaDeclaration(loc, ident, Expression.arraySyntaxCopy(args), Dsymbol.arraySyntaxCopy(decl));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 return pd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
53 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 // Should be merged with PragmaStatement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 //printf("\tPragmaDeclaration.semantic '%s'\n",toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 if (ident == Id.msg)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 if (args)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 {
90
39648eb578f6 more Expressions work
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 84
diff changeset
62 foreach (e; args)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 e = e.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 if (e.op == TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 {
90
39648eb578f6 more Expressions work
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 84
diff changeset
68 auto se = cast(StringExp)e;
136
9d194c848e3a fixed a few null reference bugs, thx sagitario
Trass3r
parents: 130
diff changeset
69 writef("%s", se.toChars()[1..$-2]); // strip the '"'s, TODO: change to original?: /*se.len, cast(char*)se.string_*/
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 else
95
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 90
diff changeset
72 writef(e.toChars());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 writef("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 else if (ident == Id.lib)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 if (!args || args.dim != 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 error("string expected for library name");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 77
diff changeset
84 auto e = args[0];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 e = e.optimize(WANTvalue | WANTinterpret);
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 77
diff changeset
88 args[0] = e;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 if (e.op != TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 error("string expected for library name, not '%s'", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 else if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 StringExp se = cast(StringExp)e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 writef("library %.*s\n", cast(int)se.len, cast(char*)se.string_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 /// version (IN_GCC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 /// else if (ident == Id.GNU_asm)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 /// {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 /// if (! args || args.dim != 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 /// error("identifier and string expected for asm name");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 /// else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 /// {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 /// Expression *e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 /// Declaration *d = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 /// StringExp *s = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 /// e = (Expression *)args.data[0];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 /// e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 /// if (e.op == TOKvar)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 /// {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 /// d = ((VarExp *)e).var;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 /// if (! d.isFuncDeclaration() && ! d.isVarDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 /// d = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 /// if (!d)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 /// error("first argument of GNU_asm must be a function or variable declaration");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 /// e = (Expression *)args.data[1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 /// e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 /// e = e.optimize(WANTvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 /// if (e.op == TOKstring && ((StringExp *)e).sz == 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 /// s = ((StringExp *)e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 /// else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 /// error("second argument of GNU_asm must be a char string");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 /// if (d && s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 /// d.c_ident = Lexer.idPool((char*) s.string);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 /// goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 /// }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 116
diff changeset
135 ///version(DMDV2) {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 else if (ident == Id.startaddress)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 if (!args || args.dim != 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 error("function name expected for start address");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 {
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 77
diff changeset
142 auto e = args[0];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 e = e.optimize(WANTvalue | WANTinterpret);
84
be2ab491772e Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 77
diff changeset
145 args[0] = e;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 Dsymbol sa = getDsymbol(e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 if (!sa || !sa.isFuncDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 error("function name expected for start address, not '%s'", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 116
diff changeset
152 ///}
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 /// version (TARGET_NET) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 /// else if (ident == Lexer.idPool("assembly"))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 /// {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 /// } // TARGET_NET
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 else if (global.params.ignoreUnsupportedPragmas)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 /* Print unrecognized pragmas
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 writef("pragma %s", ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 if (args)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 {
90
39648eb578f6 more Expressions work
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 84
diff changeset
167 foreach (size_t i, Expression e; args)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 e = e.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 if (i == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 writef(" (");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 writef(",");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 writef("%s", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 if (args.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 writef(")");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 writef("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 goto Lnodecl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 error("unrecognized pragma(%s)", ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 if (decl)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 {
77
ad4792a1cfd6 more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 74
diff changeset
189 foreach(Dsymbol s; decl)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 s.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 Lnodecl:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 if (decl)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 error("pragma is missing closing ';'");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
199 override void setScope(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 version (TARGET_NET) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 if (ident == Lexer.idPool("assembly"))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 if (!args || args.dim != 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 error("pragma has invalid number of arguments");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 Expression e = cast(Expression)args.data[0];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 e = e.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 args.data[0] = cast(void*)e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 if (e.op != TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 error("string expected, not '%s'", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 PragmaScope pragma_ = new PragmaScope(this, sc.parent, cast(StringExp)e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 assert(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 pragma_.setScope(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 //add to module members
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 assert(sc.module_);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 assert(sc.module_.members);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 sc.module_.members.push(cast(void*)pragma_);
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 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
232 override bool oneMember(Dsymbol* ps)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 {
162
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 136
diff changeset
234 *ps = null;
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 136
diff changeset
235 return true;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
238 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
243 override string kind()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
248 override void toObjFile(int multiobj) // compile to .obj file
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 if (ident == Id.lib)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 assert(args && args.dim == 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253
90
39648eb578f6 more Expressions work
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 84
diff changeset
254 auto e = args[0];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 assert(e.op == TOKstring);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257
90
39648eb578f6 more Expressions work
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 84
diff changeset
258 auto se = cast(StringExp)e;
180
0622fff7810a Fixed a few memory allocation related issues
korDen
parents: 178
diff changeset
259 char* name = cast(char*)malloc(se.len + 1);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 memcpy(name, se.string_, se.len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 name[se.len] = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 version (OMFOBJ) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 /* The OMF format allows library names to be inserted
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 * into the object file. The linker will then automatically
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 * search that library, too.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 obj_includelib(name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 } else version (ELFOBJ_OR_MACHOBJ) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 /* The format does not allow embedded library names,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 * so instead append the library name to the list to be passed
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 * to the linker.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 global.params.libfiles.push(cast(void*) name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 error("pragma lib not supported");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 /// version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 else if (ident == Id.startaddress)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 assert(args && args.dim == 1);
90
39648eb578f6 more Expressions work
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 84
diff changeset
282 auto e = args[0];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 Dsymbol sa = getDsymbol(e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 FuncDeclaration f = sa.isFuncDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 assert(f);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 Symbol* s = f.toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 obj_startaddress(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 AttribDeclaration.toObjFile(multiobj);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 }
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
292 }