comparison dmd/Package.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 2e2a5c3f943a
comparison
equal deleted inserted replaced
-1:000000000000 0:10317f0c89a5
1 module dmd.Package;
2
3 import dmd.ScopeDsymbol;
4 import dmd.Identifier;
5 import dmd.Array;
6 import dmd.DsymbolTable;
7 import dmd.Scope;
8 import dmd.Dsymbol;
9 import dmd.Module;
10 import dmd.Util;
11
12 class Package : ScopeDsymbol
13 {
14 this(Identifier ident)
15 {
16 super(ident);
17 }
18
19 string kind()
20 {
21 assert(false);
22 }
23
24 static DsymbolTable resolve(Array packages, Dsymbol* pparent, Package* ppkg)
25 {
26 DsymbolTable dst = Module.modules;
27 Dsymbol parent = null;
28
29 //printf("Package::resolve()\n");
30 if (ppkg)
31 *ppkg = null;
32
33 if (packages)
34 {
35 for (int i = 0; i < packages.dim; i++)
36 {
37 Identifier pid = cast(Identifier)packages.data[i];
38 Dsymbol p = dst.lookup(pid);
39 if (!p)
40 {
41 p = new Package(pid);
42 dst.insert(p);
43 p.parent = parent;
44 (cast(ScopeDsymbol)p).symtab = new DsymbolTable();
45 }
46 else
47 {
48 assert(p.isPackage());
49 version (TARGET_NET) { //dot net needs modules and packages with same name
50 } else {
51 if (p.isModule())
52 {
53 p.error("module and package have the same name");
54 fatal();
55 break;
56 }
57 }
58 }
59 parent = p;
60 dst = (cast(Package)p).symtab;
61 if (ppkg && !*ppkg)
62 *ppkg = cast(Package)p;
63 }
64 if (pparent)
65 {
66 *pparent = parent;
67 }
68 }
69 return dst;
70 }
71
72 Package isPackage() { return this; }
73
74 void semantic(Scope sc) { }
75 }