annotate dmd/Package.d @ 169:e7769d53e750

Moves static variables from Module to Global
author korDen
date Thu, 30 Sep 2010 13:29:54 +0400
parents e6e542f37b94
children e3afd1303184
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.Package;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.ScopeDsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Identifier;
128
e6e542f37b94 Some more Array -> Vector conversions
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
6 import dmd.ArrayTypes;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.DsymbolTable;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Module;
169
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 128
diff changeset
11 import dmd.Global;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 class Package : ScopeDsymbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 this(Identifier ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 super(ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
21 override string kind()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
128
e6e542f37b94 Some more Array -> Vector conversions
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
26 static DsymbolTable resolve(Identifiers packages, Dsymbol* pparent, Package* ppkg)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 {
169
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 128
diff changeset
28 DsymbolTable dst = global.modules;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 Dsymbol parent = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 //printf("Package::resolve()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 if (ppkg)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 *ppkg = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 if (packages)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
128
e6e542f37b94 Some more Array -> Vector conversions
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
37 foreach (pid; packages)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 Dsymbol p = dst.lookup(pid);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 if (!p)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 p = new Package(pid);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 dst.insert(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 p.parent = parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 (cast(ScopeDsymbol)p).symtab = new DsymbolTable();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 assert(p.isPackage());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 version (TARGET_NET) { //dot net needs modules and packages with same name
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 if (p.isModule())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 p.error("module and package have the same name");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 parent = p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 dst = (cast(Package)p).symtab;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 if (ppkg && !*ppkg)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 *ppkg = cast(Package)p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 if (pparent)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 *pparent = parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 return dst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
73 override Package isPackage() { return this; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
75 override void semantic(Scope sc) { }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
76 }