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