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