Mercurial > projects > dil
comparison trunk/src/dil/semantic/Pass1.d @ 713:1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Wed, 30 Jan 2008 23:23:58 +0100 |
parents | efa5fcb9aa14 |
children | 140469ecb90e |
comparison
equal
deleted
inserted
replaced
712:f8875ef9a66d | 713:1bfae3480fdc |
---|---|
140 Protection protection; | 140 Protection protection; |
141 StorageClass storageClass; | 141 StorageClass storageClass; |
142 uint alignSize; | 142 uint alignSize; |
143 } | 143 } |
144 | 144 |
145 // List of mixin, static if and pragma(msg,...) declarations. | 145 // List of mixin, static if, static assert and pragma(msg,...) declarations. |
146 // Their analysis must be deferred because they entail | 146 // Their analysis must be deferred because they entail |
147 // evaluation of expressions. | 147 // evaluation of expressions. |
148 Deferred[] deferred; | 148 Deferred[] deferred; |
149 | 149 |
150 void addDeferred(Node node) | 150 void addDeferred(Node node) |
295 d.decls && visitD(d.decls); | 295 d.decls && visitD(d.decls); |
296 exitScope(); | 296 exitScope(); |
297 return d; | 297 return d; |
298 } | 298 } |
299 | 299 |
300 D visit(ConstructorDeclaration) | 300 D visit(ConstructorDeclaration d) |
301 { return null; } | 301 { |
302 D visit(StaticConstructorDeclaration) | 302 auto func = new Function(Ident.__ctor, d); |
303 { return null; } | 303 insertOverload(func, func.name); |
304 D visit(DestructorDeclaration) | 304 return d; |
305 { return null; } | 305 } |
306 D visit(StaticDestructorDeclaration) | 306 |
307 { return null; } | 307 D visit(StaticConstructorDeclaration d) |
308 D visit(FunctionDeclaration) | 308 { |
309 { return null; } | 309 auto func = new Function(Ident.__ctor, d); |
310 insertOverload(func, func.name); | |
311 return d; | |
312 } | |
313 | |
314 D visit(DestructorDeclaration d) | |
315 { | |
316 auto func = new Function(Ident.__dtor, d); | |
317 insertOverload(func, func.name); | |
318 return d; | |
319 } | |
320 | |
321 D visit(StaticDestructorDeclaration d) | |
322 { | |
323 auto func = new Function(Ident.__dtor, d); | |
324 insertOverload(func, func.name); | |
325 return d; | |
326 } | |
327 | |
328 D visit(FunctionDeclaration d) | |
329 { | |
330 auto func = new Function(d.name, d); | |
331 insertOverload(func, func.name); | |
332 return d; | |
333 } | |
310 | 334 |
311 D visit(VariablesDeclaration vd) | 335 D visit(VariablesDeclaration vd) |
312 { | 336 { |
313 // Error if we are in an interface. | 337 // Error if we are in an interface. |
314 if (scop.symbol.isInterface) | 338 if (scop.symbol.isInterface) |
322 insert(variable, name); | 346 insert(variable, name); |
323 } | 347 } |
324 return vd; | 348 return vd; |
325 } | 349 } |
326 | 350 |
327 D visit(InvariantDeclaration) | 351 D visit(InvariantDeclaration d) |
328 { return null; } | 352 { |
329 D visit(UnittestDeclaration) | 353 auto func = new Function(Ident.__invariant, d); |
330 { return null; } | 354 insert(func, func.name); |
355 return d; | |
356 } | |
357 | |
358 D visit(UnittestDeclaration d) | |
359 { | |
360 auto func = new Function(Ident.__unittest, d); | |
361 insertOverload(func, func.name); | |
362 return d; | |
363 } | |
364 | |
331 D visit(DebugDeclaration) | 365 D visit(DebugDeclaration) |
332 { return null; } | 366 { return null; } |
333 D visit(VersionDeclaration) | 367 D visit(VersionDeclaration) |
334 { return null; } | |
335 | |
336 D visit(StaticAssertDeclaration) | |
337 { return null; } | 368 { return null; } |
338 | 369 |
339 D visit(TemplateDeclaration d) | 370 D visit(TemplateDeclaration d) |
340 { | 371 { |
341 if (d.symbol) | 372 if (d.symbol) |
348 visitD(d.decls); | 379 visitD(d.decls); |
349 exitScope(); | 380 exitScope(); |
350 return d; | 381 return d; |
351 } | 382 } |
352 | 383 |
353 D visit(NewDeclaration) | 384 D visit(NewDeclaration d) |
354 { /*add id to env*/return null; } | 385 { |
355 D visit(DeleteDeclaration) | 386 auto func = new Function(Ident.__new, d); |
356 { /*add id to env*/return null; } | 387 insert(func, func.name); |
388 return d; | |
389 } | |
390 | |
391 D visit(DeleteDeclaration d) | |
392 { | |
393 auto func = new Function(Ident.__delete, d); | |
394 insert(func, func.name); | |
395 return d; | |
396 } | |
357 | 397 |
358 D visit(ProtectionDeclaration d) | 398 D visit(ProtectionDeclaration d) |
359 { | 399 { |
360 auto saved = protection; // Save. | 400 auto saved = protection; // Save. |
361 protection = d.prot; // Set. | 401 protection = d.prot; // Set. |
389 visitD(d.decls); | 429 visitD(d.decls); |
390 alignSize = saved; // Restore. | 430 alignSize = saved; // Restore. |
391 return d; | 431 return d; |
392 } | 432 } |
393 | 433 |
434 // Deferred declarations: | |
435 | |
436 D visit(StaticAssertDeclaration d) | |
437 { | |
438 addDeferred(d); | |
439 return d; | |
440 } | |
441 | |
394 D visit(StaticIfDeclaration d) | 442 D visit(StaticIfDeclaration d) |
395 { | 443 { |
396 addDeferred(d); | 444 addDeferred(d); |
397 return d; | 445 return d; |
398 } | 446 } |