0
|
1 module dmd.type.Util;
|
|
2
|
114
|
3 import dmd.common;
|
0
|
4 import dmd.TY;
|
|
5 import dmd.Expression;
|
|
6 import dmd.Scope;
|
|
7 import dmd.Type;
|
|
8 import dmd.TupleDeclaration;
|
|
9 import dmd.TypeTuple;
|
|
10 import dmd.ScopeDsymbol;
|
|
11 import dmd.ArrayScopeSymbol;
|
|
12
|
|
13 /**************************
|
|
14 * This evaluates exp while setting length to be the number
|
|
15 * of elements in the tuple t.
|
|
16 */
|
|
17 Expression semanticLength(Scope sc, Type t, Expression exp)
|
|
18 {
|
|
19 if (t.ty == TY.Ttuple)
|
|
20 {
|
|
21 ScopeDsymbol sym = new ArrayScopeSymbol(sc, cast(TypeTuple)t);
|
|
22 sym.parent = sc.scopesym;
|
|
23 sc = sc.push(sym);
|
|
24
|
|
25 exp = exp.semantic(sc);
|
|
26
|
|
27 sc.pop();
|
|
28 }
|
|
29 else
|
|
30 exp = exp.semantic(sc);
|
|
31
|
|
32 return exp;
|
|
33 }
|
|
34
|
|
35 Expression semanticLength(Scope sc, TupleDeclaration s, Expression exp)
|
|
36 {
|
|
37 assert(false);
|
|
38
|
|
39 ScopeDsymbol sym = new ArrayScopeSymbol(sc, s);
|
|
40 sym.parent = sc.scopesym;
|
|
41 sc = sc.push(sym);
|
|
42
|
|
43 exp = exp.semantic(sc);
|
|
44
|
|
45 sc.pop();
|
|
46 return exp;
|
|
47 } |