Mercurial > projects > ddmd
annotate dmd/PostBlitDeclaration.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 | cd48cb899aee |
children |
rev | line source |
---|---|
0 | 1 module dmd.PostBlitDeclaration; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.FuncDeclaration; |
98 | 5 import dmd.Global; |
6 import dmd.LINK; | |
7 import dmd.LinkDeclaration; | |
0 | 8 import dmd.Loc; |
9 import dmd.Identifier; | |
10 import dmd.Dsymbol; | |
11 import dmd.Scope; | |
98 | 12 import dmd.StructDeclaration; |
0 | 13 import dmd.OutBuffer; |
14 import dmd.HdrGenState; | |
15 import dmd.STC; | |
98 | 16 import dmd.Type; |
17 import dmd.TypeFunction; | |
47 | 18 import dmd.Id; |
0 | 19 |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
20 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
21 |
98 | 22 version(DMDV2) |
0 | 23 class PostBlitDeclaration : FuncDeclaration |
24 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
25 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
26 |
98 | 27 this(Loc loc, Loc endloc) |
0 | 28 { |
178 | 29 register(); |
47 | 30 super(loc, endloc, Id._postblit, STCundefined, null); |
0 | 31 } |
32 | |
98 | 33 this(Loc loc, Loc endloc, Identifier id) |
0 | 34 { |
178 | 35 register(); |
98 | 36 super(loc, loc, id, STCundefined, null); |
0 | 37 } |
38 | |
98 | 39 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 40 { |
98 | 41 assert(!s); |
42 PostBlitDeclaration dd = new PostBlitDeclaration(loc, endloc, ident); | |
43 return super.syntaxCopy(dd); | |
0 | 44 } |
45 | |
98 | 46 override void semantic(Scope sc) |
0 | 47 { |
98 | 48 //writef("PostBlitDeclaration.semantic() %s\n", toChars()); |
49 //writef("ident: %s, %s, %p, %p\n", ident.toChars(), Id.dtor.toChars(), ident, Id.dtor); | |
179 | 50 //writef("stc = x%llx\n", sc.stc); |
98 | 51 parent = sc.parent; |
52 Dsymbol parent = toParent(); | |
53 StructDeclaration ad = parent.isStructDeclaration(); | |
54 if (!ad) | |
55 { | |
56 error("post blits are only for struct/union definitions, not %s %s", parent.kind(), parent.toChars()); | |
57 } | |
58 else if (ident == Id._postblit && semanticRun < PASSsemantic) | |
59 ad.postblits.push(this); | |
60 | |
61 if (!type) | |
62 type = new TypeFunction(null, Type.tvoid, false, LINKd); | |
63 | |
64 sc = sc.push(); | |
65 sc.stc &= ~STCstatic; // not static | |
66 sc.linkage = LINKd; | |
67 | |
68 FuncDeclaration.semantic(sc); | |
69 | |
70 sc.pop(); | |
0 | 71 } |
72 | |
98 | 73 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 74 { |
98 | 75 buf.writestring("this(this)"); |
76 bodyToCBuffer(buf, hgs); | |
0 | 77 } |
78 | |
79 | 79 override void toJsonBuffer(OutBuffer buf) |
80 { | |
98 | 81 // intentionally empty |
79 | 82 } |
83 | |
98 | 84 override bool isVirtual() |
0 | 85 { |
98 | 86 return false; |
0 | 87 } |
88 | |
98 | 89 override bool addPreInvariant() |
0 | 90 { |
98 | 91 return false; |
0 | 92 } |
93 | |
98 | 94 override bool addPostInvariant() |
0 | 95 { |
98 | 96 return (isThis() && vthis && global.params.useInvariants); |
0 | 97 } |
98 | |
98 | 99 override bool overloadInsert(Dsymbol s) |
0 | 100 { |
98 | 101 return false; // cannot overload postblits |
0 | 102 } |
103 | |
98 | 104 override void emitComment(Scope sc) |
0 | 105 { |
98 | 106 // intentionally empty |
0 | 107 } |
108 | |
98 | 109 override PostBlitDeclaration isPostBlitDeclaration() { return this; } |
110 } |