annotate dmd/Type.d @ 130:60bb0fe4563e

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