Mercurial > projects > ddmd
annotate dmd/Global.d @ 177:1475fd394c9e
bug fixes
author | korDen |
---|---|
date | Sun, 10 Oct 2010 10:38:55 +0400 |
parents | fa9a71a9f5a8 |
children | e3afd1303184 |
rev | line source |
---|---|
0 | 1 module dmd.Global; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Array; |
5 import dmd.Param; | |
166
d8565fbd755c
Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents:
138
diff
changeset
|
6 import dmd.ClassDeclaration; |
167
50a6d232176c
rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
korDen
parents:
166
diff
changeset
|
7 import dmd.DsymbolTable; |
168
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
8 import dmd.StringTable; |
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
9 import dmd.OutBuffer; |
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
10 import dmd.Token; |
170 | 11 import dmd.Scope; |
169 | 12 import dmd.Module; |
176 | 13 import dmd.Type; |
14 import dmd.TypeInfoDeclaration; | |
170 | 15 import dmd.Id; |
176 | 16 import dmd.TY; |
17 import dmd.LINK; | |
18 import dmd.MOD; | |
19 import dmd.Loc; | |
20 import dmd.TOK; | |
21 import dmd.TypeFunction; | |
170 | 22 |
23 import dmd.codegen.Util; | |
176 | 24 import dmd.backend.elem; |
170 | 25 import dmd.backend.Classsym; |
176 | 26 import dmd.backend.Symbol; |
27 import dmd.backend.glue; | |
28 import dmd.backend.iasm; | |
29 import dmd.backend.StringTab; | |
169 | 30 |
31 import core.stdc.time; | |
32 import core.stdc.stdio; | |
0 | 33 |
34 class Global | |
35 { | |
36 string mars_ext = "d"; | |
37 string sym_ext = "d"; | |
173 | 38 |
0 | 39 version (TARGET_WINDOS) { |
40 string obj_ext = "obj"; | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
41 } else version (POSIX) { // TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS |
0 | 42 string obj_ext = "o"; |
43 } else version (TARGET_NET) { | |
44 } else { | |
45 static assert (false); | |
46 } | |
47 | |
48 version (TARGET_WINDOS) { | |
49 string lib_ext = "lib"; | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
50 } else version (POSIX) { // TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS |
0 | 51 string lib_ext = "a"; |
52 } else version (TARGET_NET) { | |
53 } else { | |
54 static assert (false); | |
55 } | |
79 | 56 string doc_ext = "html"; // for Ddoc generated files |
57 string ddoc_ext = "ddoc"; // for Ddoc macro include files | |
58 string json_ext = "json"; | |
0 | 59 string hdr_ext = "di"; // for D 'header' import files |
60 string copyright= "Copyright (c) 1999-2009 by Digital Mars"; | |
75
cfa3747ebe4c
Changed dmd to ddmd in the "usage" message and added "ported to D by community" to desription to distinguish from pure dmd build
korDen
parents:
73
diff
changeset
|
61 string written = "written by Walter Bright, ported to D by community"; |
0 | 62 ///version (TARGET_NET) { |
63 /// "\nMSIL back-end (alpha release) by Cristian L. Vlasceanu and associates."; | |
64 ///} | |
173 | 65 |
0 | 66 string[] path; // Array of char*'s which form the import lookup path |
67 string[] filePath; // Array of char*'s which form the file import lookup path | |
68 int structalign = 8; | |
138 | 69 string version_ = "v2.039"; |
0 | 70 |
71 Param params; | |
72 uint errors; // number of errors reported so far | |
73 uint gag; // !=0 means gag reporting of errors | |
173 | 74 |
166
d8565fbd755c
Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents:
138
diff
changeset
|
75 ClassDeclaration object; |
d8565fbd755c
Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents:
138
diff
changeset
|
76 ClassDeclaration classinfo; |
173 | 77 |
167
50a6d232176c
rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
korDen
parents:
166
diff
changeset
|
78 // Used in FuncDeclaration.genCfunc() |
50a6d232176c
rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
korDen
parents:
166
diff
changeset
|
79 DsymbolTable st; |
173 | 80 |
168
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
81 // Used in Lexer.uniqueId() |
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
82 int num; |
173 | 83 |
168
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
84 // Used in Identifier.generateId() |
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
85 size_t i; |
173 | 86 |
168
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
87 // Used in Lexer |
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
88 StringTable stringtable; |
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
89 OutBuffer stringbuffer; |
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
90 Token* freelist; |
173 | 91 |
169 | 92 char date[11+1]; |
93 char time[8+1]; | |
94 char timestamp[24+1]; | |
173 | 95 |
169 | 96 // Used in Module |
97 Module rootModule; | |
98 DsymbolTable modules; // symbol table of all modules | |
99 Array amodules; // array of all modules | |
100 Array deferred; // deferred Dsymbol's needing semantic() run on them | |
101 uint dprogress; // progress resolving the deferred list | |
170 | 102 int nested; |
103 Classsym* scc; | |
104 ClassDeclaration moduleinfo; | |
173 | 105 |
170 | 106 // Used in PowExp |
107 bool importMathChecked = false; | |
173 | 108 |
170 | 109 // Used in Scope |
110 Scope scope_freelist; | |
173 | 111 |
170 | 112 // Used in TemplateMixin |
113 int nest; | |
176 | 114 |
174 | 115 // Used in Type |
116 StringTable type_stringtable; | |
176 | 117 |
118 Type tvoidptr; // void* | |
119 Type tstring; // immutable(char)[] | |
120 | |
174 | 121 ClassDeclaration typeinfo; |
122 ClassDeclaration typeinfoclass; | |
123 ClassDeclaration typeinfointerface; | |
124 ClassDeclaration typeinfostruct; | |
125 ClassDeclaration typeinfotypedef; | |
126 ClassDeclaration typeinfopointer; | |
127 ClassDeclaration typeinfoarray; | |
128 ClassDeclaration typeinfostaticarray; | |
129 ClassDeclaration typeinfoassociativearray; | |
130 ClassDeclaration typeinfoenum; | |
131 ClassDeclaration typeinfofunction; | |
132 ClassDeclaration typeinfodelegate; | |
133 ClassDeclaration typeinfotypelist; | |
134 ClassDeclaration typeinfoconst; | |
135 ClassDeclaration typeinfoinvariant; | |
136 ClassDeclaration typeinfoshared; | |
137 ClassDeclaration typeinfowild; | |
173 | 138 |
176 | 139 Type basic[TY.TMAX]; |
140 TypeInfoDeclaration internalTI[TMAX]; | |
141 | |
142 // Used in BinExp | |
143 StringTable arrayfuncs; | |
144 | |
145 // Used in FuncDeclaration | |
146 int hiddenparami; // how many we've generated so far | |
147 | |
148 // Used in TypeAArray | |
149 // Dumb linear symbol table - should use associative array! | |
150 Array sarray; | |
151 Symbol* AArray_s; | |
152 | |
153 // Used in TypeDelegate | |
154 Symbol* Delegate_s; | |
155 | |
156 // Used in TypeInfoStructDeclaration | |
157 TypeFunction tftohash; | |
158 TypeFunction tftostring; | |
159 | |
160 // Used in backend.glue | |
161 Array obj_symbols_towrite; | |
162 Outbuffer objbuf; | |
163 string lastmname; | |
164 int count; | |
165 | |
166 // Used in backend.iasm | |
167 ASM_STATE asmstate; | |
168 Token* asmtok; | |
169 TOK tok_value; | |
170 | |
171 // Used in backend.StringTab | |
172 StringTab[STSIZE] stringTab; | |
173 size_t stidx; | |
174 | |
175 // Used in backend.Util | |
176 elem* eictor; | |
177 Symbol* ictorlocalgot; | |
178 elem* ector; | |
179 Array ectorgates; | |
180 elem* edtor; | |
181 elem* etest; | |
182 int dtorcount; | |
183 Symbol* localgot; | |
184 | |
0 | 185 this() |
186 { | |
187 params.versionids = new Array(); | |
173 | 188 params.imppath = new Array(); |
176 | 189 |
167
50a6d232176c
rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
korDen
parents:
166
diff
changeset
|
190 st = new DsymbolTable(); |
168
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
191 stringtable = new StringTable(); |
ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
korDen
parents:
167
diff
changeset
|
192 stringbuffer = new OutBuffer(); |
173 | 193 |
169 | 194 modules = new DsymbolTable(); |
195 amodules = new Array(); | |
196 deferred = new Array(); | |
176 | 197 |
174 | 198 type_stringtable = new StringTable(); |
173 | 199 |
176 | 200 arrayfuncs = new StringTable(); |
201 | |
202 sarray = new Array(); | |
203 | |
204 obj_symbols_towrite = new Array(); | |
205 | |
206 ectorgates = new Array(); | |
207 | |
169 | 208 init_time(); |
209 } | |
173 | 210 |
170 | 211 void initClasssym() |
212 { | |
213 scc = fake_classsym(Id.ClassInfo); | |
177 | 214 |
215 scope Scope sc = new Scope(); | |
216 | |
217 tftohash = new TypeFunction(null, Type.thash_t, 0, LINK.LINKd); | |
218 tftohash.mod = MOD.MODconst; | |
219 tftohash = cast(TypeFunction)tftohash.semantic(Loc(0), sc); | |
220 | |
221 tftostring = new TypeFunction(null, Type.tchar.invariantOf().arrayOf(), 0, LINK.LINKd); | |
222 tftostring = cast(TypeFunction)tftostring.semantic(Loc(0), sc); | |
170 | 223 } |
173 | 224 |
169 | 225 void init_time() |
226 { | |
227 time_t tm; | |
228 char* p; | |
229 | |
230 .time(&tm); | |
231 p = ctime(&tm); | |
232 assert(p); | |
233 sprintf(date.ptr, "%.6s %.4s", p + 4, p + 20); | |
234 sprintf(time.ptr, "%.8s", p + 11); | |
235 sprintf(timestamp.ptr, "%.24s", p); | |
0 | 236 } |
237 } | |
238 | |
173 | 239 __gshared Global global; |