annotate dmd/Package.d @ 114:e28b18c23469

added a module dmd.common for commonly used stuff it currently holds code for consistency checking of predefined versions also added a VisualD project file
author Trass3r
date Wed, 01 Sep 2010 18:21:58 +0200
parents 2e2a5c3f943a
children e6e542f37b94
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;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Array;
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 static DsymbolTable resolve(Array packages, Dsymbol* pparent, Package* ppkg)
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 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 for (int i = 0; i < packages.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 Identifier pid = cast(Identifier)packages.data[i];
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 }