annotate dmd/Type.d @ 87:b17640f0e4e8

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