annotate dmd/Type.d @ 95:ae5b11064a9a

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