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