annotate dmd/Type.d @ 131:206db751bd4c

dmdfe 2.037 compiles now
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Fri, 10 Sep 2010 00:27:37 +0100
parents 60bb0fe4563e
children af1bebfd96a4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 113
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.TY;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
5 import dmd.Parameter;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.STC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.TypeArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.DotVarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.ErrorExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.StringExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.IntegerExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.VarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.TemplateParameter;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.TypeInfoSharedDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.TypeInfoConstDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.TypeInfoInvariantDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.Module;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.VarDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 import dmd.TypeInfoDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import dmd.ClassDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 import dmd.StringTable;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 import dmd.TypeBasic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 import dmd.DYNCAST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 import dmd.MOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 import dmd.Lexer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 import dmd.TypeSArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 import dmd.TypeDArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 import dmd.TypeAArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 import dmd.TypePointer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 import dmd.TypeReference;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 import dmd.TypeFunction;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 import dmd.TypeDelegate;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 import dmd.TypeIdentifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 import dmd.TypeInstance;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 import dmd.TypeTypeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 import dmd.TypeReturn;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 import dmd.TypeStruct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 import dmd.TypeEnum;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 import dmd.TypeTypedef;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 import dmd.TypeClass;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 import dmd.TypeTuple;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 import dmd.TypeSlice;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 import dmd.StringValue;
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
57 import dmd.TRUST;
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
58 import dmd.TemplateDeclaration;
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
59 import dmd.DotIdExp;
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
60 import dmd.AggregateDeclaration;
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
61 import dmd.DotTemplateInstanceExp;
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
62
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
63 import dmd.expression.Util;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 import dmd.backend.TYPE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 import dmd.backend.dt_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 import dmd.backend.mTY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 import core.stdc.stdio;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73
4
d706d958e4e8 Step 2 of restoring GC functionality.
korDen
parents: 2
diff changeset
74 import core.memory;
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
75
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 /* These have default values for 32 bit code, they get
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 * adjusted for 64 bit code.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 int PTRSIZE = 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 int Tsize_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 int Tptrdiff_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 /* REALSIZE = size a real consumes in memory
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 * REALPAD = 'padding' added to the CPU real size to bring it up to REALSIZE
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 * REALALIGNSIZE = alignment for reals
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 int REALSIZE = 16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 int REALPAD = 6;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 int REALALIGNSIZE = 16;
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 20
diff changeset
93 } else version (POSIX) { /// TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 int REALSIZE = 12;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 int REALPAD = 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 int REALALIGNSIZE = 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 int REALSIZE = 10;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 int REALPAD = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 int REALALIGNSIZE = 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 /****
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 * Given an identifier, figure out which TemplateParameter it is.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 * Return -1 if not found.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 int templateIdentifierLookup(Identifier id, TemplateParameters parameters)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 {
121
347de076ad34 TemplateParameters -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
110 foreach (size_t i, TemplateParameter tp; parameters)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 if (tp.ident.equals(id))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 return i;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 return -1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 int templateParameterLookup(Type tparam, TemplateParameters parameters)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 assert(tparam.ty == Tident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 TypeIdentifier tident = cast(TypeIdentifier)tparam;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 //printf("\ttident = '%s'\n", tident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 if (tident.idents.dim == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 return templateIdentifierLookup(tident.ident, parameters);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 return -1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 class Type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 TY ty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 MOD mod; // modifiers MODxxxx
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 /* pick this order of numbers so switch statements work better
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 /// #define MODconst 1 // type is const
95
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 87
diff changeset
137 /// #define MODinvariant 4 // type is immutable
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 87
diff changeset
138 /// #define MODimmutable 4 // type is immutable
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 /// #define MODshared 2 // type is shared
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 string deco;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 /* These are cached values that are lazily evaluated by constOf(), invariantOf(), etc.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 * They should not be referenced by anybody but mtype.c.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 * They can be null if not lazily evaluated yet.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 * Note that there is no "shared immutable", because that is just immutable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 Type cto; // MODconst ? mutable version of this type : const version
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 Type ito; // MODinvariant ? mutable version of this type : invariant version
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 Type sto; // MODshared ? mutable version of this type : shared mutable version
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 Type scto; // MODshared|MODconst ? mutable version of this type : shared const version
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 Type pto; // merged pointer to this type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 Type rto; // reference to this type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 Type arrayof; // array of this type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 TypeInfoDeclaration vtinfo; // TypeInfo object for this Type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 type* ctype; // for back end
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 static ClassDeclaration typeinfo;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 static ClassDeclaration typeinfoclass;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 static ClassDeclaration typeinfointerface;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 static ClassDeclaration typeinfostruct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 static ClassDeclaration typeinfotypedef;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 static ClassDeclaration typeinfopointer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 static ClassDeclaration typeinfoarray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 static ClassDeclaration typeinfostaticarray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 static ClassDeclaration typeinfoassociativearray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 static ClassDeclaration typeinfoenum;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 static ClassDeclaration typeinfofunction;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 static ClassDeclaration typeinfodelegate;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 static ClassDeclaration typeinfotypelist;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 static ClassDeclaration typeinfoconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 static ClassDeclaration typeinfoinvariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 static ClassDeclaration typeinfoshared;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 static Type basic[TY.TMAX];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 static ubyte mangleChar[TY.TMAX];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 static ubyte sizeTy[TY.TMAX];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 static StringTable stringtable;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 // These tables are for implicit conversion of binary ops;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 // the indices are the type of operand one, followed by operand two.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 static ubyte impcnvResult[TY.TMAX][TY.TMAX] = [
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,20,20,20,20,20,20,21,22,23,24,25,23,24,25,29,30,31,37,20,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,21,21,21,21,21,21,21,22,23,24,25,23,24,25,29,30,31,37,21,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,22,22,22,22,22,22,22,22,23,24,25,23,24,25,29,30,31,37,22,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,23,24,25,29,30,31,37,23,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,24,24,25,30,30,31,37,24,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,25,25,25,31,31,31,37,25,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,26,27,28,29,30,31,37,23,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,27,27,28,30,30,31,37,24,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,28,28,28,31,31,31,37,25,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,29,29,29,29,29,29,29,29,29,30,31,29,30,31,29,30,31,37,29,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,30,30,30,30,30,30,30,30,30,30,31,30,30,31,30,30,31,37,30,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,37,31,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,33,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 static ubyte impcnvType1[TY.TMAX][TY.TMAX] = [
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,20,20,20,20,20,20,21,22,23,24,25,23,24,25,23,24,25,37,20,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,21,21,21,21,21,21,21,22,23,24,25,23,24,25,23,24,25,37,21,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,22,22,22,22,22,22,22,22,23,24,25,23,24,25,23,24,25,37,22,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,23,24,25,23,24,25,37,23,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,24,24,25,24,24,25,37,24,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,37,25,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,26,26,26,26,26,26,26,26,26,27,28,26,27,28,26,27,28,37,26,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,27,27,27,27,27,27,27,27,27,27,28,27,27,28,27,27,28,37,27,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,37,28,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,29,29,29,29,29,29,29,29,29,30,31,29,30,31,29,30,31,37,29,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,30,30,30,30,30,30,30,30,30,30,31,30,30,31,30,30,31,37,30,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,37,31,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,33,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 static ubyte impcnvType2[TY.TMAX][TY.TMAX] = [
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,20,20,20,20,20,20,21,22,23,24,25,26,27,28,29,30,31,37,20,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,21,21,21,21,21,21,21,22,23,24,25,26,27,28,29,30,31,37,21,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,22,22,22,22,22,22,22,22,23,24,25,26,27,28,29,30,31,37,22,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,26,27,28,29,30,31,37,23,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,27,27,28,30,30,31,37,24,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,28,28,28,31,31,31,37,25,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,26,27,28,29,30,31,37,23,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,27,27,28,30,30,31,37,24,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,28,28,28,31,31,31,37,25,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,26,27,28,29,30,31,37,23,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,27,27,28,30,30,31,37,24,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,28,28,28,31,31,31,37,25,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,33,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 // If !=0, give warning on implicit conversion
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 static const(bool) impcnvWarn[TY.TMAX][TY.TMAX] = [
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 static this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 stringtable = new StringTable();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 static ~this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 delete stringtable;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 this(TY ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 this.ty = ty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 Type syntaxCopy()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388
45
ccbc1e0bb3f0 StringExp.equals implemented
korDen
parents: 23
diff changeset
389 bool equals(Object o)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 Type t = cast(Type)o;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 //printf("Type.equals(%s, %s)\n", toChars(), t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 if (this is o || (t && deco == t.deco) && // deco strings are unique
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 deco !is null) // and semantic() has been run
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 //printf("deco = '%s', t.deco = '%s'\n", deco, t.deco);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 return 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 //if (deco && t && t.deco) printf("deco = '%s', t.deco = '%s'\n", deco, t.deco);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 return 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 DYNCAST dyncast() { return DYNCAST.DYNCAST_TYPE; } // kludge for template.isType()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 /*******************************
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
406 * Covariant means that 'this' can substitute for 't',
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
407 * i.e. a pure function is a match for an impure type. * Returns:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 * 0 types are distinct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 * 1 this is covariant with t
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 * 2 arguments match as far as overloading goes,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 * but types are not covariant
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 * 3 cannot determine covariance because of forward references
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 int covariant(Type t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 {
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
416 static if (false)
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
417 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 printf("Type.covariant(t = %s) %s\n", t.toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 printf("deco = %p, %p\n", deco, t.deco);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 // printf("ty = %d\n", next.ty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 printf("mod = %x, %x\n", mod, t.mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 int inoutmismatch = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 TypeFunction t1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 TypeFunction t2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 if (equals(t))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 return 1; // covariant
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 if (ty != TY.Tfunction || t.ty != TY.Tfunction)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 goto Ldistinct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 t1 = cast(TypeFunction)this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 t2 = cast(TypeFunction)t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 if (t1.varargs != t2.varargs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 goto Ldistinct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 if (t1.parameters && t2.parameters)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
443 size_t dim = Parameter.dim(t1.parameters);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
444 if (dim != Parameter.dim(t2.parameters))
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 goto Ldistinct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 for (size_t i = 0; i < dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
449 auto arg1 = Parameter.getNth(t1.parameters, i);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
450 auto arg2 = Parameter.getNth(t2.parameters, i);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 if (!arg1.type.equals(arg2.type))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 ///static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 /// // turn on this for contravariant argument types, see bugzilla 3075
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
456 /// // BUG: cannot convert ref to const to ref to immutable
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 /// // We can add const, but not subtract it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 /// if (arg2.type.implicitConvTo(arg1.type) < MATCH.MATCHconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 goto Ldistinct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 }
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
462 const StorageClass sc = STC.STCref | STC.STCin | STC.STCout | STC.STClazy;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
463 if ((arg1.storageClass & sc) != (arg2.storageClass & sc))
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 inoutmismatch = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 // We can add scope, but not subtract it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 if (!(arg1.storageClass & STC.STCscope) && (arg2.storageClass & STC.STCscope))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 inoutmismatch = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 else if (t1.parameters != t2.parameters)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 goto Ldistinct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 // The argument lists match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 if (inoutmismatch)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 goto Lnotcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 if (t1.linkage != t2.linkage)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 goto Lnotcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 // Return types
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 Type t1n = t1.next;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 Type t2n = t2.next;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
484 if (t1n is null || t2n is null) // happens with return type inference
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
485 goto Lnotcovariant;
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
486
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 if (t1n.equals(t2n))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 goto Lcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 if (t1n.ty == TY.Tclass && t2n.ty == TY.Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 /* If same class type, but t2n is const, then it's
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 * covariant. Do this test first because it can work on
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 * forward references.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 if ((cast(TypeClass)t1n).sym == (cast(TypeClass)t2n).sym &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 t2n.mod == MOD.MODconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 goto Lcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 // If t1n is forward referenced:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 ClassDeclaration cd = (cast(TypeClass)t1n).sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 if (!cd.baseClass && cd.baseclasses.dim && !cd.isInterfaceDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 return 3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 if (t1n.implicitConvTo(t2n))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 goto Lcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 goto Lnotcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 Lcovariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 /* Can convert mutable to const
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 if (t1.mod != t2.mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 if (!(t1.mod & MOD.MODconst) && (t2.mod & MOD.MODconst))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 goto Lnotcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 if (!(t1.mod & MOD.MODshared) && (t2.mod & MOD.MODshared))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 goto Lnotcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 /* Can convert pure to impure, and nothrow to throw
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 if (!t1.ispure && t2.ispure)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 goto Lnotcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 if (!t1.isnothrow && t2.isnothrow)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 goto Lnotcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 if (t1.isref != t2.isref)
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
532 goto Lnotcovariant;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
533
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
534 /* Can convert safe/trusted to system
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
535 */
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
536 if (t1.trust <= TRUST.TRUSTsystem && t2.trust >= TRUST.TRUSTtrusted)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 goto Lnotcovariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539 //printf("\tcovaraint: 1\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540 return 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 Ldistinct:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543 //printf("\tcovaraint: 0\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 return 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 Lnotcovariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 //printf("\tcovaraint: 2\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 return 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551 string toChars()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 scope OutBuffer buf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 HdrGenState hgs;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556 toCBuffer(buf, null, &hgs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557 return buf.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
559
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
560 static char needThisPrefix()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 return 'M'; // name mangling prefix for functions needing 'this'
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
564
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
565 static void init()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
567 Lexer.initKeywords();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
569 for (int i = 0; i < TY.TMAX; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570 sizeTy[i] = TypeBasic.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
571
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572 sizeTy[TY.Tsarray] = TypeSArray.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573 sizeTy[TY.Tarray] = TypeDArray.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
574 //sizeTy[TY.Tnarray] = TypeNArray.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575 sizeTy[TY.Taarray] = TypeAArray.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
576 sizeTy[TY.Tpointer] = TypePointer.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
577 sizeTy[TY.Treference] = TypeReference.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 sizeTy[TY.Tfunction] = TypeFunction.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579 sizeTy[TY.Tdelegate] = TypeDelegate.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
580 sizeTy[TY.Tident] = TypeIdentifier.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
581 sizeTy[TY.Tinstance] = TypeInstance.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
582 sizeTy[TY.Ttypeof] = TypeTypeof.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 sizeTy[TY.Tenum] = TypeEnum.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584 sizeTy[TY.Ttypedef] = TypeTypedef.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
585 sizeTy[TY.Tstruct] = TypeStruct.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
586 sizeTy[TY.Tclass] = TypeClass.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
587 sizeTy[TY.Ttuple] = TypeTuple.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
588 sizeTy[TY.Tslice] = TypeSlice.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
589 sizeTy[TY.Treturn] = TypeReturn.sizeof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
590
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
591 mangleChar[TY.Tarray] = 'A';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
592 mangleChar[TY.Tsarray] = 'G';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
593 mangleChar[TY.Tnarray] = '@';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
594 mangleChar[TY.Taarray] = 'H';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
595 mangleChar[TY.Tpointer] = 'P';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
596 mangleChar[TY.Treference] = 'R';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
597 mangleChar[TY.Tfunction] = 'F';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
598 mangleChar[TY.Tident] = 'I';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
599 mangleChar[TY.Tclass] = 'C';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
600 mangleChar[TY.Tstruct] = 'S';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
601 mangleChar[TY.Tenum] = 'E';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
602 mangleChar[TY.Ttypedef] = 'T';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
603 mangleChar[TY.Tdelegate] = 'D';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
604
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
605 mangleChar[TY.Tnone] = 'n';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
606 mangleChar[TY.Tvoid] = 'v';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
607 mangleChar[TY.Tint8] = 'g';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
608 mangleChar[TY.Tuns8] = 'h';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
609 mangleChar[TY.Tint16] = 's';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
610 mangleChar[TY.Tuns16] = 't';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
611 mangleChar[TY.Tint32] = 'i';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
612 mangleChar[TY.Tuns32] = 'k';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
613 mangleChar[TY.Tint64] = 'l';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
614 mangleChar[TY.Tuns64] = 'm';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
615 mangleChar[TY.Tfloat32] = 'f';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
616 mangleChar[TY.Tfloat64] = 'd';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
617 mangleChar[TY.Tfloat80] = 'e';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
618
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
619 mangleChar[TY.Timaginary32] = 'o';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620 mangleChar[TY.Timaginary64] = 'p';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621 mangleChar[TY.Timaginary80] = 'j';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
622 mangleChar[TY.Tcomplex32] = 'q';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
623 mangleChar[TY.Tcomplex64] = 'r';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
624 mangleChar[TY.Tcomplex80] = 'c';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626 mangleChar[TY.Tbool] = 'b';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
627 mangleChar[TY.Tascii] = 'a';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628 mangleChar[TY.Twchar] = 'u';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
629 mangleChar[TY.Tdchar] = 'w';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
630
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
631 mangleChar[TY.Tbit] = '@';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
632 mangleChar[TY.Tinstance] = '@';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
633 mangleChar[TY.Terror] = '@';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
634 mangleChar[TY.Ttypeof] = '@';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
635 mangleChar[TY.Ttuple] = 'B';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
636 mangleChar[TY.Tslice] = '@';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
637 mangleChar[TY.Treturn] = '@';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639 debug {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
640 for (int i = 0; i < TY.TMAX; i++) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 if (!mangleChar[i]) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642 writef("ty = %d\n", i);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644 assert(mangleChar[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
647 // Set basic types
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
648 static TY[] basetab = [
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649 TY.Tvoid, TY.Tint8, TY.Tuns8, TY.Tint16, TY.Tuns16, TY.Tint32, TY.Tuns32, TY.Tint64, TY.Tuns64,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 TY.Tfloat32, TY.Tfloat64, TY.Tfloat80,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
651 TY.Timaginary32, TY.Timaginary64, TY.Timaginary80,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
652 TY.Tcomplex32, TY.Tcomplex64, TY.Tcomplex80,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653 TY.Tbool,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 TY.Tascii, TY.Twchar, TY.Tdchar
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 foreach (bt; basetab) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658 Type t = new TypeBasic(bt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
659 t = t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
660 basic[bt] = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
661 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663 basic[TY.Terror] = basic[TY.Tint32];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 tvoidptr = tvoid.pointerTo();
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
666 tstring = tchar.invariantOf().arrayOf();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668 if (global.params.isX86_64) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669 PTRSIZE = 8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671 REALSIZE = 10;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673 REALSIZE = 8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674 Tsize_t = TY.Tuns64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675 Tptrdiff_t = TY.Tint64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679 PTRSIZE = 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680 version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 REALSIZE = 16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
682 REALPAD = 6;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
683 } else version (XXX) { //#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
684 REALSIZE = 12;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
685 REALPAD = 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
687 REALSIZE = 10;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688 REALPAD = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
690 Tsize_t = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
691 Tptrdiff_t = TY.Tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
692 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
693 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695 ulong size()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 return size(Loc(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
700 ulong size(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
701 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
702 error(loc, "no size for type %s", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703 return 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
704 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 uint alignsize()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
708 return cast(uint)size(Loc(0)); ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
710
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
711 Type semantic(Loc loc, Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
712 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713 return merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 Type trySemantic(Loc loc, Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718 uint errors = global.errors;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719 global.gag++; // suppress printing of error messages
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 Type t = semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721 global.gag--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
722 if (errors != global.errors) // if any errors happened
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 global.errors = errors;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725 t = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
726 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730 /********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 * Name mangling.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732 * Input:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733 * flag 0x100 do not do const/invariant
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
734 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735 void toDecoBuffer(OutBuffer buf, int flag = 0)
20
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 16
diff changeset
736 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
737 if (flag != mod && flag != 0x100)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
739 if (mod & MOD.MODshared)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
740 buf.writeByte('O');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742 if (mod & MOD.MODconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
743 buf.writeByte('x');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
744 else if (mod & MOD.MODinvariant)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
745 buf.writeByte('y');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
746
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
747 // Cannot be both const and invariant
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
748 assert((mod & (MOD.MODconst | MOD.MODinvariant)) != (MOD.MODconst | MOD.MODinvariant));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
749 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
750 buf.writeByte(mangleChar[ty]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
751 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
752
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
753 Type merge()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
754 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
755 Type t = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
756 assert(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
757
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
758 //printf("merge(%s)\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
759 if (deco is null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
760 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
761 OutBuffer buf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
763 //if (next)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
764 //next = next.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765 toDecoBuffer(buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
766 StringValue* sv = stringtable.update(buf.extractString());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 if (sv.ptrvalue)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
768 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
769 t = cast(Type) sv.ptrvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
770 debug {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
771 if (!t.deco)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
772 writef("t = %s\n", t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
773 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
774 assert(t.deco);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
775 //printf("old value, deco = '%s' %p\n", t.deco, t.deco);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
776 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
777 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
778 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
779 sv.ptrvalue = cast(void*)this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
780 deco = sv.lstring.string_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
781 //printf("new value, deco = '%s' %p\n", t.deco, t.deco);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
782 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
783 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
784 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
785 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
786
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
787 /*************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
788 * This version does a merge even if the deco is already computed.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 * Necessary for types that have a deco, but are not merged.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 Type merge2()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793 //printf("merge2(%s)\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 Type t = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795 assert(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796 if (!t.deco)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
797 return t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
798
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
799 StringValue* sv = stringtable.lookup(t.deco);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
800 if (sv && sv.ptrvalue)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
802 t = cast(Type)sv.ptrvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
803 assert(t.deco);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
804 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
805 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
806 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
807
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
808 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
809 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
810
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
811 void toCBuffer(OutBuffer buf, Identifier ident, HdrGenState* hgs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
812 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
813 toCBuffer2(buf, hgs, MOD.MODundefined);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
814 if (ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
815 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
816 buf.writeByte(' ');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
817 buf.writestring(ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
818 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
819 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
820
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
821 void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
822 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
823 if (mod != this.mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
824 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
825 toCBuffer3(buf, hgs, mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
826 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
827 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
828 buf.writestring(toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
829 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
830
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
831 void toCBuffer3(OutBuffer buf, HdrGenState* hgs, MOD mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
832 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
833 if (mod != this.mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
834 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
835 string p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
836
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
837 if (this.mod & MOD.MODshared)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
838 buf.writestring("shared(");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
839
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
840 switch (this.mod & (MOD.MODconst | MOD.MODinvariant))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
841 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
842 case MOD.MODundefined:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
843 toCBuffer2(buf, hgs, this.mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
844 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
845 case MOD.MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
846 p = "const(";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
847 goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
848 case MOD.MODinvariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
849 p = "immutable(";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
850 L1: buf.writestring(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
851 toCBuffer2(buf, hgs, this.mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
852 buf.writeByte(')');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
853 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
854 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
855
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
856 if (this.mod & MOD.MODshared)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
857 buf.writeByte(')');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
858 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
859 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
860
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
861 void modToBuffer(OutBuffer buf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
862 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
863 if (mod & MOD.MODshared)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
864 buf.writestring(" shared");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
865 if (mod & MOD.MODconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
866 buf.writestring(" const");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
867 if (mod & MOD.MODinvariant)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
868 buf.writestring(" immutable");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
869 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
870
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
871 version (CPP_MANGLE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
872 void toCppMangle(OutBuffer buf, CppMangleState* cms)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
873 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
874 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
875 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
876 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
877 bool isintegral()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
878 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
879 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
880 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
881
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
882 bool isfloating() // real, imaginary, or complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
883 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
884 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
885 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
886
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
887 bool isreal()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
888 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
889 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
890 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
891
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
892 bool isimaginary()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
893 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
894 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
895 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
896
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
897 bool iscomplex()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
898 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
899 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
900 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
901
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
902 bool isscalar()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
903 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
904 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
905 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
906
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
907 bool isunsigned()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
908 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
909 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
910 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
911
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
912 bool isauto()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
913 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
914 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
915 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
916
12
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 4
diff changeset
917 bool isString()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
918 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
919 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
920 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
921
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
922 /**************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
923 * Given:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
924 * T a, b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
925 * Can we assign:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
926 * a = b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
927 * ?
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
928 */
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 53
diff changeset
929 bool isAssignable()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
930 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
931 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
932 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
933
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
934 bool checkBoolean() // if can be converted to boolean value
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
935 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
936 return isscalar();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
937 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
938
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
939 /*********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
940 * Check type to see if it is based on a deprecated symbol.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
941 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
942 void checkDeprecated(Loc loc, Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
943 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
944 Dsymbol s = toDsymbol(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
945 if (s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
946 s.checkDeprecated(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
947 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
948
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
949 bool isConst() { return (mod & MOD.MODconst) != 0; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
950
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
951 int isInvariant() { return mod & MOD.MODinvariant; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
952
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
953 int isMutable() { return !(mod & (MOD.MODconst | MOD.MODinvariant)); }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
954
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
955 int isShared() { return mod & MOD.MODshared; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
956
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
957 int isSharedConst() { return mod == (MOD.MODshared | MOD.MODconst); }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
958
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
959 /********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
960 * Convert to 'const'.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
961 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
962 Type constOf()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
963 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
964 //printf("Type.constOf() %p %s\n", this, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
965 if (mod == MOD.MODconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
966 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
967 if (cto)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
968 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
969 assert(cto.mod == MOD.MODconst);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
970 return cto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
971 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
972 Type t = makeConst();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
973 t = t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
974 t.fixTo(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
975 //printf("-Type.constOf() %p %s\n", t, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
976 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
977 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
978
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
979 /********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
980 * Convert to 'immutable'.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
981 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
982 Type invariantOf()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
983 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
984 //printf("Type.invariantOf() %p %s\n", this, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
985 if (isInvariant())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
986 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
987 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
988 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
989 if (ito)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
990 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
991 assert(ito.isInvariant());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
992 return ito;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
993 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
994 Type t = makeInvariant();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
995 t = t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
996 t.fixTo(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
997 //printf("\t%p\n", t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
998 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
999 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1001 Type mutableOf()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1002 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1003 //printf("Type.mutableOf() %p, %s\n", this, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1004 Type t = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1005 if (isConst())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1006 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1007 if (isShared())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1008 t = sto; // shared const => shared
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1009 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1010 t = cto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1011 assert(!t || t.isMutable());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1012 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1013 else if (isInvariant())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1014 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1015 t = ito;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1016 assert(!t || (t.isMutable() && !t.isShared()));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1017 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1018 if (!t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1019 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1020 uint sz = this.classinfo.init.length;
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
1021 t = cast(Type)GC.malloc(sz);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1022 memcpy(cast(void*)t, cast(void*)this, sz);
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1023 t.mod = mod & MODshared;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1024 t.deco = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1025 t.arrayof = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1026 t.pto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1027 t.rto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1028 t.cto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1029 t.ito = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1030 t.sto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1031 t.scto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1032 t.vtinfo = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1033 t = t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1034
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1035 t.fixTo(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1036
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1037 switch (mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1038 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1039 case MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1040 t.cto = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1041 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1042
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1043 case MODinvariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1044 t.ito = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1045 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1046
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1047 case MODshared | MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1048 t.scto = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1049 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1050
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1051 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1052 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1053 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1054 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1055 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1056 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1057
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1058 Type sharedOf()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1059 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1060 //printf("Type.sharedOf() %p, %s\n", this, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1061 if (mod == MOD.MODshared)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1062 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1063 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1064 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1065 if (sto)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1066 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1067 assert(sto.isShared());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1068 return sto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1069 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1070
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1071 Type t = makeShared();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1072 t = t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1073 t.fixTo(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1074
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1075 //printf("\t%p\n", t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1076 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1077 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1078
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1079 Type sharedConstOf()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1080 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1081 //printf("Type.sharedConstOf() %p, %s\n", this, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1082 if (mod == (MODshared | MODconst))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1083 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1084 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1085 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1086 if (scto)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1087 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1088 assert(scto.mod == (MODshared | MODconst));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1089 return scto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1090 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1091
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1092 Type t = makeSharedConst();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1093 t = t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1094 t.fixTo(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1095 //printf("\t%p\n", t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1096
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1097 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1098 }
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1099
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1100 /********************************
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1101 * Make type unshared.
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1102 */
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1103 Type unSharedOf()
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1104 {
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1105 //writef("Type::unSharedOf() %p, %s\n", this, toChars());
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1106 Type t = this;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1107
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1108 if (isShared())
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1109 {
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1110 if (isConst())
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1111 t = cto; // shared const => const
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1112 else
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1113 t = sto;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1114 assert(!t || !t.isShared());
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1115 }
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1116
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1117 if (!t)
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1118 {
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1119 uint sz = this.classinfo.init.length;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1120 t = cast(Type)GC.malloc(sz);
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1121 memcpy(cast(void*)t, cast(void*)this, sz);
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1122 t.mod = mod & ~MODshared;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1123 t.deco = null;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1124 t.arrayof = null;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1125 t.pto = null;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1126 t.rto = null;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1127 t.cto = null;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1128 t.ito = null;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1129 t.sto = null;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1130 t.scto = null;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1131 t.vtinfo = null;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1132 t = t.merge();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1133
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1134 t.fixTo(this);
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1135
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1136 switch (mod)
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1137 {
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1138 case MODshared:
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1139 t.sto = this;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1140 break;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1141
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1142 case MODshared | MODconst:
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1143 t.scto = this;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1144 break;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1145
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1146 default:
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1147 assert(0);
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1148 }
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1149 }
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1150 assert(!t.isShared());
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1151 return t;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1152 }
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1153
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1154 static uint X(MOD m, MOD n)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1155 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1156 return (((m) << 3) | (n));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1157 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1158
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1159 /**********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1160 * For our new type 'this', which is type-constructed from t,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1161 * fill in the cto, ito, sto, scto shortcuts.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1162 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1163 void fixTo(Type t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1164 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1165 ito = t.ito;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1166 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1167 /* Cannot do these because these are not fully transitive:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1168 * there can be a shared ptr to immutable, for example.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1169 * Immutable subtypes are always immutable, though.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1170 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1171 cto = t.cto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1172 sto = t.sto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1173 scto = t.scto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1174 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1175
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1176 assert(mod != t.mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1177
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1178 switch (X(mod, t.mod))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1179 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1180 case X(MOD.MODundefined, MOD.MODconst):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1181 cto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1182 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1183
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1184 case X(MOD.MODundefined, MOD.MODinvariant):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1185 ito = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1186 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1187
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1188 case X(MOD.MODundefined, MOD.MODshared):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1189 sto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1190 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1191
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1192 case X(MOD.MODundefined, MOD.MODshared | MOD.MODconst):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1193 scto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1194 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1195
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1196
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1197 case X(MOD.MODconst, MOD.MODundefined):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1198 cto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1199 goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1200
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1201 case X(MOD.MODconst, MOD.MODinvariant):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1202 ito = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1203 goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1204
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1205 case X(MOD.MODconst, MOD.MODshared):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1206 sto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1207 goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1208
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1209 case X(MOD.MODconst, MOD.MODshared | MOD.MODconst):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1210 scto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1211 L2:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1212 t.cto = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1213 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1214
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1215
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1216 case X(MOD.MODinvariant, MOD.MODundefined):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1217 ito = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1218 goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1219
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1220 case X(MOD.MODinvariant, MOD.MODconst):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1221 cto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1222 goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1223
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1224 case X(MOD.MODinvariant, MOD.MODshared):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1225 sto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1226 goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1227
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1228 case X(MOD.MODinvariant, MOD.MODshared | MOD.MODconst):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1229 scto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1230 L3:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1231 t.ito = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1232 if (t.cto) t.cto.ito = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1233 if (t.sto) t.sto.ito = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1234 if (t.scto) t.scto.ito = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1235 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1236
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1237
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1238 case X(MOD.MODshared, MOD.MODundefined):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1239 sto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1240 goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1241
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1242 case X(MOD.MODshared, MOD.MODconst):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1243 cto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1244 goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1245
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1246 case X(MOD.MODshared, MOD.MODinvariant):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1247 ito = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1248 goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1249
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1250 case X(MOD.MODshared, MOD.MODshared | MOD.MODconst):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1251 scto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1252 L4:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1253 t.sto = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1254 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1255
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1256
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1257 case X(MOD.MODshared | MOD.MODconst, MOD.MODundefined):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1258 scto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1259 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1260
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1261 case X(MOD.MODshared | MOD.MODconst, MOD.MODconst):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1262 cto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1263 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1264
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1265 case X(MOD.MODshared | MOD.MODconst, MOD.MODinvariant):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1266 ito = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1267 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1268
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1269 case X(MOD.MODshared | MOD.MODconst, MOD.MODshared):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1270 sto = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1271 L5:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1272 t.scto = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1273 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1274 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1275
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1276 check();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1277 t.check();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1278 //printf("fixTo: %s, %s\n", toChars(), t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1279 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1280
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1281 /***************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1282 * Look for bugs in constructing types.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1283 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1284 void check()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1285 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1286 switch (mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1287 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1288 case MOD.MODundefined:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1289 if (cto) assert(cto.mod == MOD.MODconst);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1290 if (ito) assert(ito.mod == MOD.MODinvariant);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1291 if (sto) assert(sto.mod == MOD.MODshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1292 if (scto) assert(scto.mod == (MOD.MODshared | MOD.MODconst));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1293 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1294
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1295 case MOD.MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1296 if (cto) assert(cto.mod == MOD.MODundefined);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1297 if (ito) assert(ito.mod == MOD.MODinvariant);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1298 if (sto) assert(sto.mod == MOD.MODshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1299 if (scto) assert(scto.mod == (MOD.MODshared | MOD.MODconst));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1300 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1301
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1302 case MOD.MODinvariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1303 if (cto) assert(cto.mod == MOD.MODconst);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1304 if (ito) assert(ito.mod == MOD.MODundefined);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1305 if (sto) assert(sto.mod == MOD.MODshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1306 if (scto) assert(scto.mod == (MOD.MODshared | MOD.MODconst));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1307 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1308
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1309 case MOD.MODshared:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1310 if (cto) assert(cto.mod == MOD.MODconst);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1311 if (ito) assert(ito.mod == MOD.MODinvariant);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1312 if (sto) assert(sto.mod == MOD.MODundefined);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1313 if (scto) assert(scto.mod == (MOD.MODshared | MOD.MODconst));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1314 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1315
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1316 case MOD.MODshared | MOD.MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1317 if (cto) assert(cto.mod == MOD.MODconst);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1318 if (ito) assert(ito.mod == MOD.MODinvariant);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1319 if (sto) assert(sto.mod == MOD.MODshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1320 if (scto) assert(scto.mod == MOD.MODundefined);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1321 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1322 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1323
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1324 Type tn = nextOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1325 if (tn && ty != TY.Tfunction && ty != TY.Tdelegate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1326 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1327 // Verify transitivity
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1328 switch (mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1329 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1330 case MOD.MODundefined:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1331 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1332
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1333 case MOD.MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1334 assert(tn.mod & MOD.MODinvariant || tn.mod & MOD.MODconst);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1335 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1336
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1337 case MOD.MODinvariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1338 assert(tn.mod == MOD.MODinvariant);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1339 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1340
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1341 case MOD.MODshared:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1342 assert(tn.mod & MOD.MODinvariant || tn.mod & MOD.MODshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1343 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1344
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1345 case MOD.MODshared | MOD.MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1346 assert(tn.mod & MOD.MODinvariant || tn.mod & (MOD.MODshared | MOD.MODconst));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1347 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1348 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1349 tn.check();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1350 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1351 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1352
51
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1353 /************************************
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1354 * Apply MODxxxx bits to existing type.
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1355 */
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1356 Type castMod(uint mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1357 {
51
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1358 Type t;
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1359
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1360 switch (mod)
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1361 {
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1362 case 0:
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1363 t = mutableOf();
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1364 break;
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1365
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1366 case MODconst:
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1367 t = constOf();
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1368 break;
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1369
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1370 case MODinvariant:
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1371 t = invariantOf();
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1372 break;
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1373
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1374 case MODshared:
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1375 t = sharedOf();
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1376 break;
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1377
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1378 case MODshared | MODconst:
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1379 t = sharedConstOf();
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1380 break;
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1381
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1382 default:
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1383 assert(0);
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1384 }
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 45
diff changeset
1385 return t;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1386 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1387
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1388 /************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1389 * Add MODxxxx bits to existing type.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1390 * We're adding, not replacing, so adding const to
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1391 * a shared type => "shared const"
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1392 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1393 Type addMod(MOD mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1394 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1395 Type t = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1396
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1397 /* Add anything to immutable, and it remains immutable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1398 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1399 if (!t.isInvariant())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1400 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1401 switch (mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1402 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1403 case MOD.MODundefined:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1404 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1405
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1406 case MOD.MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1407 if (isShared())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1408 t = sharedConstOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1409 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1410 t = constOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1411 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1412
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1413 case MOD.MODinvariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1414 t = invariantOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1415 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1416
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1417 case MOD.MODshared:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1418 if (isConst())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1419 t = sharedConstOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1420 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1421 t = sharedOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1422 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1423
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1424 case MOD.MODshared | MOD.MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1425 t = sharedConstOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1426 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1427 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1428 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1429 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1430 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1431
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
1432 Type addStorageClass(StorageClass stc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1433 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1434 /* Just translate to MOD bits and let addMod() do the work
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1435 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1436 MOD mod = MOD.MODundefined;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1437
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1438 if (stc & STC.STCimmutable)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1439 mod = MOD.MODinvariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1440 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1441 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1442 if (stc & (STC.STCconst | STC.STCin))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1443 mod = MOD.MODconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1444 if (stc & STC.STCshared)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1445 mod |= MOD.MODshared;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1446 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1447
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1448 return addMod(mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1449 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1450
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1451 Type pointerTo()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1452 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1453 if (pto is null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1454 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1455 Type t = new TypePointer(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1456 pto = t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1457 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1458
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1459 return pto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1460 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1461
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1462 Type referenceTo()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1463 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1464 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1465 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1466
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1467 version (DumbClone) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1468 final Type clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1469 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1470 auto size = this.classinfo.init.length;
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
1471 auto ptr = GC.malloc(size);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1472 memcpy(ptr, cast(void*)this, size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1473
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1474 return cast(Type)ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1475 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1476 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1477 final Type cloneTo(Type t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1478 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1479 t.ctype = ctype;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1480 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1481 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1482
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1483 Type clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1484 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1485 assert(this.classinfo is Type.classinfo);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1486 return cloneTo(new Type(ty));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1487 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1488 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1489
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1490 Type arrayOf()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1491 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1492 if (!arrayof)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1493 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1494 Type t = new TypeDArray(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1495 arrayof = t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1496 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1497 return arrayof;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1498 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1499
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1500 Type makeConst()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1501 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1502 //printf("Type.makeConst() %p, %s\n", this, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1503 if (cto)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1504 return cto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1505
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1506 Type t = clone();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1507 t.mod = MOD.MODconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1508
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1509 t.deco = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1510 t.arrayof = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1511 t.pto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1512 t.rto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1513 t.cto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1514 t.ito = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1515 t.sto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1516 t.scto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1517 t.vtinfo = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1518
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1519 //printf("-Type.makeConst() %p, %s\n", t, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1520 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1521 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1522
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1523 Type makeInvariant()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1524 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1525 if (ito) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1526 return ito;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1527 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1528
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1529 Type t = clone();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1530 t.mod = MOD.MODinvariant;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1531
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1532 t.deco = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1533 t.arrayof = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1534 t.pto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1535 t.rto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1536 t.cto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1537 t.ito = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1538 t.sto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1539 t.scto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1540 t.vtinfo = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1541
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1542 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1543 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1544
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1545 Type makeShared()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1546 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1547 if (sto)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1548 return sto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1549
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1550 Type t = clone();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1551 t.mod = MOD.MODshared;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1552
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1553 t.deco = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1554 t.arrayof = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1555 t.pto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1556 t.rto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1557 t.cto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1558 t.ito = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1559 t.sto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1560 t.scto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1561 t.vtinfo = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1562
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1563 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1564 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1565
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1566 Type makeSharedConst()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1567 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1568 if (scto)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1569 return scto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1570
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1571 Type t = clone();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1572 t.mod = MODshared | MODconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1573
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1574 t.deco = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1575 t.arrayof = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1576 t.pto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1577 t.rto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1578 t.cto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1579 t.ito = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1580 t.sto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1581 t.scto = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1582 t.vtinfo = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1583
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1584 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1585 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1586
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1587 Dsymbol toDsymbol(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1588 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1589 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1590 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1591
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1592 /*******************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1593 * If this is a shell around another type,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1594 * get that other type.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1595 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1596
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1597 Type toBasetype()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1598 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1599 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1600 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1601
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1602 /**************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1603 * Return type with the top level of it being mutable.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1604 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1605 Type toHeadMutable()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1606 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1607 if (!mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1608 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1609
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1610 return mutableOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1611 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1612
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1613 bool isBaseOf(Type t, int* poffset)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1614 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1615 return false; // assume not
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1616 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1617
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1618 /*******************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1619 * Determine if converting 'this' to 'to' is an identity operation,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1620 * a conversion to const operation, or the types aren't the same.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1621 * Returns:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1622 * MATCHequal 'this' == 'to'
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1623 * MATCHconst 'to' is const
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1624 * MATCHnomatch conversion to mutable or invariant
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1625 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1626 MATCH constConv(Type to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1627 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1628 if (equals(to))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1629 return MATCH.MATCHexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1630 if (ty == to.ty && to.mod == MOD.MODconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1631 return MATCH.MATCHconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1632 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1633 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1634
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1635 /********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1636 * Determine if 'this' can be implicitly converted
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1637 * to type 'to'.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1638 * Returns:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1639 * MATCHnomatch, MATCHconvert, MATCHconst, MATCHexact
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1640 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1641 MATCH implicitConvTo(Type to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1642 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1643 //printf("Type.implicitConvTo(this=%p, to=%p)\n", this, to);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1644 //printf("from: %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1645 //printf("to : %s\n", to.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1646 if (this is to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1647 return MATCHexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1648
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1649 return MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1650 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1651
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1652 ClassDeclaration isClassHandle()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1653 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1654 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1655 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1656
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1657 Expression getProperty(Loc loc, Identifier ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1658 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1659 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1660
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1661 version (LOGDOTEXP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1662 printf("Type.getProperty(type = '%s', ident = '%s')\n", toChars(), ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1663 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1664 if (ident == Id.__sizeof)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1665 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1666 e = new IntegerExp(loc, size(loc), Type.tsize_t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1667 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1668 else if (ident == Id.size)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1669 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1670 error(loc, ".size property should be replaced with .sizeof");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1671 e = new ErrorExp();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1672 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1673 else if (ident is Id.alignof_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1674 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1675 e = new IntegerExp(loc, alignsize(), Type.tsize_t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1676 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1677 else if (ident == Id.typeinfo_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1678 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1679 if (!global.params.useDeprecated)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1680 error(loc, ".typeinfo deprecated, use typeid(type)");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1681 e = getTypeInfo(null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1682 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1683 else if (ident == Id.init_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1684 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1685 if (ty == TY.Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1686 error(loc, "void does not have an initializer");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1687 e = defaultInit(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1688 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1689 else if (ident is Id.mangleof_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1690 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1691 string s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1692 if (!deco) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1693 s = toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1694 error(loc, "forward reference of type %s.mangleof", s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1695 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1696 s = deco;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1697 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1698
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1699 e = new StringExp(loc, s, 'c');
87
b17640f0e4e8 Fixed a bug with a Scope.this(Scope enclosing) being called instead of Scope.clone() method (as a copy ctor replacement)
korDen
parents: 79
diff changeset
1700 scope Scope sc = new Scope();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1701 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1702 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1703 else if (ident is Id.stringof_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1704 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1705 string s = toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1706 e = new StringExp(loc, s, 'c');
87
b17640f0e4e8 Fixed a bug with a Scope.this(Scope enclosing) being called instead of Scope.clone() method (as a copy ctor replacement)
korDen
parents: 79
diff changeset
1707 scope Scope sc = new Scope();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1708 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1709 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1710 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1711 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1712 error(loc, "no property '%s' for type '%s'", ident.toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1713 e = new ErrorExp();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1714 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1715 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1716 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1717
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1718 Expression dotExp(Scope sc, Expression e, Identifier ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1719 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1720 VarDeclaration v = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1721
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1722 version (LOGDOTEXP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1723 printf("Type.dotExp(e = '%s', ident = '%s')\n", e.toChars(), ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1724 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1725 if (e.op == TOK.TOKdotvar)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1726 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1727 DotVarExp dv = cast(DotVarExp)e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1728 v = dv.var.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1729 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1730 else if (e.op == TOK.TOKvar)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1731 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1732 VarExp ve = cast(VarExp)e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1733 v = ve.var.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1734 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1735 if (v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1736 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1737 if (ident is Id.offset)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1738 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1739 if (!global.params.useDeprecated)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1740 error(e.loc, ".offset deprecated, use .offsetof");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1741 goto Loffset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1742 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1743 else if (ident is Id.offsetof)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1744 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1745 Loffset:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1746 if (v.storage_class & STC.STCfield)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1747 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1748 e = new IntegerExp(e.loc, v.offset, Type.tsize_t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1749 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1750 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1751 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1752 else if (ident is Id.init_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1753 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1754 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1755 if (v.init)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1756 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1757 if (v.init.isVoidInitializer())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1758 error(e.loc, "%s.init is void", v.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1759 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1760 { Loc loc = e.loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1761 e = v.init.toExpression();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1762 if (e.op == TOK.TOKassign || e.op == TOK.TOKconstruct || e.op == TOK.TOKblit)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1763 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1764 e = (cast(AssignExp)e).e2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1765
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1766 /* Take care of case where we used a 0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1767 * to initialize the struct.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1768 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1769 if (e.type == Type.tint32 &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1770 e.isBool(0) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1771 v.type.toBasetype().ty == TY.Tstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1772 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1773 e = v.type.defaultInit(e.loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1774 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1775 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1776 e = e.optimize(WANTvalue | WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1777 // if (!e.isConst())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1778 // error(loc, ".init cannot be evaluated at compile time");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1779 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1780 goto Lreturn;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1781 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1782 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1783 e = defaultInit(e.loc);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1784 goto Lreturn;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1785 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1786 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1787 if (ident is Id.typeinfo_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1788 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1789 if (!global.params.useDeprecated)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1790 error(e.loc, ".typeinfo deprecated, use typeid(type)");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1791 e = getTypeInfo(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1792 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1793 else if (ident is Id.stringof_)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1794 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1795 string s = e.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1796 e = new StringExp(e.loc, s, 'c');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1797 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1798 else
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1799 e = getProperty(e.loc, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1800
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1801 Lreturn:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1802 e = e.semantic(sc);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1803 return e;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1804 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1805
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1806 /***************************************
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1807 * Figures out what to do with an undefined member reference
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1808 * for classes and structs.
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1809 */
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1810 Expression noMember(Scope sc, Expression e, Identifier ident)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1811 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1812 assert(ty == TY.Tstruct || ty == TY.Tclass);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1813 AggregateDeclaration sym = toDsymbol(sc).isAggregateDeclaration();
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1814 assert(sym);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1815
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
1816 if (ident !is Id.__sizeof &&
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
1817 ident !is Id.alignof_ &&
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
1818 ident !is Id.init_ &&
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
1819 ident !is Id.mangleof_ &&
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
1820 ident !is Id.stringof_ &&
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
1821 ident !is Id.offsetof)
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1822 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1823 /* See if we should forward to the alias this.
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1824 */
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1825 if (sym.aliasthis)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1826 { /* Rewrite e.ident as:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1827 * e.aliasthis.ident
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1828 */
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1829 e = new DotIdExp(e.loc, e, sym.aliasthis.ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1830 e = new DotIdExp(e.loc, e, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1831 return e.semantic(sc);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1832 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1833
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1834 /* Look for overloaded opDot() to see if we should forward request
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1835 * to it.
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1836 */
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1837 Dsymbol fd = search_function(sym, Id.opDot);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1838 if (fd)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1839 { /* Rewrite e.ident as:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1840 * e.opDot().ident
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1841 */
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
1842 e = build_overload(e.loc, sc, e, null, fd.ident);
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1843 e = new DotIdExp(e.loc, e, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1844 return e.semantic(sc);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1845 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1846
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1847 /* Look for overloaded opDispatch to see if we should forward request
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1848 * to it.
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1849 */
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1850 fd = search_function(sym, Id.opDispatch);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1851 if (fd)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1852 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1853 /* Rewrite e.ident as:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1854 * e.opDispatch!("ident")
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1855 */
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1856 TemplateDeclaration td = fd.isTemplateDeclaration();
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1857 if (!td)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1858 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1859 fd.error("must be a template opDispatch(string s), not a %s", fd.kind());
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1860 return new ErrorExp();
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1861 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1862 auto se = new StringExp(e.loc, ident.toChars());
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1863 auto tiargs = new Objects();
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1864 tiargs.push(se);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1865 e = new DotTemplateInstanceExp(e.loc, e, Id.opDispatch, tiargs);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1866 (cast(DotTemplateInstanceExp)e).ti.tempdecl = td;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1867 return e;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1868 //return e.semantic(sc);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1869 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1870 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1871
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1872 return Type.dotExp(sc, e, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1873 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 121
diff changeset
1874
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1875 uint memalign(uint salign)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1876 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1877 return salign;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1878 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1879
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1880 ///Expression defaultInit(Loc loc = Loc(0))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1881 Expression defaultInit(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1882 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1883 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1884 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1885
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1886 ///bool isZeroInit(Loc loc = Loc(0)) // if initializer is 0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1887 bool isZeroInit(Loc loc) // if initializer is 0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1888 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1889 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1890 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1891
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1892 dt_t** toDt(dt_t** pdt)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1893 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1894 //printf("Type.toDt()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1895 Expression e = defaultInit(Loc(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1896 return e.toDt(pdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1897 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1898
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1899 Identifier getTypeInfoIdent(int internal)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1900 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1901 // _init_10TypeInfo_%s
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1902 scope OutBuffer buf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1903 Identifier id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1904 char* name;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1905 int len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1906
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1907 if (internal)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1908 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1909 buf.writeByte(mangleChar[ty]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1910 if (ty == TY.Tarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1911 buf.writeByte(mangleChar[(cast(TypeArray)this).next.ty]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1912 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1913 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1914 toDecoBuffer(buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1915
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1916 len = buf.offset;
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: 4
diff changeset
1917 version (Bug4054)
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: 4
diff changeset
1918 name = cast(char*)GC.malloc(19 + len.sizeof * 3 + len + 1);
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: 4
diff changeset
1919 else
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1920 name = cast(char*)alloca(19 + len.sizeof * 3 + len + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1921 buf.writeByte(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1922 version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1923 // The LINKc will prepend the _
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1924 len = sprintf(name, "D%dTypeInfo_%s6__initZ".ptr, 9 + len, buf.data);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1925 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1926 len = sprintf(name, "_D%dTypeInfo_%s6__initZ".ptr, 9 + len, buf.data);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1927 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1928 if (global.params.isWindows)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1929 name++; // C mangling will add it back in
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1930 //printf("name = %s\n", name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1931 id = Lexer.idPool(name[0..len-1].idup);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1932 return id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1933 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1934
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1935 /* These form the heart of template argument deduction.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1936 * Given 'this' being the type argument to the template instance,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1937 * it is matched against the template declaration parameter specialization
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1938 * 'tparam' to determine the type to be used for the parameter.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1939 * Example:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1940 * template Foo(T:T*) // template declaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1941 * Foo!(int*) // template instantiation
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1942 * Input:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1943 * this = int*
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1944 * tparam = T
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1945 * parameters = [ T:T* ] // Array of TemplateParameter's
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1946 * Output:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1947 * dedtypes = [ int ] // Array of Expression/Type's
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1948 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1949 MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1950 {
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1951 static if (false)
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1952 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1953 printf("Type.deduceType()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1954 printf("\tthis = %d, ", ty); print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1955 printf("\ttparam = %d, ", tparam.ty); tparam.print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1956 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1957 if (!tparam)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1958 goto Lnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1959
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1960 if (this == tparam)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1961 goto Lexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1962
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1963 if (tparam.ty == Tident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1964 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1965 // Determine which parameter tparam is
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1966 int i = templateParameterLookup(tparam, parameters);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1967 if (i == -1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1968 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1969 if (!sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1970 goto Lnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1971
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1972 /* Need a loc to go with the semantic routine.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1973 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1974 Loc loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1975 if (parameters.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1976 {
121
347de076ad34 TemplateParameters -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
1977 auto tp = parameters[0];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1978 loc = tp.loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1979 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1980
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1981 /* BUG: what if tparam is a template instance, that
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1982 * has as an argument another Tident?
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1983 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1984 tparam = tparam.semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1985 assert(tparam.ty != Tident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1986 return deduceType(sc, tparam, parameters, dedtypes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1987 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1988
121
347de076ad34 TemplateParameters -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
1989 auto tp = parameters[i];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1990
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1991 // Found the corresponding parameter tp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1992 if (!tp.isTemplateTypeParameter())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1993 goto Lnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1994 Type tt = this;
113
3482c73a991b More cleanup for arrays
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 110
diff changeset
1995 Type at = cast(Type)dedtypes[i];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1996
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1997 // 5*5 == 25 cases
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1998 static pure int X(int U, int T) { return ((U << 3) | T); }
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
1999
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2000 switch (X(tparam.mod, mod))
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2001 {
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2002 case X(0, 0):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2003 case X(0, MODconst):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2004 case X(0, MODinvariant):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2005 case X(0, MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2006 case X(0, MODconst | MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2007 // foo(U:U) T => T
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2008 // foo(U:U) const(T) => const(T)
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2009 // foo(U:U) immutable(T) => immutable(T)
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2010 // foo(U:U) shared(T) => shared(T)
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2011 // foo(U:U) const(shared(T)) => const(shared(T))
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2012 if (!at)
110
12c0c84d13fd merged in 2.036 changes
Trass3r
parents: 98 94
diff changeset
2013 { dedtypes[i] = tt;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2014 goto Lexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2015 }
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2016 break;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2017
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2018 case X(MODconst, MODconst):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2019 case X(MODinvariant, MODinvariant):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2020 case X(MODshared, MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2021 case X(MODconst | MODshared, MODconst | MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2022 // foo(U:const(U)) const(T) => T
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2023 // foo(U:immutable(U)) immutable(T) => T
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2024 // foo(U:shared(U)) shared(T) => T
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2025 // foo(U:const(shared(U)) const(shared(T))=> T
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2026 tt = mutableOf().unSharedOf();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2027 if (!at)
110
12c0c84d13fd merged in 2.036 changes
Trass3r
parents: 98 94
diff changeset
2028 {
94
3a0b150c9841 Objects -> Vector!Object iteration 1
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 87
diff changeset
2029 dedtypes[i] = tt;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2030 goto Lexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2031 }
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2032 break;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2033
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2034 case X(MODconst, 0):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2035 case X(MODconst, MODimmutable):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2036 case X(MODconst, MODconst | MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2037 case X(MODconst | MODshared, MODimmutable):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2038 // foo(U:const(U)) T => T
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2039 // foo(U:const(U)) immutable(T) => T
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2040 // foo(U:const(U)) const(shared(T)) => shared(T)
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2041 // foo(U:const(shared(U)) immutable(T) => T
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2042 tt = mutableOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2043 if (!at)
110
12c0c84d13fd merged in 2.036 changes
Trass3r
parents: 98 94
diff changeset
2044 { dedtypes[i] = tt;
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2045 goto Lconst;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2046 }
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2047 break;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2048
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2049 case X(MODshared, MODconst | MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2050 case X(MODconst | MODshared, MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2051 // foo(U:shared(U)) const(shared(T)) => const(T)
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2052 // foo(U:const(shared(U)) shared(T) => T
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2053 tt = unSharedOf();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2054 if (!at)
110
12c0c84d13fd merged in 2.036 changes
Trass3r
parents: 98 94
diff changeset
2055 { dedtypes[i] = tt;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2056 goto Lconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2057 }
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2058 break;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2059
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2060 case X(MODimmutable, 0):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2061 case X(MODimmutable, MODconst):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2062 case X(MODimmutable, MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2063 case X(MODimmutable, MODconst | MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2064 case X(MODconst, MODshared):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2065 case X(MODshared, 0):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2066 case X(MODshared, MODconst):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2067 case X(MODshared, MODimmutable):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2068 case X(MODconst | MODshared, 0):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2069 case X(MODconst | MODshared, MODconst):
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2070 // foo(U:immutable(U)) T => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2071 // foo(U:immutable(U)) const(T) => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2072 // foo(U:immutable(U)) shared(T) => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2073 // foo(U:immutable(U)) const(shared(T)) => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2074 // foo(U:const(U)) shared(T) => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2075 // foo(U:shared(U)) T => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2076 // foo(U:shared(U)) const(T) => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2077 // foo(U:shared(U)) immutable(T) => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2078 // foo(U:const(shared(U)) T => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2079 // foo(U:const(shared(U)) const(T) => nomatch
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2080 //if (!at)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2081 goto Lnomatch;
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2082 break;
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2083
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2084 default:
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2085 assert(0);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2086 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2087
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2088 if (tt.equals(at))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2089 goto Lexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2090 else if (tt.ty == Tclass && at.ty == Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2091 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2092 return tt.implicitConvTo(at);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2093 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2094 else if (tt.ty == Tsarray && at.ty == Tarray &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2095 tt.nextOf().implicitConvTo(at.nextOf()) >= MATCHconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2096 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2097 goto Lexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2098 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2099 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2100 goto Lnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2101 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2102
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2103 if (ty != tparam.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2104 return implicitConvTo(tparam);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2105 // goto Lnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2106
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2107 if (nextOf())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2108 return nextOf().deduceType(sc, tparam.nextOf(), parameters, dedtypes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2109
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2110 Lexact:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2111 return MATCHexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2112
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2113 Lnomatch:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2114 return MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2115
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2116 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2117 Lconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2118 return MATCHconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2119 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2120 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2121
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2122 void resolve(Loc loc, Scope sc, Expression* pe, Type* pt, Dsymbol* ps)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2123 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2124 //printf("Type.resolve() %s, %d\n", toChars(), ty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2125 Type t = semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2126 *pt = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2127 *pe = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2128 *ps = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2129 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2130
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2131 /*******************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2132 * Get a canonicalized form of the TypeInfo for use with the internal
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2133 * runtime library routines. Canonicalized in that static arrays are
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2134 * represented as dynamic arrays, enums are represented by their
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2135 * underlying type, etc. This reduces the number of TypeInfo's needed,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2136 * so we can use the custom internal ones more.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2137 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2138 Expression getInternalTypeInfo(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2139 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2140 TypeInfoDeclaration tid;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2141 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2142 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2143 static TypeInfoDeclaration internalTI[TMAX];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2144
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2145 //printf("Type.getInternalTypeInfo() %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2146 t = toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2147 switch (t.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2148 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2149 case Tsarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2150 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2151 // convert to corresponding dynamic array type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2152 t = t.nextOf().mutableOf().arrayOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2153 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2154 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2155
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2156 case Tclass:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2157 if ((cast(TypeClass)t).sym.isInterfaceDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2158 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2159 goto Linternal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2160
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2161 case Tarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2162 // convert to corresponding dynamic array type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2163 t = t.nextOf().mutableOf().arrayOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2164 if (t.nextOf().ty != Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2165 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2166 goto Linternal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2167
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2168 case Tfunction:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2169 case Tdelegate:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2170 case Tpointer:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2171 Linternal:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2172 tid = internalTI[t.ty];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2173 if (!tid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2174 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2175 tid = new TypeInfoDeclaration(t, 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2176 internalTI[t.ty] = tid;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2177 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2178 e = new VarExp(Loc(0), tid);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2179 e = e.addressOf(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2180 e.type = tid.type; // do this so we don't get redundant dereference
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2181 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2182
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2183 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2184 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2185 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2186 //printf("\tcalling getTypeInfo() %s\n", t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2187 return t.getTypeInfo(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2188 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2189
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2190 /****************************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2191 * Get the exact TypeInfo.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2192 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2193 Expression getTypeInfo(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2194 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2195 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2196 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2197
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2198 //printf("Type.getTypeInfo() %p, %s\n", this, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2199 t = merge2(); // do this since not all Type's are merge'd
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2200 if (!t.vtinfo)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2201 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2202 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2203 if (t.isShared()) // does both 'shared' and 'shared const'
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2204 t.vtinfo = new TypeInfoSharedDeclaration(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2205 else if (t.isConst())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2206 t.vtinfo = new TypeInfoConstDeclaration(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2207 else if (t.isInvariant())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2208 t.vtinfo = new TypeInfoInvariantDeclaration(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2209 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2210 t.vtinfo = t.getTypeInfoDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2211 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2212 t.vtinfo = t.getTypeInfoDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2213 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2214 assert(t.vtinfo);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2215 vtinfo = t.vtinfo;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2216
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2217 /* If this has a custom implementation in std/typeinfo, then
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2218 * do not generate a COMDAT for it.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2219 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2220 if (!t.builtinTypeInfo())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2221 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2222 // Generate COMDAT
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2223 if (sc) // if in semantic() pass
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2224 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2225 // Find module that will go all the way to an object file
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2226 Module m = sc.module_.importedFrom;
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 73
diff changeset
2227 m.members.push(t.vtinfo);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2228 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2229 else // if in obj generation pass
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2230 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2231 t.vtinfo.toObjFile(global.params.multiobj);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2232 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2233 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2234 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2235 e = new VarExp(Loc(0), t.vtinfo);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2236 e = e.addressOf(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2237 e.type = t.vtinfo.type; // do this so we don't get redundant dereference
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2238 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2239 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2240
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2241 TypeInfoDeclaration getTypeInfoDeclaration()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2242 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2243 //printf("Type.getTypeInfoDeclaration() %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2244 return new TypeInfoDeclaration(this, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2245 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2246
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2247 /* These decide if there's an instance for them already in std.typeinfo,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2248 * because then the compiler doesn't need to build one.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2249 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2250 bool builtinTypeInfo()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2251 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2252 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2253 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2254
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2255 /*******************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2256 * If one of the subtypes of this type is a TypeIdentifier,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2257 * i.e. it's an unresolved type, return that type.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2258 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2259 Type reliesOnTident()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2260 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2261 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2262 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2263
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2264 Expression toExpression()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2265 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2266 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2267 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2268
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2269 /***************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2270 * Return true if type has pointers that need to
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2271 * be scanned by the GC during a collection cycle.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2272 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2273 bool hasPointers()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2274 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2275 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2276 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2277
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2278 /*************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2279 * If this is a type of something, return that something.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2280 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2281 Type nextOf()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2282 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2283 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2284 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2285
53
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2286 /****************************************
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2287 * Return the mask that an integral type will
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2288 * fit into.
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2289 */
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2290 ulong sizemask()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2291 {
53
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2292 ulong m;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2293
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2294 switch (toBasetype().ty)
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2295 {
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2296 case Tbool: m = 1; break;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2297 case Tchar:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2298 case Tint8:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2299 case Tuns8: m = 0xFF; break;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2300 case Twchar:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2301 case Tint16:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2302 case Tuns16: m = 0xFFFFUL; break;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2303 case Tdchar:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2304 case Tint32:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2305 case Tuns32: m = 0xFFFFFFFFUL; break;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2306 case Tint64:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2307 case Tuns64: m = 0xFFFFFFFFFFFFFFFFUL; break;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2308 default:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2309 assert(0);
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2310 }
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 51
diff changeset
2311 return m;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2312 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2313
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2314 static void error(T...)(Loc loc, string format, T t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2315 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2316 .error(loc, format, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2317 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2318
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2319 static void warning(T...)(Loc loc, string format, T t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2320 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2321 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2322 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2323
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2324 // For backend
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2325 /*****************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2326 * Return back end type corresponding to D front end type.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2327 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2328 TYM totym()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2329 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2330 TYM t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2331
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2332 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2333 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2334 case TY.Tvoid: t = TYM.TYvoid; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2335 case TY.Tint8: t = TYM.TYschar; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2336 case TY.Tuns8: t = TYM.TYuchar; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2337 case TY.Tint16: t = TYM.TYshort; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2338 case TY.Tuns16: t = TYM.TYushort; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2339 case TY.Tint32: t = TYM.TYint; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2340 case TY.Tuns32: t = TYM.TYuint; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2341 case TY.Tint64: t = TYM.TYllong; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2342 case TY.Tuns64: t = TYM.TYullong; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2343 case TY.Tfloat32: t = TYM.TYfloat; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2344 case TY.Tfloat64: t = TYM.TYdouble; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2345 case TY.Tfloat80: t = TYM.TYldouble; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2346 case TY.Timaginary32: t = TYM.TYifloat; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2347 case TY.Timaginary64: t = TYM.TYidouble; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2348 case TY.Timaginary80: t = TYM.TYildouble; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2349 case TY.Tcomplex32: t = TYM.TYcfloat; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2350 case TY.Tcomplex64: t = TYM.TYcdouble; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2351 case TY.Tcomplex80: t = TYM.TYcldouble; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2352 //case Tbit: t = TYM.TYuchar; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2353 case TY.Tbool: t = TYM.TYbool; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2354 case TY.Tchar: t = TYM.TYchar; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2355 version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2356 case TY.Twchar: t = TYM.TYwchar_t; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2357 case TY.Tdchar: t = TYM.TYdchar; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2358 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2359 case TY.Twchar: t = TYM.TYwchar_t; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2360 case TY.Tdchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2361 t = (global.params.symdebug == 1) ? TYM.TYdchar : TYM.TYulong;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2362 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2363 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2364
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2365 case TY.Taarray: t = TYM.TYaarray; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2366 case TY.Tclass:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2367 case TY.Treference:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2368 case TY.Tpointer: t = TYM.TYnptr; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2369 case TY.Tdelegate: t = TYM.TYdelegate; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2370 case TY.Tarray: t = TYM.TYdarray; break;
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2371 version(SARRAYVALUE)
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2372 { case TY.Tsarray: t = TYstruct; break;}
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2373 else
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2374 { case TY.Tsarray: t = TYM.TYarray; break;}
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2375 case TY.Tstruct: t = TYM.TYstruct; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2376
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2377 case TY.Tenum:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2378 case TY.Ttypedef:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2379 t = toBasetype().totym();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2380 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2381
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2382 case TY.Tident:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2383 case TY.Ttypeof:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2384 debug {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2385 writef("ty = %d, '%s'\n", ty, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2386 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2387 error (Loc(0), "forward reference of %s", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2388 t = TYM.TYint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2389 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2390
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2391 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2392 debug {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2393 writef("ty = %d, '%s'\n", ty, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2394 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2395 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2396 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2397
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2398 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2399 // Add modifiers
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2400 switch (mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2401 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2402 case MOD.MODundefined:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2403 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2404 case MOD.MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2405 t |= mTY.mTYconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2406 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2407 case MOD.MODinvariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2408 t |= mTY.mTYimmutable;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2409 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2410 case MOD.MODshared:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2411 t |= mTY.mTYshared;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2412 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2413 case MOD.MODshared | MOD.MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2414 t |= mTY.mTYshared | mTY.mTYconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2415 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2416 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2417 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2418 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2419 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2420
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2421 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2422 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2423
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2424 /***************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2425 * Convert from D type to C type.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2426 * This is done so C debug info can be generated.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2427 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2428 type* toCtype()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2429 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2430 if (!ctype)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2431 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2432 ctype = type_fake(totym());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2433 ctype.Tcount++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2434 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2435 return ctype;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2436 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2437
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2438 type* toCParamtype()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2439 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2440 return toCtype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2441 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2442
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2443 Symbol* toSymbol()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2444 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2445 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2446 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2447
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2448 // For eliminating dynamic_cast
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2449 TypeBasic isTypeBasic()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2450 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2451 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2452 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2453
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2454 static Type tvoid()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2455 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2456 return basic[TY.Tvoid];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2457 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2458
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2459 static Type tint8()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2460 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2461 return basic[TY.Tint8];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2462 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2463
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2464 static Type tuns8()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2465 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2466 return basic[TY.Tuns8];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2467 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2468
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2469 static Type tint16()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2470 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2471 return basic[TY.Tint16];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2472 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2473
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2474 static Type tuns16()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2475 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2476 return basic[TY.Tuns16];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2477 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2478
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2479 static Type tint32()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2480 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2481 return basic[TY.Tint32];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2482 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2483
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2484 static Type tuns32()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2485 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2486 return basic[TY.Tuns32];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2487 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2488
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2489 static Type tint64()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2490 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2491 return basic[TY.Tint64];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2492 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2493
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2494 static Type tuns64()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2495 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2496 return basic[TY.Tuns64];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2497 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2498
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2499 static Type tfloat32()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2500 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2501 return basic[TY.Tfloat32];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2502 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2503
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2504 static Type tfloat64()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2505 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2506 return basic[TY.Tfloat64];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2507 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2508
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2509 static Type tfloat80()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2510 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2511 return basic[TY.Tfloat80];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2512 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2513
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2514 static Type timaginary32()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2515 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2516 return basic[TY.Timaginary32];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2517 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2518
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2519 static Type timaginary64()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2520 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2521 return basic[TY.Timaginary64];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2522 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2523
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2524 static Type timaginary80()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2525 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2526 return basic[TY.Timaginary80];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2527 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2528
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2529 static Type tcomplex32()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2530 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2531 return basic[TY.Tcomplex32];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2532 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2533
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2534 static Type tcomplex64()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2535 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2536 return basic[TY.Tcomplex64];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2537 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2538
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2539 static Type tcomplex80()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2540 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2541 return basic[TY.Tcomplex80];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2542 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2543
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2544 static Type tbit()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2545 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2546 return basic[TY.Tbit];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2547 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2548
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2549 static Type tbool()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2550 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2551 return basic[TY.Tbool];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2552 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2553
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2554 static Type tchar()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2555 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2556 return basic[TY.Tchar];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2557 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2558
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2559 static Type twchar()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2560 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2561 return basic[TY.Twchar];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2562 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2563
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2564 static Type tdchar()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2565 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2566 return basic[TY.Tdchar];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2567 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2568
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2569 // Some special types
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2570 static Type tshiftcnt()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2571 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2572 return tint32; // right side of shift expression
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2573 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2574
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2575 // #define tboolean tint32 // result of boolean expression
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2576 static Type tboolean()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2577 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2578 return tbool; // result of boolean expression
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2579 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2580
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2581 static Type tindex()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2582 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2583 return tint32; // array/ptr index
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2584 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2585
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2586 static Type tvoidptr; // void*
98
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2587 static Type tstring; // immutable(char)[]
5c859d5fbe27 and more
Trass3r
parents: 95
diff changeset
2588
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2589 static Type terror()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2590 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2591 return basic[TY.Terror]; // for error recovery
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2592 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2593
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2594 static Type tsize_t()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2595 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2596 return basic[Tsize_t]; // matches size_t alias
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2597 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2598
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2599 static Type tptrdiff_t()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2600 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2601 return basic[Tptrdiff_t]; // matches ptrdiff_t alias
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2602 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2603
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2604 static Type thash_t()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2605 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2606 return tsize_t; // matches hash_t alias
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2607 }
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: 4
diff changeset
2608 }