Mercurial > projects > ldc
annotate dmd/module.c @ 1596:42fc0d955a0d
Updated runtest to always rebuild libtangobos-partial.a in case of updates.
Changed std.stdarg to import ldc.vararg so it has the correct implementation.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Sun, 15 Nov 2009 13:22:02 +0000 |
parents | def7a1d494fd |
children | 44b145be2ef5 |
rev | line source |
---|---|
336 | 1 |
2 // Compiler implementation of the D programming language | |
1195
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
3 // Copyright (c) 1999-2009 by Digital Mars |
336 | 4 // All Rights Reserved |
5 // written by Walter Bright | |
6 // http://www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #include <stdio.h> | |
12 #include <stdlib.h> | |
13 #include <assert.h> | |
14 | |
872
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
751
diff
changeset
|
15 #if (defined (__SVR4) && defined (__sun)) |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
751
diff
changeset
|
16 #include <alloca.h> |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
751
diff
changeset
|
17 #endif |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
751
diff
changeset
|
18 |
1133
eeb8b95ea92e
Cleanup DMD 1.041 merge.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
19 #if defined(_MSC_VER) || defined(__MINGW32__) |
336 | 20 #include <malloc.h> |
21 #endif | |
22 | |
23 #if IN_GCC | |
24 #include "gdc_alloca.h" | |
25 #endif | |
26 | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
27 #include "rmem.h" |
336 | 28 |
29 #include "mars.h" | |
30 #include "module.h" | |
31 #include "parse.h" | |
32 #include "scope.h" | |
33 #include "identifier.h" | |
34 #include "id.h" | |
35 #include "import.h" | |
36 #include "dsymbol.h" | |
37 #include "hdrgen.h" | |
38 #include "lexer.h" | |
39 | |
40 #define MARS 1 | |
41 #include "html.h" | |
42 | |
43 #ifdef IN_GCC | |
44 #include "d-dmd-gcc.h" | |
45 #endif | |
46 | |
986
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
47 |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
48 #include "llvm/Support/CommandLine.h" |
1564
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
49 #include <map> |
986
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
50 |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
51 static llvm::cl::opt<bool> preservePaths("op", |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
52 llvm::cl::desc("Do not strip paths from source file"), |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
53 llvm::cl::ZeroOrMore); |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
54 |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
55 static llvm::cl::opt<bool> fqnNames("oq", |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
56 llvm::cl::desc("Write object files with fully qualified names"), |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
57 llvm::cl::ZeroOrMore); |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
58 |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
59 |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
60 |
336 | 61 ClassDeclaration *Module::moduleinfo; |
62 | |
63 Module *Module::rootModule; | |
64 DsymbolTable *Module::modules; | |
65 Array Module::amodules; | |
66 | |
67 Array Module::deferred; // deferred Dsymbol's needing semantic() run on them | |
68 unsigned Module::dprogress; | |
69 | |
70 void Module::init() | |
71 { | |
72 modules = new DsymbolTable(); | |
73 } | |
74 | |
75 Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen) | |
76 : Package(ident) | |
77 { | |
78 FileName *srcfilename; | |
79 | |
80 // printf("Module::Module(filename = '%s', ident = '%s')\n", filename, ident->toChars()); | |
81 this->arg = filename; | |
82 md = NULL; | |
83 errors = 0; | |
84 numlines = 0; | |
85 members = NULL; | |
86 isHtml = 0; | |
87 isDocFile = 0; | |
88 needmoduleinfo = 0; | |
89 #ifdef IN_GCC | |
90 strictlyneedmoduleinfo = 0; | |
91 #endif | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
92 selfimports = 0; |
336 | 93 insearch = 0; |
94 searchCacheIdent = NULL; | |
95 searchCacheSymbol = NULL; | |
96 searchCacheFlags = 0; | |
97 semanticstarted = 0; | |
1587 | 98 semanticRun = 0; |
336 | 99 decldefs = NULL; |
100 vmoduleinfo = NULL; | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1133
diff
changeset
|
101 #if IN_DMD |
336 | 102 massert = NULL; |
103 marray = NULL; | |
104 sictor = NULL; | |
105 sctor = NULL; | |
106 sdtor = NULL; | |
107 stest = NULL; | |
108 sfilename = NULL; | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1133
diff
changeset
|
109 #endif |
336 | 110 root = 0; |
111 importedFrom = NULL; | |
112 srcfile = NULL; | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
113 objfile = NULL; |
336 | 114 docfile = NULL; |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
115 hdrfile = NULL; |
336 | 116 |
117 debuglevel = 0; | |
118 debugids = NULL; | |
119 debugidsNot = NULL; | |
120 versionlevel = 0; | |
121 versionids = NULL; | |
122 versionidsNot = NULL; | |
123 | |
124 macrotable = NULL; | |
125 escapetable = NULL; | |
1587 | 126 safe = FALSE; |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1133
diff
changeset
|
127 #if IN_DMD |
336 | 128 doppelganger = 0; |
129 cov = NULL; | |
130 covb = NULL; | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1133
diff
changeset
|
131 #endif |
336 | 132 |
133 srcfilename = FileName::defaultExt(filename, global.mars_ext); | |
134 if (!srcfilename->equalsExt(global.mars_ext) && | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
135 !srcfilename->equalsExt(global.hdr_ext) && |
336 | 136 !srcfilename->equalsExt("dd")) |
137 { | |
138 if (srcfilename->equalsExt("html") || | |
139 srcfilename->equalsExt("htm") || | |
140 srcfilename->equalsExt("xhtml")) | |
141 isHtml = 1; | |
142 else | |
143 { error("source file name '%s' must have .%s extension", srcfilename->toChars(), global.mars_ext); | |
144 fatal(); | |
145 } | |
146 } | |
147 srcfile = new File(srcfilename); | |
148 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
643
diff
changeset
|
149 // LDC |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
150 llvmForceLogging = false; |
604
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
151 this->doDocComment = doDocComment; |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
152 this->doHdrGen = doHdrGen; |
336 | 153 } |
154 | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
155 File* Module::buildFilePath(const char* forcename, const char* path, const char* ext) |
336 | 156 { |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
157 const char *argobj; |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
158 if (forcename) |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
159 argobj = forcename; |
336 | 160 else |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
161 { |
986
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
162 if (preservePaths) |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
163 argobj = (char*)this->arg; |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
164 else |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
165 argobj = FileName::name((char*)this->arg); |
336 | 166 |
986
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
957
diff
changeset
|
167 if (fqnNames) |
643 | 168 { |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
169 if(md) |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
170 argobj = FileName::replaceName((char*)argobj, md->toChars()); |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
171 else |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
172 argobj = FileName::replaceName((char*)argobj, toChars()); |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
173 |
643 | 174 // add ext, otherwise forceExt will make nested.module into nested.bc |
175 size_t len = strlen(argobj); | |
176 size_t extlen = strlen(ext); | |
177 char* s = (char *)alloca(len + 1 + extlen + 1); | |
178 memcpy(s, argobj, len); | |
179 s[len] = '.'; | |
180 memcpy(s + len + 1, ext, extlen + 1); | |
181 s[len+1+extlen] = 0; | |
182 argobj = s; | |
183 } | |
336 | 184 } |
185 | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
186 if (!FileName::absolute(argobj)) |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
187 { |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
188 argobj = FileName::combine(path, argobj); |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
189 } |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
190 |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
191 FileName::ensurePathExists(FileName::path(argobj)); |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
192 |
708
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
193 // always append the extension! otherwise hard to make output switches consistent |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
194 // if (forcename) |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
195 // return new File(argobj); |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
196 // else |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
197 // allow for .o and .obj on windows |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
198 #if _WIN32 |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
199 if (ext == global.params.objdir && FileName::ext(argobj) |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
200 && stricmp(FileName::ext(argobj), global.obj_ext_alt) == 0) |
1257
7af860e4f403
Changes for mingw to compile properly
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1195
diff
changeset
|
201 return new File((char*)argobj); |
708
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
202 #endif |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
203 return new File(FileName::forceExt(argobj, ext)); |
336 | 204 } |
205 | |
1564
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
206 // LDC |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
207 static void check_and_add_output_file(Module* NewMod, const std::string& str) |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
208 { |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
209 typedef std::map<std::string, Module*> map_t; |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
210 static map_t files; |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
211 |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
212 map_t::iterator i = files.find(str); |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
213 if (i != files.end()) |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
214 { |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
215 Module* ThisMod = i->second; |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
216 error("Output file '%s' for module '%s' collides with previous module '%s'. See the -oq option", |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
217 str.c_str(), NewMod->toPrettyChars(), ThisMod->toPrettyChars()); |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
218 fatal(); |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
219 } |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
220 files.insert(std::make_pair(str, NewMod)); |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
221 } |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
222 |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
223 void Module::buildTargetFiles() |
336 | 224 { |
604
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
225 if(objfile && |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
226 (!doDocComment || docfile) && |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
227 (!doHdrGen || hdrfile)) |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
228 return; |
336 | 229 |
604
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
230 if(!objfile) |
675
bfe5229f9d8e
Disable bc output by default. Remove -dis. Add -output-bc, -output-ll, -output-s.
Christian Kamm <kamm incasoftware de>
parents:
664
diff
changeset
|
231 objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.obj_ext); |
604
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
232 if(doDocComment && !docfile) |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
233 docfile = Module::buildFilePath(global.params.docname, global.params.docdir, global.doc_ext); |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
234 if(doHdrGen && !hdrfile) |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
235 hdrfile = Module::buildFilePath(global.params.hdrname, global.params.hdrdir, global.hdr_ext); |
598
13ff06605226
To prevert source-overwriting in the future, forbit output files with the same
Christian Kamm <kamm incasoftware de>
parents:
597
diff
changeset
|
236 |
13ff06605226
To prevert source-overwriting in the future, forbit output files with the same
Christian Kamm <kamm incasoftware de>
parents:
597
diff
changeset
|
237 // safety check: never allow obj, doc or hdr file to have the source file's name |
604
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
238 if(stricmp(FileName::name(objfile->name->str), FileName::name((char*)this->arg)) == 0) |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
239 { |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
240 error("Output object files with the same name as the source file are forbidden"); |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
241 fatal(); |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
242 } |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
243 if(docfile && stricmp(FileName::name(docfile->name->str), FileName::name((char*)this->arg)) == 0) |
598
13ff06605226
To prevert source-overwriting in the future, forbit output files with the same
Christian Kamm <kamm incasoftware de>
parents:
597
diff
changeset
|
244 { |
604
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
245 error("Output doc files with the same name as the source file are forbidden"); |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
246 fatal(); |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
247 } |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
248 if(hdrfile && stricmp(FileName::name(hdrfile->name->str), FileName::name((char*)this->arg)) == 0) |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
249 { |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
250 error("Output header files with the same name as the source file are forbidden"); |
598
13ff06605226
To prevert source-overwriting in the future, forbit output files with the same
Christian Kamm <kamm incasoftware de>
parents:
597
diff
changeset
|
251 fatal(); |
13ff06605226
To prevert source-overwriting in the future, forbit output files with the same
Christian Kamm <kamm incasoftware de>
parents:
597
diff
changeset
|
252 } |
1564
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
253 |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
254 // LDC |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
255 // another safety check to make sure we don't overwrite previous output files |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
256 check_and_add_output_file(this, objfile->name->str); |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
257 if (docfile) |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
258 check_and_add_output_file(this, docfile->name->str); |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
259 if (hdrfile) |
68dea5bae9e9
Added check and error in case two same named modules - with different packages and compiled at once - would overwrite each other's output files.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1257
diff
changeset
|
260 check_and_add_output_file(this, hdrfile->name->str); |
336 | 261 } |
262 | |
263 void Module::deleteObjFile() | |
264 { | |
265 if (global.params.obj) | |
266 objfile->remove(); | |
267 //if (global.params.llvmBC) | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
268 //bcfile->remove(); |
604
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
598
diff
changeset
|
269 if (doDocComment && docfile) |
336 | 270 docfile->remove(); |
271 } | |
272 | |
273 Module::~Module() | |
274 { | |
275 } | |
276 | |
277 const char *Module::kind() | |
278 { | |
279 return "module"; | |
280 } | |
281 | |
282 Module *Module::load(Loc loc, Array *packages, Identifier *ident) | |
283 { Module *m; | |
284 char *filename; | |
285 | |
286 //printf("Module::load(ident = '%s')\n", ident->toChars()); | |
287 | |
288 // Build module filename by turning: | |
289 // foo.bar.baz | |
290 // into: | |
291 // foo\bar\baz | |
292 filename = ident->toChars(); | |
293 if (packages && packages->dim) | |
294 { | |
295 OutBuffer buf; | |
296 int i; | |
297 | |
298 for (i = 0; i < packages->dim; i++) | |
299 { Identifier *pid = (Identifier *)packages->data[i]; | |
300 | |
301 buf.writestring(pid->toChars()); | |
302 #if _WIN32 | |
303 buf.writeByte('\\'); | |
304 #else | |
305 buf.writeByte('/'); | |
306 #endif | |
307 } | |
308 buf.writestring(filename); | |
309 buf.writeByte(0); | |
310 filename = (char *)buf.extractData(); | |
311 } | |
312 | |
313 m = new Module(filename, ident, 0, 0); | |
314 m->loc = loc; | |
315 | |
316 /* Search along global.path for .di file, then .d file. | |
317 */ | |
318 char *result = NULL; | |
319 FileName *fdi = FileName::forceExt(filename, global.hdr_ext); | |
320 FileName *fd = FileName::forceExt(filename, global.mars_ext); | |
321 char *sdi = fdi->toChars(); | |
322 char *sd = fd->toChars(); | |
323 | |
324 if (FileName::exists(sdi)) | |
325 result = sdi; | |
326 else if (FileName::exists(sd)) | |
327 result = sd; | |
328 else if (FileName::absolute(filename)) | |
329 ; | |
330 else if (!global.path) | |
331 ; | |
332 else | |
333 { | |
334 for (size_t i = 0; i < global.path->dim; i++) | |
335 { | |
336 char *p = (char *)global.path->data[i]; | |
337 char *n = FileName::combine(p, sdi); | |
338 if (FileName::exists(n)) | |
339 { result = n; | |
340 break; | |
341 } | |
342 mem.free(n); | |
343 n = FileName::combine(p, sd); | |
344 if (FileName::exists(n)) | |
345 { result = n; | |
346 break; | |
347 } | |
348 mem.free(n); | |
349 } | |
350 } | |
351 if (result) | |
352 m->srcfile = new File(result); | |
353 | |
354 if (global.params.verbose) | |
355 { | |
356 printf("import "); | |
357 if (packages) | |
358 { | |
359 for (size_t i = 0; i < packages->dim; i++) | |
360 { Identifier *pid = (Identifier *)packages->data[i]; | |
361 printf("%s.", pid->toChars()); | |
362 } | |
363 } | |
364 printf("%s\t(%s)\n", ident->toChars(), m->srcfile->toChars()); | |
365 } | |
366 | |
367 m->read(loc); | |
368 m->parse(); | |
369 | |
370 #ifdef IN_GCC | |
371 d_gcc_magic_module(m); | |
372 #endif | |
373 | |
374 return m; | |
375 } | |
376 | |
377 void Module::read(Loc loc) | |
378 { | |
379 //printf("Module::read('%s') file '%s'\n", toChars(), srcfile->toChars()); | |
380 if (srcfile->read()) | |
381 { error(loc, "cannot read file '%s'", srcfile->toChars()); | |
382 fatal(); | |
383 } | |
384 } | |
385 | |
386 inline unsigned readwordLE(unsigned short *p) | |
387 { | |
388 #if __I86__ | |
389 return *p; | |
390 #else | |
391 return (((unsigned char *)p)[1] << 8) | ((unsigned char *)p)[0]; | |
392 #endif | |
393 } | |
394 | |
395 inline unsigned readwordBE(unsigned short *p) | |
396 { | |
397 return (((unsigned char *)p)[0] << 8) | ((unsigned char *)p)[1]; | |
398 } | |
399 | |
400 inline unsigned readlongLE(unsigned *p) | |
401 { | |
402 #if __I86__ | |
403 return *p; | |
404 #else | |
405 return ((unsigned char *)p)[0] | | |
406 (((unsigned char *)p)[1] << 8) | | |
407 (((unsigned char *)p)[2] << 16) | | |
408 (((unsigned char *)p)[3] << 24); | |
409 #endif | |
410 } | |
411 | |
412 inline unsigned readlongBE(unsigned *p) | |
413 { | |
414 return ((unsigned char *)p)[3] | | |
415 (((unsigned char *)p)[2] << 8) | | |
416 (((unsigned char *)p)[1] << 16) | | |
417 (((unsigned char *)p)[0] << 24); | |
418 } | |
419 | |
420 #if IN_GCC | |
421 void Module::parse(bool dump_source) | |
422 #else | |
423 void Module::parse() | |
424 #endif | |
425 { char *srcname; | |
426 unsigned char *buf; | |
427 unsigned buflen; | |
428 unsigned le; | |
429 unsigned bom; | |
430 | |
431 //printf("Module::parse()\n"); | |
432 | |
433 srcname = srcfile->name->toChars(); | |
434 //printf("Module::parse(srcname = '%s')\n", srcname); | |
435 | |
436 buf = srcfile->buffer; | |
437 buflen = srcfile->len; | |
438 | |
439 if (buflen >= 2) | |
440 { | |
441 /* Convert all non-UTF-8 formats to UTF-8. | |
442 * BOM : http://www.unicode.org/faq/utf_bom.html | |
443 * 00 00 FE FF UTF-32BE, big-endian | |
444 * FF FE 00 00 UTF-32LE, little-endian | |
445 * FE FF UTF-16BE, big-endian | |
446 * FF FE UTF-16LE, little-endian | |
447 * EF BB BF UTF-8 | |
448 */ | |
449 | |
450 bom = 1; // assume there's a BOM | |
451 if (buf[0] == 0xFF && buf[1] == 0xFE) | |
452 { | |
453 if (buflen >= 4 && buf[2] == 0 && buf[3] == 0) | |
454 { // UTF-32LE | |
455 le = 1; | |
456 | |
457 Lutf32: | |
458 OutBuffer dbuf; | |
459 unsigned *pu = (unsigned *)(buf); | |
460 unsigned *pumax = &pu[buflen / 4]; | |
461 | |
462 if (buflen & 3) | |
463 { error("odd length of UTF-32 char source %u", buflen); | |
464 fatal(); | |
465 } | |
466 | |
467 dbuf.reserve(buflen / 4); | |
468 for (pu += bom; pu < pumax; pu++) | |
469 { unsigned u; | |
470 | |
471 u = le ? readlongLE(pu) : readlongBE(pu); | |
472 if (u & ~0x7F) | |
473 { | |
474 if (u > 0x10FFFF) | |
475 { error("UTF-32 value %08x greater than 0x10FFFF", u); | |
476 fatal(); | |
477 } | |
478 dbuf.writeUTF8(u); | |
479 } | |
480 else | |
481 dbuf.writeByte(u); | |
482 } | |
483 dbuf.writeByte(0); // add 0 as sentinel for scanner | |
484 buflen = dbuf.offset - 1; // don't include sentinel in count | |
485 buf = (unsigned char *) dbuf.extractData(); | |
486 } | |
487 else | |
488 { // UTF-16LE (X86) | |
489 // Convert it to UTF-8 | |
490 le = 1; | |
491 | |
492 Lutf16: | |
493 OutBuffer dbuf; | |
494 unsigned short *pu = (unsigned short *)(buf); | |
495 unsigned short *pumax = &pu[buflen / 2]; | |
496 | |
497 if (buflen & 1) | |
498 { error("odd length of UTF-16 char source %u", buflen); | |
499 fatal(); | |
500 } | |
501 | |
502 dbuf.reserve(buflen / 2); | |
503 for (pu += bom; pu < pumax; pu++) | |
504 { unsigned u; | |
505 | |
506 u = le ? readwordLE(pu) : readwordBE(pu); | |
507 if (u & ~0x7F) | |
508 { if (u >= 0xD800 && u <= 0xDBFF) | |
509 { unsigned u2; | |
510 | |
511 if (++pu > pumax) | |
512 { error("surrogate UTF-16 high value %04x at EOF", u); | |
513 fatal(); | |
514 } | |
515 u2 = le ? readwordLE(pu) : readwordBE(pu); | |
516 if (u2 < 0xDC00 || u2 > 0xDFFF) | |
517 { error("surrogate UTF-16 low value %04x out of range", u2); | |
518 fatal(); | |
519 } | |
520 u = (u - 0xD7C0) << 10; | |
521 u |= (u2 - 0xDC00); | |
522 } | |
523 else if (u >= 0xDC00 && u <= 0xDFFF) | |
524 { error("unpaired surrogate UTF-16 value %04x", u); | |
525 fatal(); | |
526 } | |
527 else if (u == 0xFFFE || u == 0xFFFF) | |
528 { error("illegal UTF-16 value %04x", u); | |
529 fatal(); | |
530 } | |
531 dbuf.writeUTF8(u); | |
532 } | |
533 else | |
534 dbuf.writeByte(u); | |
535 } | |
536 dbuf.writeByte(0); // add 0 as sentinel for scanner | |
537 buflen = dbuf.offset - 1; // don't include sentinel in count | |
538 buf = (unsigned char *) dbuf.extractData(); | |
539 } | |
540 } | |
541 else if (buf[0] == 0xFE && buf[1] == 0xFF) | |
542 { // UTF-16BE | |
543 le = 0; | |
544 goto Lutf16; | |
545 } | |
546 else if (buflen >= 4 && buf[0] == 0 && buf[1] == 0 && buf[2] == 0xFE && buf[3] == 0xFF) | |
547 { // UTF-32BE | |
548 le = 0; | |
549 goto Lutf32; | |
550 } | |
551 else if (buflen >= 3 && buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF) | |
552 { // UTF-8 | |
553 | |
554 buf += 3; | |
555 buflen -= 3; | |
556 } | |
557 else | |
558 { | |
559 /* There is no BOM. Make use of Arcane Jill's insight that | |
560 * the first char of D source must be ASCII to | |
561 * figure out the encoding. | |
562 */ | |
563 | |
564 bom = 0; | |
565 if (buflen >= 4) | |
566 { if (buf[1] == 0 && buf[2] == 0 && buf[3] == 0) | |
567 { // UTF-32LE | |
568 le = 1; | |
569 goto Lutf32; | |
570 } | |
571 else if (buf[0] == 0 && buf[1] == 0 && buf[2] == 0) | |
572 { // UTF-32BE | |
573 le = 0; | |
574 goto Lutf32; | |
575 } | |
576 } | |
577 if (buflen >= 2) | |
578 { | |
579 if (buf[1] == 0) | |
580 { // UTF-16LE | |
581 le = 1; | |
582 goto Lutf16; | |
583 } | |
584 else if (buf[0] == 0) | |
585 { // UTF-16BE | |
586 le = 0; | |
587 goto Lutf16; | |
588 } | |
589 } | |
590 | |
591 // It's UTF-8 | |
592 if (buf[0] >= 0x80) | |
593 { error("source file must start with BOM or ASCII character, not \\x%02X", buf[0]); | |
594 fatal(); | |
595 } | |
596 } | |
597 } | |
598 | |
599 #ifdef IN_GCC | |
1133
eeb8b95ea92e
Cleanup DMD 1.041 merge.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
600 // dump utf-8 encoded source |
336 | 601 if (dump_source) |
602 { // %% srcname could contain a path ... | |
603 d_gcc_dump_source(srcname, "utf-8", buf, buflen); | |
604 } | |
605 #endif | |
606 | |
607 /* If it starts with the string "Ddoc", then it's a documentation | |
608 * source file. | |
609 */ | |
610 if (buflen >= 4 && memcmp(buf, "Ddoc", 4) == 0) | |
611 { | |
612 comment = buf + 4; | |
613 isDocFile = 1; | |
614 return; | |
615 } | |
616 if (isHtml) | |
617 { | |
618 OutBuffer *dbuf = new OutBuffer(); | |
619 Html h(srcname, buf, buflen); | |
620 h.extractCode(dbuf); | |
621 buf = dbuf->data; | |
622 buflen = dbuf->offset; | |
623 #ifdef IN_GCC | |
624 // dump extracted source | |
625 if (dump_source) | |
626 d_gcc_dump_source(srcname, "d.utf-8", buf, buflen); | |
627 #endif | |
628 } | |
629 Parser p(this, buf, buflen, docfile != NULL); | |
630 p.nextToken(); | |
631 members = p.parseModule(); | |
632 md = p.md; | |
633 numlines = p.loc.linnum; | |
634 | |
635 DsymbolTable *dst; | |
636 | |
637 if (md) | |
638 { this->ident = md->id; | |
639 dst = Package::resolve(md->packages, &this->parent, NULL); | |
640 } | |
641 else | |
642 { | |
643 dst = modules; | |
644 | |
645 /* Check to see if module name is a valid identifier | |
646 */ | |
647 if (!Lexer::isValidIdentifier(this->ident->toChars())) | |
648 error("has non-identifier characters in filename, use module declaration instead"); | |
649 } | |
650 | |
651 // Update global list of modules | |
652 if (!dst->insert(this)) | |
653 { | |
654 if (md) | |
655 error(loc, "is in multiple packages %s", md->toChars()); | |
656 else | |
657 error(loc, "is in multiple defined"); | |
658 } | |
659 else | |
660 { | |
661 amodules.push(this); | |
662 } | |
663 } | |
664 | |
1587 | 665 void Module::importAll(Scope *prevsc) |
666 { | |
667 //printf("+Module::importAll(this = %p, '%s'): parent = %p\n", this, toChars(), parent); | |
668 | |
669 if (scope) | |
670 return; // already done | |
671 | |
672 /* Note that modules get their own scope, from scratch. | |
673 * This is so regardless of where in the syntax a module | |
674 * gets imported, it is unaffected by context. | |
675 * Ignore prevsc. | |
676 */ | |
677 Scope *sc = Scope::createGlobal(this); // create root scope | |
678 | |
679 // Add import of "object" if this module isn't "object" | |
680 if (ident != Id::object) | |
681 { | |
682 if (members->dim == 0 || ((Dsymbol *)members->data[0])->ident != Id::object) | |
683 { | |
684 Import *im = new Import(0, NULL, Id::object, NULL, 0); | |
685 members->shift(im); | |
686 } | |
687 } | |
336 | 688 |
1587 | 689 if (!symtab) |
690 { | |
691 // Add all symbols into module's symbol table | |
692 symtab = new DsymbolTable(); | |
693 for (int i = 0; i < members->dim; i++) | |
694 { | |
695 Dsymbol *s = (Dsymbol *)members->data[i]; | |
696 s->addMember(NULL, sc->scopesym, 1); | |
697 } | |
698 } | |
699 // anything else should be run after addMember, so version/debug symbols are defined | |
700 | |
701 /* Set scope for the symbols so that if we forward reference | |
702 * a symbol, it can possibly be resolved on the spot. | |
703 * If this works out well, it can be extended to all modules | |
704 * before any semantic() on any of them. | |
705 */ | |
706 setScope(sc); // remember module scope for semantic | |
707 for (int i = 0; i < members->dim; i++) | |
708 { Dsymbol *s = (Dsymbol *)members->data[i]; | |
709 s->setScope(sc); | |
710 } | |
711 | |
712 for (int i = 0; i < members->dim; i++) | |
713 { | |
714 Dsymbol *s = (Dsymbol *)members->data[i]; | |
715 s->importAll(sc); | |
716 } | |
717 | |
718 sc = sc->pop(); | |
719 sc->pop(); // 2 pops because Scope::createGlobal() created 2 | |
720 } | |
721 | |
722 void Module::semantic(Scope *unused_sc) | |
723 { | |
336 | 724 if (semanticstarted) |
725 return; | |
726 | |
727 //printf("+Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); | |
728 semanticstarted = 1; | |
729 | |
730 // Note that modules get their own scope, from scratch. | |
731 // This is so regardless of where in the syntax a module | |
732 // gets imported, it is unaffected by context. | |
1587 | 733 Scope *sc = scope; // see if already got one from importAll() |
734 if (!sc) | |
735 { printf("test2\n"); | |
736 Scope::createGlobal(this); // create root scope | |
737 } | |
336 | 738 |
739 //printf("Module = %p, linkage = %d\n", sc->scopesym, sc->linkage); | |
740 | |
1587 | 741 #if 0 |
336 | 742 // Add import of "object" if this module isn't "object" |
743 if (ident != Id::object) | |
744 { | |
745 Import *im = new Import(0, NULL, Id::object, NULL, 0); | |
746 members->shift(im); | |
747 } | |
748 | |
749 // Add all symbols into module's symbol table | |
750 symtab = new DsymbolTable(); | |
1587 | 751 for (int i = 0; i < members->dim; i++) |
752 { Dsymbol *s = (Dsymbol *)members->data[i]; | |
336 | 753 s->addMember(NULL, sc->scopesym, 1); |
754 } | |
755 | |
1587 | 756 /* Set scope for the symbols so that if we forward reference |
757 * a symbol, it can possibly be resolved on the spot. | |
758 * If this works out well, it can be extended to all modules | |
759 * before any semantic() on any of them. | |
760 */ | |
761 for (int i = 0; i < members->dim; i++) | |
762 { Dsymbol *s = (Dsymbol *)members->data[i]; | |
763 s->setScope(sc); | |
764 } | |
765 #endif | |
766 | |
336 | 767 // Pass 1 semantic routines: do public side of the definition |
1587 | 768 for (int i = 0; i < members->dim; i++) |
769 { Dsymbol *s = (Dsymbol *)members->data[i]; | |
336 | 770 |
771 //printf("\tModule('%s'): '%s'.semantic()\n", toChars(), s->toChars()); | |
772 s->semantic(sc); | |
773 runDeferredSemantic(); | |
774 } | |
775 | |
1587 | 776 if (!scope) |
777 { sc = sc->pop(); | |
778 sc->pop(); // 2 pops because Scope::createGlobal() created 2 | |
779 } | |
780 semanticRun = semanticstarted; | |
336 | 781 //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); |
782 } | |
783 | |
751
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
708
diff
changeset
|
784 void Module::semantic2(Scope* unused_sc) |
336 | 785 { int i; |
786 | |
787 if (deferred.dim) | |
788 { | |
789 for (int i = 0; i < deferred.dim; i++) | |
790 { | |
791 Dsymbol *sd = (Dsymbol *)deferred.data[i]; | |
792 | |
793 sd->error("unable to resolve forward reference in definition"); | |
794 } | |
795 return; | |
796 } | |
797 //printf("Module::semantic2('%s'): parent = %p\n", toChars(), parent); | |
798 if (semanticstarted >= 2) | |
799 return; | |
800 assert(semanticstarted == 1); | |
801 semanticstarted = 2; | |
802 | |
803 // Note that modules get their own scope, from scratch. | |
804 // This is so regardless of where in the syntax a module | |
805 // gets imported, it is unaffected by context. | |
806 Scope *sc = Scope::createGlobal(this); // create root scope | |
807 //printf("Module = %p\n", sc.scopesym); | |
808 | |
809 // Pass 2 semantic routines: do initializers and function bodies | |
810 for (i = 0; i < members->dim; i++) | |
811 { Dsymbol *s; | |
812 | |
813 s = (Dsymbol *)members->data[i]; | |
814 s->semantic2(sc); | |
815 } | |
816 | |
817 sc = sc->pop(); | |
818 sc->pop(); | |
1587 | 819 semanticRun = semanticstarted; |
336 | 820 //printf("-Module::semantic2('%s'): parent = %p\n", toChars(), parent); |
821 } | |
822 | |
751
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
708
diff
changeset
|
823 void Module::semantic3(Scope* unused_sc) |
336 | 824 { int i; |
825 | |
826 //printf("Module::semantic3('%s'): parent = %p\n", toChars(), parent); | |
827 if (semanticstarted >= 3) | |
828 return; | |
829 assert(semanticstarted == 2); | |
830 semanticstarted = 3; | |
831 | |
832 // Note that modules get their own scope, from scratch. | |
833 // This is so regardless of where in the syntax a module | |
834 // gets imported, it is unaffected by context. | |
835 Scope *sc = Scope::createGlobal(this); // create root scope | |
836 //printf("Module = %p\n", sc.scopesym); | |
837 | |
838 // Pass 3 semantic routines: do initializers and function bodies | |
839 for (i = 0; i < members->dim; i++) | |
840 { Dsymbol *s; | |
841 | |
842 s = (Dsymbol *)members->data[i]; | |
843 //printf("Module %s: %s.semantic3()\n", toChars(), s->toChars()); | |
844 s->semantic3(sc); | |
845 } | |
846 | |
847 sc = sc->pop(); | |
848 sc->pop(); | |
1587 | 849 semanticRun = semanticstarted; |
336 | 850 } |
851 | |
852 void Module::inlineScan() | |
1587 | 853 { |
336 | 854 if (semanticstarted >= 4) |
855 return; | |
856 assert(semanticstarted == 3); | |
857 semanticstarted = 4; | |
858 | |
859 // Note that modules get their own scope, from scratch. | |
860 // This is so regardless of where in the syntax a module | |
861 // gets imported, it is unaffected by context. | |
862 //printf("Module = %p\n", sc.scopesym); | |
863 | |
1587 | 864 for (int i = 0; i < members->dim; i++) |
865 { Dsymbol *s = (Dsymbol *)members->data[i]; | |
336 | 866 //if (global.params.verbose) |
867 //printf("inline scan symbol %s\n", s->toChars()); | |
868 | |
869 s->inlineScan(); | |
870 } | |
1587 | 871 semanticRun = semanticstarted; |
336 | 872 } |
873 | |
874 /**************************************************** | |
875 */ | |
876 | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
877 // is this used anywhere? |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
878 /* |
336 | 879 void Module::gensymfile() |
880 { | |
881 OutBuffer buf; | |
882 HdrGenState hgs; | |
883 | |
884 //printf("Module::gensymfile()\n"); | |
885 | |
886 buf.printf("// Sym file generated from '%s'", srcfile->toChars()); | |
887 buf.writenl(); | |
888 | |
889 for (int i = 0; i < members->dim; i++) | |
890 { Dsymbol *s = (Dsymbol *)members->data[i]; | |
891 | |
892 s->toCBuffer(&buf, &hgs); | |
893 } | |
894 | |
895 // Transfer image to file | |
896 symfile->setbuffer(buf.data, buf.offset); | |
897 buf.data = NULL; | |
898 | |
899 symfile->writev(); | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
900 }*/ |
336 | 901 |
902 /********************************** | |
903 * Determine if we need to generate an instance of ModuleInfo | |
904 * for this Module. | |
905 */ | |
906 | |
907 int Module::needModuleInfo() | |
908 { | |
550
cbe08531430f
Removed unimplemented switches.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
510
diff
changeset
|
909 return needmoduleinfo; |
336 | 910 } |
911 | |
912 Dsymbol *Module::search(Loc loc, Identifier *ident, int flags) | |
913 { | |
914 /* Since modules can be circularly referenced, | |
915 * need to stop infinite recursive searches. | |
1587 | 916 * This is done with the cache. |
336 | 917 */ |
918 | |
919 //printf("%s Module::search('%s', flags = %d) insearch = %d\n", toChars(), ident->toChars(), flags, insearch); | |
920 Dsymbol *s; | |
921 if (insearch) | |
922 s = NULL; | |
923 else if (searchCacheIdent == ident && searchCacheFlags == flags) | |
1587 | 924 { |
336 | 925 s = searchCacheSymbol; |
1587 | 926 //printf("%s Module::search('%s', flags = %d) insearch = %d searchCacheSymbol = %s\n", toChars(), ident->toChars(), flags, insearch, searchCacheSymbol ? searchCacheSymbol->toChars() : "null"); |
927 } | |
336 | 928 else |
929 { | |
930 insearch = 1; | |
931 s = ScopeDsymbol::search(loc, ident, flags); | |
932 insearch = 0; | |
933 | |
934 searchCacheIdent = ident; | |
935 searchCacheSymbol = s; | |
936 searchCacheFlags = flags; | |
937 } | |
938 return s; | |
939 } | |
940 | |
1587 | 941 Dsymbol *Module::symtabInsert(Dsymbol *s) |
942 { | |
943 searchCacheIdent = 0; // symbol is inserted, so invalidate cache | |
944 return Package::symtabInsert(s); | |
945 } | |
946 | |
947 | |
336 | 948 /******************************************* |
949 * Can't run semantic on s now, try again later. | |
950 */ | |
951 | |
952 void Module::addDeferredSemantic(Dsymbol *s) | |
953 { | |
954 // Don't add it if it is already there | |
955 for (int i = 0; i < deferred.dim; i++) | |
956 { | |
957 Dsymbol *sd = (Dsymbol *)deferred.data[i]; | |
958 | |
959 if (sd == s) | |
960 return; | |
961 } | |
962 | |
963 //printf("Module::addDeferredSemantic('%s')\n", s->toChars()); | |
964 deferred.push(s); | |
965 } | |
966 | |
967 | |
968 /****************************************** | |
969 * Run semantic() on deferred symbols. | |
970 */ | |
971 | |
972 void Module::runDeferredSemantic() | |
973 { | |
974 size_t len; | |
975 | |
976 static int nested; | |
977 if (nested) | |
978 return; | |
979 //if (deferred.dim) printf("+Module::runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); | |
980 nested++; | |
981 | |
982 do | |
983 { | |
984 dprogress = 0; | |
985 len = deferred.dim; | |
986 if (!len) | |
987 break; | |
988 | |
989 Dsymbol **todo; | |
990 Dsymbol *tmp; | |
991 if (len == 1) | |
992 { | |
993 todo = &tmp; | |
994 } | |
995 else | |
996 { | |
997 todo = (Dsymbol **)alloca(len * sizeof(Dsymbol *)); | |
998 assert(todo); | |
999 } | |
1000 memcpy(todo, deferred.data, len * sizeof(Dsymbol *)); | |
1001 deferred.setDim(0); | |
1002 | |
1003 for (int i = 0; i < len; i++) | |
1004 { | |
1005 Dsymbol *s = todo[i]; | |
1006 | |
1007 s->semantic(NULL); | |
1008 //printf("deferred: %s, parent = %s\n", s->toChars(), s->parent->toChars()); | |
1009 } | |
1010 //printf("\tdeferred.dim = %d, len = %d, dprogress = %d\n", deferred.dim, len, dprogress); | |
1011 } while (deferred.dim < len || dprogress); // while making progress | |
1012 nested--; | |
1013 //printf("-Module::runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); | |
1014 } | |
1015 | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1016 /************************************ |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1017 * Recursively look at every module this module imports, |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1018 * return TRUE if it imports m. |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1019 * Can be used to detect circular imports. |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1020 */ |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1021 |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1022 int Module::imports(Module *m) |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1023 { |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1024 //printf("%s Module::imports(%s)\n", toChars(), m->toChars()); |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1025 int aimports_dim = aimports.dim; |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1026 #if 0 |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1027 for (int i = 0; i < aimports.dim; i++) |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1028 { Module *mi = (Module *)aimports.data[i]; |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1029 printf("\t[%d] %s\n", i, mi->toChars()); |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1030 } |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1031 #endif |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1032 for (int i = 0; i < aimports.dim; i++) |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1033 { Module *mi = (Module *)aimports.data[i]; |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1034 if (mi == m) |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1035 return TRUE; |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1036 if (!mi->insearch) |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1037 { |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1038 mi->insearch = 1; |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1039 int r = mi->imports(m); |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1040 if (r) |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1041 return r; |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1042 } |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1043 } |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1044 return FALSE; |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1045 } |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
872
diff
changeset
|
1046 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1047 /************************************* |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1048 * Return !=0 if module imports itself. |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1049 */ |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1050 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1051 int Module::selfImports() |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1052 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1053 //printf("Module::selfImports() %s\n", toChars()); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1054 if (!selfimports) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1055 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1056 for (int i = 0; i < amodules.dim; i++) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1057 { Module *mi = (Module *)amodules.data[i]; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1058 //printf("\t[%d] %s\n", i, mi->toChars()); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1059 mi->insearch = 0; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1060 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1061 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1062 selfimports = imports(this) + 1; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1063 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1064 for (int i = 0; i < amodules.dim; i++) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1065 { Module *mi = (Module *)amodules.data[i]; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1066 //printf("\t[%d] %s\n", i, mi->toChars()); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1067 mi->insearch = 0; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1068 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1069 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1070 return selfimports - 1; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1071 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1072 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1073 |
336 | 1074 /* =========================== ModuleDeclaration ===================== */ |
1075 | |
1076 ModuleDeclaration::ModuleDeclaration(Array *packages, Identifier *id) | |
1077 { | |
1078 this->packages = packages; | |
1079 this->id = id; | |
1080 } | |
1081 | |
1082 char *ModuleDeclaration::toChars() | |
1083 { | |
1084 OutBuffer buf; | |
1085 int i; | |
1086 | |
1087 if (packages && packages->dim) | |
1088 { | |
1089 for (i = 0; i < packages->dim; i++) | |
1090 { Identifier *pid = (Identifier *)packages->data[i]; | |
1091 | |
1092 buf.writestring(pid->toChars()); | |
1093 buf.writeByte('.'); | |
1094 } | |
1095 } | |
1096 buf.writestring(id->toChars()); | |
1097 buf.writeByte(0); | |
1098 return (char *)buf.extractData(); | |
1099 } | |
1100 | |
1101 /* =========================== Package ===================== */ | |
1102 | |
1103 Package::Package(Identifier *ident) | |
1104 : ScopeDsymbol(ident) | |
1105 { | |
1106 } | |
1107 | |
1108 | |
1109 const char *Package::kind() | |
1110 { | |
1111 return "package"; | |
1112 } | |
1113 | |
1114 | |
1115 DsymbolTable *Package::resolve(Array *packages, Dsymbol **pparent, Package **ppkg) | |
1116 { | |
1117 DsymbolTable *dst = Module::modules; | |
1118 Dsymbol *parent = NULL; | |
1119 | |
1120 //printf("Package::resolve()\n"); | |
1121 if (ppkg) | |
1122 *ppkg = NULL; | |
1123 | |
1124 if (packages) | |
1125 { int i; | |
1126 | |
1127 for (i = 0; i < packages->dim; i++) | |
1128 { Identifier *pid = (Identifier *)packages->data[i]; | |
1129 Dsymbol *p; | |
1130 | |
1131 p = dst->lookup(pid); | |
1132 if (!p) | |
1133 { | |
1134 p = new Package(pid); | |
1135 dst->insert(p); | |
1136 p->parent = parent; | |
1137 ((ScopeDsymbol *)p)->symtab = new DsymbolTable(); | |
1138 } | |
1139 else | |
1140 { | |
1141 assert(p->isPackage()); | |
1587 | 1142 #if TARGET_NET //dot net needs modules and packages with same name |
1143 #else | |
336 | 1144 if (p->isModule()) |
1145 { p->error("module and package have the same name"); | |
1146 fatal(); | |
1147 break; | |
1148 } | |
1587 | 1149 #endif |
336 | 1150 } |
1151 parent = p; | |
1152 dst = ((Package *)p)->symtab; | |
1153 if (ppkg && !*ppkg) | |
1154 *ppkg = (Package *)p; | |
1155 } | |
1156 if (pparent) | |
1157 { | |
1158 *pparent = parent; | |
1159 } | |
1160 } | |
1161 return dst; | |
1162 } |