annotate dmd/Package.d @ 128:e6e542f37b94

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