annotate dmd/TypeFunction.d @ 157:b7b61140701d

* added all missing default cases in switch statements + Lexer.getDocComment + Lexer.combineComments
author trass3r
date Thu, 16 Sep 2010 01:34:10 +0200
parents fe2e1b93e88f
children e3afd1303184
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.TypeFunction;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 113
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.TypeNext;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.TypeSArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.TypeArray;
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
7 import dmd.TemplateTupleParameter;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.LINK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.StructDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.TypeStruct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.STC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.MOD;
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
15 import dmd.PROT;
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
16 import dmd.TypeIdentifier;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
17 import dmd.TemplateParameter;
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
18 import dmd.TypeInfoFunctionDeclaration;
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
19 import dmd.Tuple;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.Type;
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.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.CppMangleState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.TypeInfoDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.MATCH;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
29 import dmd.Parameter;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import dmd.RET;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 import dmd.TY;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
33 import dmd.TRUST;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 import dmd.Util;
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
35 import dmd.FuncDeclaration;
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
36 import dmd.Dsymbol;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
37 import dmd.TypeTuple;
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
38 import dmd.TemplateInstance : isTuple;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 import dmd.backend.TYPE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 import dmd.backend.PARAM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 import dmd.backend.TF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 import dmd.backend.mTY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 import core.stdc.stdlib;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 import core.stdc.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
50 import std.stdio;
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
51
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 class TypeFunction : TypeNext
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 // .next is the return type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
56 Parameters parameters; // function parameters
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 int varargs; // 1: T t, ...) style for variable number of arguments
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 // 2: T t ...) style for variable number of arguments
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 bool isnothrow; // true: nothrow
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 bool ispure; // true: pure
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 bool isproperty; // can be called without parentheses
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 bool isref; // true: returns a reference
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 LINK linkage; // calling convention
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
64 TRUST trust; // level of trust
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
65 Expressions fargs; // function arguments
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 int inuse;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
69 this(Parameters parameters, Type treturn, int varargs, LINK linkage)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 super(TY.Tfunction, treturn);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 //if (!treturn) *(char*)0=0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 // assert(treturn);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 assert(0 <= varargs && varargs <= 2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 this.parameters = parameters;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 this.varargs = varargs;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 this.linkage = linkage;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
79 this.trust = TRUSTdefault;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
82 override Type syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 Type treturn = next ? next.syntaxCopy() : null;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
85 auto params = Parameter.arraySyntaxCopy(parameters);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 TypeFunction t = new TypeFunction(params, treturn, varargs, linkage);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 t.mod = mod;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 t.isnothrow = isnothrow;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 t.ispure = ispure;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 t.isproperty = isproperty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 t.isref = isref;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
92 t.trust = trust;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
93 t.fargs = fargs;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 version (DumbClone) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 final TypeFunction cloneTo(TypeFunction t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 super.cloneTo(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 // these 3 should be set by ctor
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 assert(t.parameters is null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 assert(t.varargs == varargs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 assert(t.linkage == linkage);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 t.isnothrow = isnothrow;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 t.ispure = ispure;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 t.isproperty = isproperty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 t.isref = isref;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 t.inuse = inuse;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 if (parameters)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 t.parameters = parameters.copy();
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
118 foreach (arg; parameters)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 Argument cpy = arg.clone();
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
121 t.parameters[i] = cpy;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 TypeFunction clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 {
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
130 assert(this.classinfo is TypeFunction.classinfo);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 return cloneTo(new TypeFunction(null, next, varargs, linkage));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
134 override Type semantic(Loc loc, Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 if (deco) // if semantic() already run
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 //printf("already done\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 //printf("TypeFunction.semantic() this = %p\n", this);
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
142 //printf("TypeFunction::semantic() %s, sc->stc = %llx, fargs = %p\n", toChars(), sc->stc, fargs);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 /* Copy in order to not mess up original.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 * This can produce redundant copies if inferring return type,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 * as semantic() will get called again on this.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
149 TypeFunction tf = cloneThis(this);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 if (sc.stc & STC.STCpure)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 tf.ispure = true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 if (sc.stc & STC.STCnothrow)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 tf.isnothrow = true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 if (sc.stc & STC.STCref)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 tf.isref = true;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
157 if (sc.stc & STCsafe)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
158 tf.trust = TRUST.TRUSTsafe;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
159 if (sc.stc & STCtrusted)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
160 tf.trust = TRUST.TRUSTtrusted;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
161 if (sc.stc & STCproperty)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
162 tf.isproperty = true;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
163
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
164 tf.linkage = sc.linkage;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
165
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
166 /* If the parent is @safe, then this function defaults to safe
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
167 * too.
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
168 */
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
169 if (tf.trust == TRUST.TRUSTdefault)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
170 for (Dsymbol p = sc.func; p; p = p.toParent2())
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
171 { FuncDeclaration fd = p.isFuncDeclaration();
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
172 if (fd)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
173 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
174 if (fd.isSafe())
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
175 tf.trust = TRUST.TRUSTsafe; // default to @safe
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
176 break;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
177 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
178 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
180 bool wildreturn = false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 if (tf.next)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 tf.next = tf.next.semantic(loc,sc);
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
184 version(SARRAYVALUE) {} else
acd69f84627e further work
Trass3r
parents: 95
diff changeset
185 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 if (tf.next.toBasetype().ty == TY.Tsarray)
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
187 {
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
188 error(loc, "functions cannot return static array %s", tf.next.toChars());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 tf.next = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 }
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
191 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 if (tf.next.toBasetype().ty == TY.Tfunction)
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
193 {
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
194 error(loc, "functions cannot return a function");
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 tf.next = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 if (tf.next.toBasetype().ty == TY.Ttuple)
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
198 {
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
199 error(loc, "functions cannot return a tuple");
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 tf.next = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 if (tf.next.isauto() && !(sc.flags & SCOPE.SCOPEctor))
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
203 error(loc, "functions cannot return scope %s", tf.next.toChars());
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
204 if (tf.next.toBasetype().ty == TY.Tvoid)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
205 tf.isref = false; // rewrite "ref void" as just "void"
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
206 if (tf.next.isWild())
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
207 wildreturn = true;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
208 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
210 bool wildparams = false;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
211 bool wildsubparams = false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 if (tf.parameters)
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
213 {
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
214 /* Create a scope for evaluating the default arguments for the parameters
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
215 */
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
216 Scope argsc = sc.push();
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
217 argsc.stc = STCundefined; // don't inherit storage class
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
218 argsc.protection = PROT.PROTpublic;
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
219
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
220 size_t dim = Parameter.dim(tf.parameters);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 for (size_t i = 0; i < dim; i++)
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
223 { auto fparam = Parameter.getNth(tf.parameters, i);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 tf.inuse++;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
226 fparam.type = fparam.type.semantic(loc, argsc);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 if (tf.inuse == 1) tf.inuse--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
229 fparam.type = fparam.type.addStorageClass(fparam.storageClass);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
231 if (fparam.storageClass & (STC.STCauto | STC.STCalias | STC.STCstatic))
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 {
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
233 if (!fparam.type)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
237 Type t = fparam.type.toBasetype();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
239 if (fparam.storageClass & (STC.STCout | STC.STCref | STC.STClazy))
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 {
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
241 //if (t.ty == TY.Tsarray)
acd69f84627e further work
Trass3r
parents: 95
diff changeset
242 //error(loc, "cannot have out or ref parameter of type %s", t.toChars());
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
243 if (fparam.storageClass & STC.STCout && fparam.type.mod & (STCconst | STCimmutable))
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
244 error(loc, "cannot have const or immutabl out parameter of type %s", t.toChars());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 }
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
246 if (!(fparam.storageClass & STC.STClazy) && t.ty == TY.Tvoid)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
247 error(loc, "cannot have parameter of type %s", fparam.type.toChars());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
249 if (t.isWild())
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
250 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
251 wildparams = true;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
252 if (tf.next && !wildreturn)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
253 error(loc, "inout on parameter means inout must be on return type as well (if from D1 code, replace with 'ref')");
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
254 }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
255 else if (!wildsubparams && t.hasWild())
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
256 wildsubparams = true;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
258 if (fparam.defaultArg)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
259 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
260 fparam.defaultArg = fparam.defaultArg.semantic(argsc);
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
261 fparam.defaultArg = resolveProperties(argsc, fparam.defaultArg);
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
262 fparam.defaultArg = fparam.defaultArg.implicitCastTo(argsc, fparam.type);
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
263 }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
264
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
265 /* If fparam turns out to be a tuple, the number of parameters may
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 * change.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 if (t.ty == TY.Ttuple)
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
269 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
270 // Propagate storage class from tuple parameters to their element-parameters.
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
271 auto tt = cast(TypeTuple)t;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
272 if (tt.arguments)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
273 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
274 auto tdim = tt.arguments.dim;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
275 foreach (narg; tt.arguments)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
276 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
277 narg.storageClass = fparam.storageClass;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
278 }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
279 }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
280
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
281 /* Reset number of parameters, and back up one to do this fparam again,
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
282 * now that it is the first element of a tuple
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
283 */
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
284 dim = Parameter.dim(tf.parameters);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 i--;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
286 continue;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 }
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
288
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
289 /* Resolve "auto ref" storage class to be either ref or value,
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
290 * based on the argument matching the parameter
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
291 */
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
292 if (fparam.storageClass & STC.STCauto)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
293 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
294 if (fargs && i < fargs.dim)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
295 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
296 auto farg = fargs[i];
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
297 if (farg.isLvalue())
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
298 {} // ref parameter
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
299 else
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
300 fparam.storageClass &= ~STC.STCref; // value parameter
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
301 }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
302 else
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
303 error(loc, "auto can only be used for template function parameters");
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
304 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 }
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
306 argsc.pop();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 }
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
308
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
309 if (wildreturn && !wildparams)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
310 error(loc, "inout on return means inout must be on a parameter as well for %s", toChars());
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
311 if (wildsubparams && wildparams)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
312 error(loc, "inout must be all or none on top level for %s", toChars());
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
313
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 if (tf.next)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 tf.deco = tf.merge().deco;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 if (tf.inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 { error(loc, "recursive type");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 tf.inuse = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 return terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
323 if (tf.isproperty && (tf.varargs || Parameter.dim(tf.parameters) > 1))
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
324 error(loc, "properties can only have zero or one parameter");
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
325
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
326 if (tf.varargs == 1 && tf.linkage != LINK.LINKd && Parameter.dim(tf.parameters) == 0)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 error(loc, "variadic functions with non-D linkage must have at least one parameter");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 /* Don't return merge(), because arg identifiers and default args
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 * can be different
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 * even though the types match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 return tf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
336 override void toDecoBuffer(OutBuffer buf, int flag)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 ubyte mc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 //printf("TypeFunction.toDecoBuffer() this = %p %s\n", this, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 //static int nest; if (++nest == 50) *(char*)0=0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 if (inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 inuse = 2; // flag error to caller
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 inuse++;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
348 MODtoDecoBuffer(buf, mod);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 switch (linkage)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 case LINK.LINKd: mc = 'F'; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 case LINK.LINKc: mc = 'U'; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 case LINK.LINKwindows: mc = 'W'; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 case LINK.LINKpascal: mc = 'V'; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 case LINK.LINKcpp: mc = 'R'; break;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 148
diff changeset
356 default:
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 148
diff changeset
357 writef("linkage: %d\n", linkage);
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 148
diff changeset
358 assert(false, "ICE: undefined linkage occured");
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 buf.writeByte(mc);
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
361 if (ispure || isnothrow || isproperty || isref || trust)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 if (ispure)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 buf.writestring("Na");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 if (isnothrow)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 buf.writestring("Nb");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 if (isref)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 buf.writestring("Nc");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 if (isproperty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 buf.writestring("Nd");
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
371 switch (trust)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
372 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
373 case TRUST.TRUSTtrusted:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
374 buf.writestring("Ne");
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
375 break;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
376 case TRUST.TRUSTsafe:
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
377 buf.writestring("Nf");
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
378 break;
132
c494af1dba80 Fixes for dmd 2.037
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 131
diff changeset
379 default:
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
380 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 // Write argument types
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
383 Parameter.argsToDecoBuffer(buf, parameters);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 //if (buf.data[buf.offset - 1] == '@') halt();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 buf.writeByte('Z' - varargs); // mark end of arg list
79
43073c7c7769 updated to 2.035
Trass3r
parents: 73
diff changeset
386 assert(next);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 next.toDecoBuffer(buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 inuse--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
391 override void toCBuffer(OutBuffer buf, Identifier ident, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 //printf("TypeFunction.toCBuffer() this = %p\n", this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 string p = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 if (inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 inuse = 2; // flag error to caller
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 inuse++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 /* Use 'storage class' style for attributes
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 */
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
405 if (mod)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
406 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
407 MODtoBuffer(buf, mod);
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
408 buf.writeByte(' ');
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
409 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 if (ispure)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 buf.writestring("pure ");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 if (isnothrow)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 buf.writestring("nothrow ");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 if (isproperty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 buf.writestring("@property ");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 if (isref)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 buf.writestring("ref ");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
420 switch (trust)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
421 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
422 case TRUST.TRUSTtrusted:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
423 buf.writestring("@trusted ");
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
424 break;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
425
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
426 case TRUST.TRUSTsafe:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
427 buf.writestring("@safe ");
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
428 break;
148
fe2e1b93e88f phobos compiles now:
Trass3r
parents: 143
diff changeset
429
fe2e1b93e88f phobos compiles now:
Trass3r
parents: 143
diff changeset
430 default:
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
431 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
432
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 if (next && (!ident || ident.toHChars2() == ident.toChars()))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 next.toCBuffer2(buf, hgs, MODundefined);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 if (hgs.ddoc != 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 switch (linkage)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 case LINKd: p = null; break;
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
440 case LINKc: p = " C"; break;
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
441 case LINKwindows: p = " Windows"; break;
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
442 case LINKpascal: p = " Pascal"; break;
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
443 case LINKcpp: p = " C++"; break;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 if (!hgs.hdrgen && p)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 buf.writestring(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 if (ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 buf.writeByte(' ');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 buf.writestring(ident.toHChars2());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
456 Parameter.argsToCBuffer(buf, hgs, parameters, varargs);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 inuse--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
460 override void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 //printf("TypeFunction::toCBuffer2() this = %p, ref = %d\n", this, isref);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 string p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 if (inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 inuse = 2; // flag error to caller
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 inuse++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 if (next)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 next.toCBuffer2(buf, hgs, MODundefined);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 if (hgs.ddoc != 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 switch (linkage)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 case LINKd: p = null; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 case LINKc: p = "C "; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 case LINKwindows: p = "Windows "; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 case LINKpascal: p = "Pascal "; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 case LINKcpp: p = "C++ "; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 default: assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 if (!hgs.hdrgen && p)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 buf.writestring(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 buf.writestring(" function");
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
491 Parameter.argsToCBuffer(buf, hgs, parameters, varargs);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 /* Use postfix style for attributes
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 if (mod != this.mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 modToBuffer(buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 if (ispure)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 buf.writestring(" pure");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 if (isnothrow)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 buf.writestring(" nothrow");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 if (isproperty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 buf.writestring(" @property");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 if (isref)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 buf.writestring(" ref");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
509 switch (trust)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
510 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
511 case TRUSTtrusted:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
512 buf.writestring(" @trusted");
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
513 break;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
514
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
515 case TRUSTsafe:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
516 buf.writestring(" @safe");
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
517 break;
143
95b3ed3cddd5 fixed phobos compilation bug
Trass3r
parents: 135
diff changeset
518
95b3ed3cddd5 fixed phobos compilation bug
Trass3r
parents: 135
diff changeset
519 default:
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
520 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 inuse--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
524 override MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 {
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
526 //printf("TypeFunction.deduceType()\n");
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
527 //printf("\tthis = %d, ", ty); print();
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
528 //printf("\ttparam = %d, ", tparam.ty); tparam.print();
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
529
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
530 // Extra check that function characteristics must match
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
531 if (tparam && tparam.ty == Tfunction)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
532 {
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
533 TypeFunction tp = cast(TypeFunction)tparam;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
534 if (varargs != tp.varargs ||
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
535 linkage != tp.linkage)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
536 return MATCHnomatch;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
537
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
538 size_t nfargs = Parameter.dim(this.parameters);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
539 size_t nfparams = Parameter.dim(tp.parameters);
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
540
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
541 /* See if tuple match
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
542 */
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
543 if (nfparams > 0 && nfargs >= nfparams - 1)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
544 {
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
545 /* See if 'A' of the template parameter matches 'A'
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
546 * of the type of the last function parameter.
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
547 */
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
548 auto fparam = Parameter.getNth(tp.parameters, nfparams - 1);
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
549 assert(fparam);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
550 assert(fparam.type);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
551 if (fparam.type.ty != Tident)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
552 goto L1;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
553 TypeIdentifier tid = cast(TypeIdentifier)fparam.type;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
554 if (tid.idents.dim)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
555 goto L1;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
556
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
557 /* Look through parameters to find tuple matching tid.ident
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
558 */
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
559 size_t tupi = 0;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
560 for (; 1; tupi++)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
561 {
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
562 if (tupi == parameters.dim)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
563 goto L1;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
564 TemplateParameter t = parameters[tupi];
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
565 TemplateTupleParameter tup = t.isTemplateTupleParameter();
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
566 if (tup && tup.ident.equals(tid.ident))
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
567 break;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
568 }
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
569
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
570 /* The types of the function arguments [nfparams - 1 .. nfargs]
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
571 * now form the tuple argument.
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
572 */
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
573 int tuple_dim = nfargs - (nfparams - 1);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
574
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
575 /* See if existing tuple, and whether it matches or not
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
576 */
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
577 Object o = dedtypes[tupi];
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
578 if (o)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
579 {
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
580 // Existing deduced argument must be a tuple, and must match
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
581 Tuple t = isTuple(o);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
582 if (!t || t.objects.dim != tuple_dim)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
583 return MATCHnomatch;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
584 for (size_t i = 0; i < tuple_dim; i++)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
585 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
586 auto arg = Parameter.getNth(this.parameters, nfparams - 1 + i);
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
587 if (!arg.type.equals(t.objects[i]))
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
588 return MATCHnomatch;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
589 }
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
590 }
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
591 else
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
592 { // Create new tuple
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
593 Tuple t = new Tuple();
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
594 t.objects.setDim(tuple_dim);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
595 for (size_t i = 0; i < tuple_dim; i++)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
596 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
597 auto arg = Parameter.getNth(this.parameters, nfparams - 1 + i);
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
598 t.objects[i] = arg.type;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
599 }
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
600 dedtypes[tupi] = t;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
601 }
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
602 nfparams--; // don't consider the last parameter for type deduction
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
603 goto L2;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
604 }
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
605
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
606 L1:
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
607 if (nfargs != nfparams)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
608 return MATCHnomatch;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
609 L2:
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
610 for (size_t i = 0; i < nfparams; i++)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
611 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
612 auto a = Parameter.getNth(this.parameters, i);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
613 auto ap = Parameter.getNth(tp.parameters, i);
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
614 if (a.storageClass != ap.storageClass ||
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
615 !a.type.deduceType(sc, ap.type, parameters, dedtypes))
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
616 return MATCHnomatch;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
617 }
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
618 }
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
619 return Type.deduceType(sc, tparam, parameters, dedtypes);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
622 override TypeInfoDeclaration getTypeInfoDeclaration()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
623 {
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 126
diff changeset
624 return new TypeInfoFunctionDeclaration(this);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
627 override Type reliesOnTident()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628 {
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
629 size_t dim = Parameter.dim(parameters);
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
630 for (size_t i = 0; i < dim; i++)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
631 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
632 auto fparam = Parameter.getNth(parameters, i);
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
633 Type t = fparam.type.reliesOnTident();
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
634 if (t)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
635 return t;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
636 }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
637 return next ? next.reliesOnTident() : null;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
640 version (CPP_MANGLE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 void toCppMangle(OutBuffer buf, CppMangleState* cms)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
647 /***************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
648 * Examine function signature for parameter p and see if
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649 * p can 'escape' the scope of the function.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 */
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
651 bool parameterEscapes(Parameter p)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
652 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653 /* Scope parameters do not escape.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 * Allow 'lazy' to imply 'scope' -
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655 * lazy parameters can be passed along
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656 * as lazy parameters to the next function, but that isn't
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 * escaping.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
659 if (p.storageClass & (STC.STCscope | STC.STClazy))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
660 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
661
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662 if (ispure)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663 { /* With pure functions, we need only be concerned if p escapes
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664 * via any return statement.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
666 Type tret = nextOf().toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667 if (!isref && !tret.hasPointers())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668 { /* The result has no references, so p could not be escaping
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669 * that way.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675 /* Assume it escapes in the absence of better information.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680 /********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 * 'args' are being matched to function 'this'
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
682 * Determine match level.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
683 * Returns:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
684 * MATCHxxxx
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
685 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686 MATCH callMatch(Expression ethis, Expressions args)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
687 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688 //printf("TypeFunction.callMatch() %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 MATCH match = MATCH.MATCHexact; // assume exact match
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
690 bool exactwildmatch = false;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
691 bool wildmatch = false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
692
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
693 if (ethis)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695 Type t = ethis.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696 if (t.toBasetype().ty == TY.Tpointer)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 t = t.toBasetype().nextOf(); // change struct* to struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699 if (t.mod != mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
700 {
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
701 if (MODimplicitConv(t.mod, mod))
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
702 match = MATCH.MATCHconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
704 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
708 size_t nparams = Parameter.dim(parameters);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 size_t nargs = args ? args.dim : 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
710 if (nparams == nargs) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
711 ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
712 } else if (nargs > nparams)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 if (varargs == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715 goto Nomatch; // too many args; no match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 match = MATCH.MATCHconvert; // match ... with a "conversion" match level
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719 for (size_t u = 0; u < nparams; u++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721 MATCH m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
722 Expression arg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 // BUG: what about out and ref?
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
726 auto p = Parameter.getNth(parameters, u);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 assert(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728 if (u >= nargs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730 if (p.defaultArg)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732 if (varargs == 2 && u + 1 == nparams)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733 goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
734 goto Nomatch; // not enough arguments
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
736
113
3482c73a991b More cleanup for arrays
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 96
diff changeset
737 arg = cast(Expression)args[u];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738 assert(arg);
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
739 // writef("arg: %s, type: %s\n", arg.toChars(), arg.type.toChars());
acd69f84627e further work
Trass3r
parents: 95
diff changeset
740
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742 // Non-lvalues do not match ref or out parameters
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
743 if (p.storageClass & (STC.STCref | STC.STCout))
acd69f84627e further work
Trass3r
parents: 95
diff changeset
744 {
acd69f84627e further work
Trass3r
parents: 95
diff changeset
745 if (!arg.isLvalue())
acd69f84627e further work
Trass3r
parents: 95
diff changeset
746 goto Nomatch;
acd69f84627e further work
Trass3r
parents: 95
diff changeset
747 }
acd69f84627e further work
Trass3r
parents: 95
diff changeset
748
acd69f84627e further work
Trass3r
parents: 95
diff changeset
749 if (p.storageClass & STCref)
acd69f84627e further work
Trass3r
parents: 95
diff changeset
750 {
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
751 /* Don't allow static arrays to be passed to mutable references
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
752 * to static arrays if the argument cannot be modified.
acd69f84627e further work
Trass3r
parents: 95
diff changeset
753 */
acd69f84627e further work
Trass3r
parents: 95
diff changeset
754 Type targb = arg.type.toBasetype();
acd69f84627e further work
Trass3r
parents: 95
diff changeset
755 Type tparb = p.type.toBasetype();
acd69f84627e further work
Trass3r
parents: 95
diff changeset
756 //writef("%s\n", targb.toChars());
acd69f84627e further work
Trass3r
parents: 95
diff changeset
757 //writef("%s\n", tparb.toChars());
acd69f84627e further work
Trass3r
parents: 95
diff changeset
758 if (targb.nextOf() && tparb.ty == Tsarray &&
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
759 !MODimplicitConv(targb.nextOf().mod, tparb.nextOf().mod))
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
760 goto Nomatch;
acd69f84627e further work
Trass3r
parents: 95
diff changeset
761 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
763 if (p.storageClass & STC.STClazy && p.type.ty == TY.Tvoid && arg.type.ty != TY.Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
764 m = MATCH.MATCHconvert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765 else
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
766 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 m = arg.implicitConvTo(p.type);
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
768 if (p.type.isWild())
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
769 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
770 if (m == MATCHnomatch)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
771 {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
772 m = arg.implicitConvTo(p.type.constOf());
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
773 if (m == MATCHnomatch)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
774 m = arg.implicitConvTo(p.type.sharedConstOf());
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
775 if (m != MATCHnomatch)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
776 wildmatch = true; // mod matched to wild
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
777 }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
778 else
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
779 exactwildmatch = true; // wild matched to wild
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
780
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
781 /* If both are allowed, then there could be more than one
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
782 * binding of mod to wild, leaving a gaping type hole.
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
783 */
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
784 if (wildmatch && exactwildmatch)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
785 m = MATCHnomatch;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
786 }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
787 }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 132
diff changeset
788
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 //printf("\tm = %d\n", m);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 if (m == MATCH.MATCHnomatch) // if no match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 L1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793 if (varargs == 2 && u + 1 == nparams) // if last varargs param
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795 Type tb = p.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796 TypeSArray tsa;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
797 long sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
798
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
799 switch (tb.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
800 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801 case TY.Tsarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
802 tsa = cast(TypeSArray)tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
803 sz = tsa.dim.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
804 if (sz != nargs - u)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
805 goto Nomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
806 case TY.Tarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
807 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
808 TypeArray ta = cast(TypeArray)tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
809 for (; u < nargs; u++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
810 {
113
3482c73a991b More cleanup for arrays
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 96
diff changeset
811 arg = cast(Expression)args[u];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
812 assert(arg);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
813 static if (true) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
814 /* If lazy array of delegates,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
815 * convert arg(s) to delegate(s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
816 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
817 Type tret = p.isLazyArray();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
818 if (tret)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
819 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
820 if (ta.next.equals(arg.type))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
821 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
822 m = MATCH.MATCHexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
823 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
824 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
825 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
826 m = arg.implicitConvTo(tret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
827 if (m == MATCH.MATCHnomatch)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
828 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
829 if (tret.toBasetype().ty == TY.Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
830 m = MATCH.MATCHconvert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
831 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
832 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
833 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
834 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
835 m = arg.implicitConvTo(ta.next);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
836 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
837 m = arg.implicitConvTo(ta.next);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
838 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
839 if (m == MATCH.MATCHnomatch)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
840 goto Nomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
841
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
842 if (m < match)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
843 match = m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
844 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
845 goto Ldone;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
846 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
847
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
848 case TY.Tclass:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
849 // Should see if there's a constructor match?
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
850 // Or just leave it ambiguous?
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
851 goto Ldone;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
852
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
853 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
854 goto Nomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
855 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
856 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
857
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
858 goto Nomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
859 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
860
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
861 if (m < match)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
862 match = m; // pick worst match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
863 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
864
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
865 Ldone:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
866 //printf("match = %d\n", match);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
867 return match;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
868
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
869 Nomatch:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
870 //printf("no match\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
871 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
872 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
873
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
874 override type* toCtype()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
875 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
876 if (ctype) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
877 return ctype;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
878 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
879
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
880 type* t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
881 if (true)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
882 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
883 param_t* paramtypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
884 tym_t tyf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
885 type* tp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
886
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
887 paramtypes = null;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
888 size_t nparams = Parameter.dim(parameters);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
889 for (size_t i = 0; i < nparams; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
890 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
891 auto arg = Parameter.getNth(parameters, i);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
892 tp = arg.type.toCtype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
893 if (arg.storageClass & (STC.STCout | STC.STCref))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
894 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
895 // C doesn't have reference types, so it's really a pointer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
896 // to the parameter type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
897 tp = type_allocn(TYM.TYref, tp);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
898 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
899 param_append_type(&paramtypes,tp);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
900 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
901 tyf = totym();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
902 t = type_alloc(tyf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
903 t.Tflags |= TF.TFprototype;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
904 if (varargs != 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
905 t.Tflags |= TF.TFfixed;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
906 ctype = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
907 t.Tnext = next.toCtype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
908 t.Tnext.Tcount++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
909 t.Tparamtypes = paramtypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
910 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
911 ctype = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
912 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
913 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
914
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
915 /***************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
916 * Determine return style of function - whether in registers or
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
917 * through a hidden pointer to the caller's stack.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
918 */
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
919 RET retStyle()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
920 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
921 //printf("TypeFunction.retStyle() %s\n", toChars());
95
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
922 version (DMDV2)
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
923 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
924 if (isref)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
925 return RET.RETregs; // returns a pointer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
926 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
927
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
928 Type tn = next.toBasetype();
95
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
929 Type tns = tn;
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
930 ulong sz = tn.size();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
931
95
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
932 version(SARRAYVALUE)
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
933 {
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
934 if (tn.ty == Tsarray)
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
935 {
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
936 do
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
937 {
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
938 tns = tns.nextOf().toBasetype();
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
939 } while (tns.ty == Tsarray);
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
940 if (tns.ty != Tstruct)
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
941 {
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
942 if (global.params.isLinux && linkage != LINKd)
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
943 {}
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
944 else
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
945 {
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
946 switch (sz)
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
947 { case 1:
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
948 case 2:
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
949 case 4:
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
950 case 8:
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
951 return RET.RETregs; // return small structs in regs
acd69f84627e further work
Trass3r
parents: 95
diff changeset
952 // (not 3 byte structs!)
95
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
953 default:
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
954 break;
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
955 }
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
956 }
96
acd69f84627e further work
Trass3r
parents: 95
diff changeset
957 return RET.RETstack;
95
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
958 }
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
959 }
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
960 }
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
961 if (tns.ty == TY.Tstruct)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
962 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
963 StructDeclaration sd = (cast(TypeStruct)tn).sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
964 if (global.params.isLinux && linkage != LINK.LINKd) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
965 ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
966 }
95
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
967 ///version (DMDV2) { // TODO:
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
968 else if (sd.dtor || sd.cpctor)
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
969 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
970 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
971 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
972 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
973 {
95
ae5b11064a9a beginning of 2.036 branch
Trass3r
parents: 79
diff changeset
974 switch (sz)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
975 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
976 case 1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
977 case 2:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
978 case 4:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
979 case 8:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
980 return RET.RETregs; // return small structs in regs
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
981 // (not 3 byte structs!)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
982 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
983 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
984 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
985 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
986 return RET.RETstack;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
987 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
988 else if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
989 linkage == LINK.LINKc &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
990 tn.iscomplex())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
991 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
992 if (tn.ty == TY.Tcomplex32)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
993 return RET.RETregs; // in EDX:EAX, not ST1:ST0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
994 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
995 return RET.RETstack;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
996 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
997 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
998 return RET.RETregs;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
999 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1000
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
1001 override TYM totym()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1002 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1003 TYM tyf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1004
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1005 //printf("TypeFunction.totym(), linkage = %d\n", linkage);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1006 switch (linkage)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1007 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1008 case LINK.LINKwindows:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1009 tyf = (varargs == 1) ? TYM.TYnfunc : TYM.TYnsfunc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1010 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1011
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1012 case LINK.LINKpascal:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1013 tyf = (varargs == 1) ? TYM.TYnfunc : TYM.TYnpfunc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1014 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1015
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1016 case LINK.LINKc:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1017 tyf = TYM.TYnfunc;
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
1018 version (POSIX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1019 if (retStyle() == RET.RETstack)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1020 tyf = TYM.TYhfunc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1021 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1022 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1023
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1024 case LINK.LINKd:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1025 tyf = (varargs == 1) ? TYM.TYnfunc : TYM.TYjfunc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1026 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1027
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1028 case LINK.LINKcpp:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1029 tyf = TYM.TYnfunc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1030 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1031
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1032 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1033 writef("linkage = %d\n", linkage);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1034 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1035 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1036 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1037 if (isnothrow)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1038 tyf |= mTY.mTYnothrow;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1039 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1040 return tyf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1041 }
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
1042 }