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
|
98
|
20 version(DMDV2)
|
0
|
21 class PostBlitDeclaration : FuncDeclaration
|
|
22 {
|
98
|
23 this(Loc loc, Loc endloc)
|
0
|
24 {
|
178
|
25 register();
|
47
|
26 super(loc, endloc, Id._postblit, STCundefined, null);
|
0
|
27 }
|
|
28
|
98
|
29 this(Loc loc, Loc endloc, Identifier id)
|
0
|
30 {
|
178
|
31 register();
|
98
|
32 super(loc, loc, id, STCundefined, null);
|
0
|
33 }
|
|
34
|
98
|
35 override Dsymbol syntaxCopy(Dsymbol s)
|
0
|
36 {
|
98
|
37 assert(!s);
|
|
38 PostBlitDeclaration dd = new PostBlitDeclaration(loc, endloc, ident);
|
|
39 return super.syntaxCopy(dd);
|
0
|
40 }
|
|
41
|
98
|
42 override void semantic(Scope sc)
|
0
|
43 {
|
98
|
44 //writef("PostBlitDeclaration.semantic() %s\n", toChars());
|
|
45 //writef("ident: %s, %s, %p, %p\n", ident.toChars(), Id.dtor.toChars(), ident, Id.dtor);
|
179
|
46 //writef("stc = x%llx\n", sc.stc);
|
98
|
47 parent = sc.parent;
|
|
48 Dsymbol parent = toParent();
|
|
49 StructDeclaration ad = parent.isStructDeclaration();
|
|
50 if (!ad)
|
|
51 {
|
|
52 error("post blits are only for struct/union definitions, not %s %s", parent.kind(), parent.toChars());
|
|
53 }
|
|
54 else if (ident == Id._postblit && semanticRun < PASSsemantic)
|
|
55 ad.postblits.push(this);
|
|
56
|
|
57 if (!type)
|
|
58 type = new TypeFunction(null, Type.tvoid, false, LINKd);
|
|
59
|
|
60 sc = sc.push();
|
|
61 sc.stc &= ~STCstatic; // not static
|
|
62 sc.linkage = LINKd;
|
|
63
|
|
64 FuncDeclaration.semantic(sc);
|
|
65
|
|
66 sc.pop();
|
0
|
67 }
|
|
68
|
98
|
69 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
0
|
70 {
|
98
|
71 buf.writestring("this(this)");
|
|
72 bodyToCBuffer(buf, hgs);
|
0
|
73 }
|
|
74
|
79
|
75 override void toJsonBuffer(OutBuffer buf)
|
|
76 {
|
98
|
77 // intentionally empty
|
79
|
78 }
|
|
79
|
98
|
80 override bool isVirtual()
|
0
|
81 {
|
98
|
82 return false;
|
0
|
83 }
|
|
84
|
98
|
85 override bool addPreInvariant()
|
0
|
86 {
|
98
|
87 return false;
|
0
|
88 }
|
|
89
|
98
|
90 override bool addPostInvariant()
|
0
|
91 {
|
98
|
92 return (isThis() && vthis && global.params.useInvariants);
|
0
|
93 }
|
|
94
|
98
|
95 override bool overloadInsert(Dsymbol s)
|
0
|
96 {
|
98
|
97 return false; // cannot overload postblits
|
0
|
98 }
|
|
99
|
98
|
100 override void emitComment(Scope sc)
|
0
|
101 {
|
98
|
102 // intentionally empty
|
0
|
103 }
|
|
104
|
98
|
105 override PostBlitDeclaration isPostBlitDeclaration() { return this; }
|
|
106 } |