annotate dmd/Package.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents e7769d53e750
children b0d41ff5e0df
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 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 169
diff changeset
18 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 super(ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
22 override string kind()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
128
e6e542f37b94 Some more Array -> Vector conversions
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
27 static DsymbolTable resolve(Identifiers packages, Dsymbol* pparent, Package* ppkg)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 {
169
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 128
diff changeset
29 DsymbolTable dst = global.modules;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 Dsymbol parent = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 //printf("Package::resolve()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 if (ppkg)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 *ppkg = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 if (packages)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 {
128
e6e542f37b94 Some more Array -> Vector conversions
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
38 foreach (pid; packages)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 Dsymbol p = dst.lookup(pid);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 if (!p)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 p = new Package(pid);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 dst.insert(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 p.parent = parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 (cast(ScopeDsymbol)p).symtab = new DsymbolTable();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 assert(p.isPackage());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 version (TARGET_NET) { //dot net needs modules and packages with same name
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 if (p.isModule())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 p.error("module and package have the same name");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 parent = p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 dst = (cast(Package)p).symtab;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 if (ppkg && !*ppkg)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 *ppkg = cast(Package)p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 if (pparent)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 *pparent = parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 return dst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 }
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 Package isPackage() { return this; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
76 override void semantic(Scope sc) { }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
77 }