annotate dmd/type/Util.d @ 114:e28b18c23469

added a module dmd.common for commonly used stuff it currently holds code for consistency checking of predefined versions also added a VisualD project file
author Trass3r
date Wed, 01 Sep 2010 18:21:58 +0200
parents 10317f0c89a5
children b7b61140701d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.type.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 0
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.TupleDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.TypeTuple;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.ScopeDsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.ArrayScopeSymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 /**************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 * This evaluates exp while setting length to be the number
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 * of elements in the tuple t.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 Expression semanticLength(Scope sc, Type t, Expression exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 if (t.ty == TY.Ttuple)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 ScopeDsymbol sym = new ArrayScopeSymbol(sc, cast(TypeTuple)t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 sym.parent = sc.scopesym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 sc = sc.push(sym);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 exp = exp.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 sc.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 exp = exp.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 return exp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 Expression semanticLength(Scope sc, TupleDeclaration s, Expression exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 ScopeDsymbol sym = new ArrayScopeSymbol(sc, s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 sym.parent = sc.scopesym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 sc = sc.push(sym);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 exp = exp.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 sc.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 return exp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 }