annotate dmd/AliasDeclaration.d @ 179:cd48cb899aee

Updated to dmd2.040
author korDen
date Sun, 17 Oct 2010 20:56:07 +0400
parents e3afd1303184
children b0d41ff5e0df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.AliasDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 98
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.LINK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Declaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.TypedefDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.VarDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.FuncAliasDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.ScopeDsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.STC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 class AliasDeclaration : Declaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 {
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
24 Dsymbol aliassym;
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
25 Dsymbol overnext; // next in overload list
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
26 int inSemantic;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
28 this(Loc loc, Identifier ident, Type type)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 174
diff changeset
30 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 super(ident);
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
32
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 //printf("AliasDeclaration(id = '%s', type = %p)\n", id.toChars(), type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 //printf("type = '%s'\n", type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 this.loc = loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 this.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 this.aliassym = null;
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
38 version (_DH) {
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
39 this.htype = null;
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
40 this.haliassym = null;
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
41 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 assert(type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
45
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
46 this(Loc loc, Identifier id, Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 174
diff changeset
48 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 super(id);
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
50
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 //printf("AliasDeclaration(id = '%s', s = %p)\n", id->toChars(), s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 assert(s !is this); /// huh?
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 this.loc = loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 this.type = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 this.aliassym = s;
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
56 version (_DH) {
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
57 this.htype = null;
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
58 this.haliassym = null;
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
59 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 assert(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
62
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 16
diff changeset
63 override Dsymbol syntaxCopy(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 {
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
65 //printf("AliasDeclaration::syntaxCopy()\n");
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
66 assert(!s);
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
67 AliasDeclaration sa;
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
68 if (type)
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
69 sa = new AliasDeclaration(loc, ident, type.syntaxCopy());
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
70 else
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
71 sa = new AliasDeclaration(loc, ident, aliassym.syntaxCopy(null));
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
72 version (_DH) {
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
73 // Syntax copy for header file
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
74 if (!htype) // Don't overwrite original
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
75 { if (type) // Make copy for both old and new instances
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
76 { htype = type.syntaxCopy();
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
77 sa.htype = type.syntaxCopy();
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
78 }
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
79 }
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
80 else // Make copy of original for new instance
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
81 sa.htype = htype.syntaxCopy();
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
82 if (!haliassym)
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
83 { if (aliassym)
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
84 { haliassym = aliassym.syntaxCopy(s);
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
85 sa.haliassym = aliassym.syntaxCopy(s);
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
86 }
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
87 }
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
88 else
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
89 sa.haliassym = haliassym.syntaxCopy(s);
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
90 } // version (_DH)
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
91 return sa;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
93
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 16
diff changeset
94 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 //printf("AliasDeclaration.semantic() %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 if (aliassym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 if (aliassym.isTemplateInstance())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 aliassym.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 this.inSemantic = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
105 version(DMDV1) { // don't really know why this is here
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 if (storage_class & STC.STCconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 error("cannot be const");
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
108 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 storage_class |= sc.stc & STC.STCdeprecated;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 // Given:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 // alias foo.bar.abc def;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 // it is not knowable from the syntax whether this is an alias
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 // for a type or an alias for a symbol. It is up to the semantic()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 // pass to distinguish.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 // If it is a type, then type is set and getType() will return that
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 // type. If it is a symbol, then aliassym is set and type is null -
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 // toAlias() will return aliasssym.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 Dsymbol s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 /* This section is needed because resolve() will:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 * const x = 3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 * alias x y;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 * try to alias y to 3.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 s = type.toDsymbol(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 if (s && ((s.getType() && type.equals(s.getType())) || s.isEnumMember()))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 goto L2; // it's a symbolic alias
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132
98
5c859d5fbe27 and more
Trass3r
parents: 79
diff changeset
133 ///version (DMDV2) {
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
134 type = type.addStorageClass(storage_class);
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
135 if (storage_class & (STC.STCref | STCnothrow | STCpure | STCdisable))
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 { // For 'ref' to be attached to function types, and picked
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 // up by Type.resolve(), it has to go into sc.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 sc = sc.push();
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
139 sc.stc |= storage_class & (STCref | STCnothrow | STCpure | STCshared | STCdisable);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 type.resolve(loc, sc, &e, &t, &s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 sc = sc.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 else
98
5c859d5fbe27 and more
Trass3r
parents: 79
diff changeset
144 /// #endif
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
145 type.resolve(loc, sc, &e, &t, &s);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 if (s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 else if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 // Try to convert Expression to Dsymbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 s = getDsymbol(e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 if (s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 error("cannot alias an expression %s", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 t = e.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 else if (t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 type = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 if (overnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 ScopeDsymbol.multiplyDefined(Loc(0), this, overnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 this.inSemantic = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
169 L2:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 //printf("alias is a symbol %s %s\n", s.kind(), s.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 type = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 VarDeclaration v = s.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 if (v && v.linkage == LINK.LINKdefault)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 error("forward reference of %s", v.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 s = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 FuncDeclaration f = s.toAlias().isFuncDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 if (f)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 if (overnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 FuncAliasDeclaration fa = new FuncAliasDeclaration(f);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 if (!fa.overloadInsert(overnext))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 ScopeDsymbol.multiplyDefined(Loc(0), f, overnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 overnext = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 s = fa;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 s.parent = sc.parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 if (overnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 ScopeDsymbol.multiplyDefined(Loc(0), s, overnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 if (s == this)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 assert(global.errors);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 s = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 //printf("setting aliassym %p to %p\n", this, s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 aliassym = s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 this.inSemantic = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
205
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 16
diff changeset
206 override bool overloadInsert(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 /* Don't know yet what the aliased symbol is, so assume it can
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 * be overloaded and check later for correctness.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 //printf("AliasDeclaration.overloadInsert('%s')\n", s.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 if (overnext is null)
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
214 {
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
215 static if (true)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
216 {
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
217 if (s is this)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
218 return true;
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
219 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 overnext = s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 return true;
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
222
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 return overnext.overloadInsert(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
229
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 16
diff changeset
230 override string kind()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 return "alias";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
234
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 16
diff changeset
235 override Type getType()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 return type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
239
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 16
diff changeset
240 override Dsymbol toAlias()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 //printf("AliasDeclaration::toAlias('%s', this = %p, aliassym = %p, kind = '%s')\n", toChars(), this, aliassym, aliassym ? aliassym->kind() : "");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 assert(this !is aliassym);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 //static int count; if (++count == 10) *(char*)0=0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 if (inSemantic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 error("recursive alias declaration");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 aliassym = new TypedefDeclaration(loc, ident, Type.terror, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 Dsymbol s = aliassym ? aliassym.toAlias() : this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 return s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
254
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 16
diff changeset
255 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 {
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
257 buf.writestring("alias ");
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
258 /// static if (false) { // && _DH
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
259 /// if (hgs.hdrgen)
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
260 /// {
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
261 /// if (haliassym)
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
262 /// {
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
263 /// haliassym.toCBuffer(buf, hgs);
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
264 /// buf.writeByte(' ');
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
265 /// buf.writestring(ident.toChars());
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
266 /// }
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
267 /// else
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
268 /// htype.toCBuffer(buf, ident, hgs);
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
269 /// }
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
270 /// else
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
271 /// }
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
272 {
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
273 if (aliassym)
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
274 {
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
275 aliassym.toCBuffer(buf, hgs);
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
276 buf.writeByte(' ');
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
277 buf.writestring(ident.toChars());
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
278 }
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
279 else
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
280 type.toCBuffer(buf, ident, hgs);
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
281 }
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
282 buf.writeByte(';');
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
283 buf.writenl();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
286 version (_DH) {
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
287 Type htype;
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
288 Dsymbol haliassym;
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
289 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 16
diff changeset
290 override void toDocBuffer(OutBuffer buf)
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
291 {
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
292 assert(false);
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
293 }
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
294
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 16
diff changeset
295 override AliasDeclaration isAliasDeclaration() { return this; }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
296 }