comparison dmd2/import.c @ 847:356e65836fb5

Merged DMD 2.021 frontend. Removed generated files from dmd/dmd2 dirs.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sat, 13 Dec 2008 16:14:37 +0100
parents f04dde6e882c
children 638d16625da2
comparison
equal deleted inserted replaced
846:bc982f1ad106 847:356e65836fb5
182 if (aliasId) 182 if (aliasId)
183 return mod; 183 return mod;
184 return this; 184 return this;
185 } 185 }
186 186
187 /*****************************
188 * Add import to sd's symbol table.
189 */
190
187 int Import::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) 191 int Import::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
188 { 192 {
189 int result = 0; 193 int result = 0;
190 194
191 if (names.dim == 0) 195 if (names.dim == 0)
192 return Dsymbol::addMember(sc, sd, memnum); 196 return Dsymbol::addMember(sc, sd, memnum);
193 197
194 if (aliasId) 198 if (aliasId)
195 result = Dsymbol::addMember(sc, sd, memnum); 199 result = Dsymbol::addMember(sc, sd, memnum);
196 200
201 /* Instead of adding the import to sd's symbol table,
202 * add each of the alias=name pairs
203 */
197 for (size_t i = 0; i < names.dim; i++) 204 for (size_t i = 0; i < names.dim; i++)
198 { 205 {
199 Identifier *name = (Identifier *)names.data[i]; 206 Identifier *name = (Identifier *)names.data[i];
200 Identifier *alias = (Identifier *)aliases.data[i]; 207 Identifier *alias = (Identifier *)aliases.data[i];
201 208
202 if (!alias) 209 if (!alias)
203 alias = name; 210 alias = name;
204 211
205 #if 1
206 TypeIdentifier *tname = new TypeIdentifier(loc, name); 212 TypeIdentifier *tname = new TypeIdentifier(loc, name);
207 #else
208 TypeIdentifier *tname = new TypeIdentifier(loc, NULL);
209 if (packages)
210 {
211 for (size_t j = 0; j < packages->dim; j++)
212 { Identifier *pid = (Identifier *)packages->data[j];
213
214 if (!tname->ident)
215 tname->ident = pid;
216 else
217 tname->addIdent(pid);
218 }
219 }
220 if (!tname->ident)
221 tname->ident = id;
222 else
223 tname->addIdent(id);
224 tname->addIdent(name);
225 #endif
226 AliasDeclaration *ad = new AliasDeclaration(loc, alias, tname); 213 AliasDeclaration *ad = new AliasDeclaration(loc, alias, tname);
227 result |= ad->addMember(sc, sd, memnum); 214 result |= ad->addMember(sc, sd, memnum);
228 215
229 aliasdecls.push(ad); 216 aliasdecls.push(ad);
230 } 217 }