Mercurial > projects > dil
comparison trunk/src/dil/Declarations.d @ 495:b60450804b6e
Attributes are evaluated during the parsing phase now.
Renamed parseDeclarationDefinitionsBlock to parseDeclarationDefinitionsBody.
Renamed parseDeclaration to parseVariableOrFunction.
Removed class Linkage, renamed parseLinkage to parseLinkageType and modified
it so that it returns a value from enum LinkageType.
Fix in parseStorageAttribute(): class invariants are recognized now.
Modified parseAlignAttribute() so that returns an uint - the alignment size.
Removed classes AttributeStatement and ExternStatement. Using Declarations
instead in parseAttributeStatement().
Added LinkageType to module Enums. Added StorageClassDeclaration and renamed
ExternDeclaration to LinkageDeclaration.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 08 Dec 2007 22:20:34 +0100 |
parents | 9a7ca8c56e59 |
children | 5a607597dc22 |
comparison
equal
deleted
inserted
replaced
494:9a7ca8c56e59 | 495:b60450804b6e |
---|---|
37 | 37 |
38 final bool isPublic() | 38 final bool isPublic() |
39 { | 39 { |
40 return !!(prot & Protection.Public); | 40 return !!(prot & Protection.Public); |
41 } | 41 } |
42 | |
43 final void setStorageClass(StorageClass stc) | |
44 { | |
45 this.stc = stc; | |
46 } | |
47 | |
48 final void setProtection(Protection prot) | |
49 { | |
50 this.prot = prot; | |
51 } | |
52 | |
42 } | 53 } |
43 | 54 |
44 class Declarations : Declaration | 55 class Declarations : Declaration |
45 { | 56 { |
46 this() | 57 this() |
269 class StructDeclaration : Declaration | 280 class StructDeclaration : Declaration |
270 { | 281 { |
271 Token* name; | 282 Token* name; |
272 TemplateParameters tparams; | 283 TemplateParameters tparams; |
273 Declarations decls; | 284 Declarations decls; |
285 uint alignSize; | |
274 this(Token* name, TemplateParameters tparams, Declarations decls) | 286 this(Token* name, TemplateParameters tparams, Declarations decls) |
275 { | 287 { |
276 super.hasBody = decls !is null; | 288 super.hasBody = decls !is null; |
277 mixin(set_kind); | 289 mixin(set_kind); |
278 addOptChild(tparams); | 290 addOptChild(tparams); |
279 addOptChild(decls); | 291 addOptChild(decls); |
280 | 292 |
281 this.name = name; | 293 this.name = name; |
282 this.tparams = tparams; | 294 this.tparams = tparams; |
283 this.decls = decls; | 295 this.decls = decls; |
296 } | |
297 | |
298 void setAlignSize(uint alignSize) | |
299 { | |
300 this.alignSize = alignSize; | |
284 } | 301 } |
285 } | 302 } |
286 | 303 |
287 class UnionDeclaration : Declaration | 304 class UnionDeclaration : Declaration |
288 { | 305 { |
362 Type returnType; | 379 Type returnType; |
363 Token* funcName; | 380 Token* funcName; |
364 TemplateParameters tparams; | 381 TemplateParameters tparams; |
365 Parameters params; | 382 Parameters params; |
366 FunctionBody funcBody; | 383 FunctionBody funcBody; |
384 LinkageType linkageType; | |
367 this(Type returnType, Token* funcName, TemplateParameters tparams, | 385 this(Type returnType, Token* funcName, TemplateParameters tparams, |
368 Parameters params, FunctionBody funcBody, StorageClass stc) | 386 Parameters params, FunctionBody funcBody) |
369 { | 387 { |
370 super.hasBody = funcBody.funcBody !is null; | 388 super.hasBody = funcBody.funcBody !is null; |
371 mixin(set_kind); | 389 mixin(set_kind); |
372 addChild(returnType); | 390 addChild(returnType); |
373 addOptChild(tparams); | 391 addOptChild(tparams); |
374 addChild(params); | 392 addChild(params); |
375 addChild(funcBody); | 393 addChild(funcBody); |
376 | 394 |
377 this.stc = stc; | |
378 this.returnType = returnType; | 395 this.returnType = returnType; |
379 this.funcName = funcName; | 396 this.funcName = funcName; |
380 this.tparams = tparams; | 397 this.tparams = tparams; |
381 this.params = params; | 398 this.params = params; |
382 this.funcBody = funcBody; | 399 this.funcBody = funcBody; |
383 } | 400 } |
401 | |
402 void setLinkageType(LinkageType linkageType) | |
403 { | |
404 this.linkageType = linkageType; | |
405 } | |
384 } | 406 } |
385 | 407 |
386 class VariableDeclaration : Declaration | 408 class VariableDeclaration : Declaration |
387 { | 409 { |
388 Type type; | 410 Type type; |
389 Token*[] idents; | 411 Token*[] idents; |
390 Expression[] values; | 412 Expression[] values; |
413 LinkageType linkageType; | |
391 this(Type type, Token*[] idents, Expression[] values) | 414 this(Type type, Token*[] idents, Expression[] values) |
392 { | 415 { |
393 mixin(set_kind); | 416 mixin(set_kind); |
394 addOptChild(type); | 417 addOptChild(type); |
395 foreach(value; values) | 418 foreach(value; values) |
396 addOptChild(value); | 419 addOptChild(value); |
397 | 420 |
398 this.type = type; | 421 this.type = type; |
399 this.idents = idents; | 422 this.idents = idents; |
400 this.values = values; | 423 this.values = values; |
424 } | |
425 | |
426 void setLinkageType(LinkageType linkageType) | |
427 { | |
428 this.linkageType = linkageType; | |
401 } | 429 } |
402 } | 430 } |
403 | 431 |
404 class InvariantDeclaration : Declaration | 432 class InvariantDeclaration : Declaration |
405 { | 433 { |
565 } | 593 } |
566 } | 594 } |
567 | 595 |
568 class ProtectionDeclaration : AttributeDeclaration | 596 class ProtectionDeclaration : AttributeDeclaration |
569 { | 597 { |
598 Protection prot; | |
570 this(Protection prot, Declaration decls) | 599 this(Protection prot, Declaration decls) |
571 { | 600 { |
572 super(cast(TOK)0, decls); | 601 super(cast(TOK)0, decls); |
573 mixin(set_kind); | 602 mixin(set_kind); |
574 super.prot = prot; | 603 this.prot = prot; |
575 } | 604 } |
576 | 605 |
577 void semantic(Scope scop) | 606 void semantic(Scope scop) |
578 { | 607 { |
579 // auto saved_prot = scop.protection; | 608 // auto saved_prot = scop.protection; |
581 // decls.semantic(scop); | 610 // decls.semantic(scop); |
582 // scop.protection = saved_prot; | 611 // scop.protection = saved_prot; |
583 } | 612 } |
584 } | 613 } |
585 | 614 |
586 class ExternDeclaration : AttributeDeclaration | 615 class StorageClassDeclaration : AttributeDeclaration |
587 { | 616 { |
588 Linkage linkage; | 617 StorageClass storageClass; |
589 this(Linkage linkage, Declaration decls) | 618 this(StorageClass storageClass, TOK tok, Declaration decl) |
619 { | |
620 super(tok, decl); | |
621 mixin(set_kind); | |
622 | |
623 this.storageClass = storageClass; | |
624 } | |
625 } | |
626 | |
627 class LinkageDeclaration : AttributeDeclaration | |
628 { | |
629 LinkageType linkageType; | |
630 this(LinkageType linkageType, Declaration decls) | |
590 { | 631 { |
591 super(TOK.Extern, decls); | 632 super(TOK.Extern, decls); |
592 mixin(set_kind); | 633 mixin(set_kind); |
593 addOptChild(linkage); | 634 |
594 | 635 this.linkageType = linkageType; |
595 this.linkage = linkage; | |
596 } | 636 } |
597 } | 637 } |
598 | 638 |
599 class AlignDeclaration : AttributeDeclaration | 639 class AlignDeclaration : AttributeDeclaration |
600 { | 640 { |