Mercurial > projects > ddmd
view dmd/Package.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | 2e2a5c3f943a |
line wrap: on
line source
module dmd.Package; import dmd.ScopeDsymbol; import dmd.Identifier; import dmd.Array; import dmd.DsymbolTable; import dmd.Scope; import dmd.Dsymbol; import dmd.Module; import dmd.Util; class Package : ScopeDsymbol { this(Identifier ident) { super(ident); } string kind() { assert(false); } static DsymbolTable resolve(Array packages, Dsymbol* pparent, Package* ppkg) { DsymbolTable dst = Module.modules; Dsymbol parent = null; //printf("Package::resolve()\n"); if (ppkg) *ppkg = null; if (packages) { for (int i = 0; i < packages.dim; i++) { Identifier pid = cast(Identifier)packages.data[i]; Dsymbol p = dst.lookup(pid); if (!p) { p = new Package(pid); dst.insert(p); p.parent = parent; (cast(ScopeDsymbol)p).symtab = new DsymbolTable(); } else { assert(p.isPackage()); version (TARGET_NET) { //dot net needs modules and packages with same name } else { if (p.isModule()) { p.error("module and package have the same name"); fatal(); break; } } } parent = p; dst = (cast(Package)p).symtab; if (ppkg && !*ppkg) *ppkg = cast(Package)p; } if (pparent) { *pparent = parent; } } return dst; } Package isPackage() { return this; } void semantic(Scope sc) { } }