annotate dmd/Global.d @ 169:e7769d53e750

Moves static variables from Module to Global
author korDen
date Thu, 30 Sep 2010 13:29:54 +0400
parents ceed63f310fb
children 96c0fff6897d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 96
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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;
169
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
11 import dmd.Module;
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
12
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
13 import core.stdc.time;
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
14 import core.stdc.stdio;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 class Global
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 string mars_ext = "d";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 string sym_ext = "d";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 version (TARGET_WINDOS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 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
23 } else version (POSIX) { // TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 string obj_ext = "o";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 } else version (TARGET_NET) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 static assert (false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 version (TARGET_WINDOS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 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
32 } else version (POSIX) { // TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 string lib_ext = "a";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 } else version (TARGET_NET) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 static assert (false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 }
79
43073c7c7769 updated to 2.035
Trass3r
parents: 75
diff changeset
38 string doc_ext = "html"; // for Ddoc generated files
43073c7c7769 updated to 2.035
Trass3r
parents: 75
diff changeset
39 string ddoc_ext = "ddoc"; // for Ddoc macro include files
43073c7c7769 updated to 2.035
Trass3r
parents: 75
diff changeset
40 string json_ext = "json";
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 string hdr_ext = "di"; // for D 'header' import files
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 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
43 string written = "written by Walter Bright, ported to D by community";
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 ///version (TARGET_NET) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 /// "\nMSIL back-end (alpha release) by Cristian L. Vlasceanu and associates.";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 string[] path; // Array of char*'s which form the import lookup path
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 string[] filePath; // Array of char*'s which form the file import lookup path
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 int structalign = 8;
138
Trass3r
parents: 135
diff changeset
51 string version_ = "v2.039";
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 Param params;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 uint errors; // number of errors reported so far
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 uint gag; // !=0 means gag reporting of errors
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56
166
d8565fbd755c Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents: 138
diff changeset
57 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
58 ClassDeclaration classinfo;
d8565fbd755c Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents: 138
diff changeset
59
167
50a6d232176c rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
korDen
parents: 166
diff changeset
60 // Used in FuncDeclaration.genCfunc()
50a6d232176c rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
korDen
parents: 166
diff changeset
61 DsymbolTable st;
50a6d232176c rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
korDen
parents: 166
diff changeset
62
168
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
63 // Used in Lexer.uniqueId()
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
64 int num;
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
65
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
66 // Used in Identifier.generateId()
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
67 size_t i;
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
68
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
69 // Used in Lexer
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
70 StringTable stringtable;
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
71 OutBuffer stringbuffer;
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
72 Token* freelist;
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
73
169
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
74 char date[11+1];
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
75 char time[8+1];
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
76 char timestamp[24+1];
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
77
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
78 // Used in Module
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
79 Module rootModule;
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
80 DsymbolTable modules; // symbol table of all modules
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
81 Array amodules; // array of all modules
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
82 Array deferred; // deferred Dsymbol's needing semantic() run on them
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
83 uint dprogress; // progress resolving the deferred list
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
84
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
85 ClassDeclaration moduleinfo;
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
86
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 params.versionids = new Array();
167
50a6d232176c rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
korDen
parents: 166
diff changeset
90 st = new DsymbolTable();
168
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
91 stringtable = new StringTable();
ceed63f310fb stringtable, stringbuffer and freelist moved to Global
korDen
parents: 167
diff changeset
92 stringbuffer = new OutBuffer();
169
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
93
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
94 modules = new DsymbolTable();
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
95 amodules = new Array();
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
96 deferred = new Array();
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
97
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
98 init_time();
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
99 }
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
100
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
101 void init_time()
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
102 {
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
103 time_t tm;
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
104 char* p;
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
105
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
106 .time(&tm);
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
107 p = ctime(&tm);
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
108 assert(p);
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
109 sprintf(date.ptr, "%.6s %.4s", p + 4, p + 20);
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
110 sprintf(time.ptr, "%.8s", p + 11);
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 168
diff changeset
111 sprintf(timestamp.ptr, "%.24s", p);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
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
115 Global global;