annotate dmd/Global.d @ 173:d237b38b5858

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