annotate dmd/InExp.d @ 8:d42cd5917df4

wysiwyg strings, alias this, templates, TypeSlice implementation
author dkoroskin <>
date Mon, 14 Dec 2009 17:43:43 +0300
parents 10317f0c89a5
children 4ae0d790a452
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.InExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.BinExp;
8
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
9 import dmd.TOK;
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
10 import dmd.Type;
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
11 import dmd.TY;
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
12 import dmd.TypeAArray;
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
13
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
14 import dmd.expression.util.arrayTypeCompatible;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.backend.elem;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 class InExp : BinExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 this(Loc loc, Expression e1, Expression e2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 {
8
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
22 super(loc, TOKin, InExp.sizeof, e1, e2);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 Expression semantic(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
8
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
27 if (type)
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
28 return this;
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
29
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
30 super.semanticp(sc);
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
31
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
32 Expression e = op_overload(sc);
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
33 if (e)
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
34 return e;
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
35
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
36 //type = Type.tboolean;
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
37 Type t2b = e2.type.toBasetype();
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
38 if (t2b.ty != TY.Taarray)
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
39 {
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
40 error("rvalue of in expression must be an associative array, not %s", e2.type.toChars());
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
41 type = Type.terror;
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
42 }
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
43 else
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
44 {
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
45 TypeAArray ta = cast(TypeAArray)t2b;
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
46
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
47 // Special handling for array keys
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
48 if (!arrayTypeCompatible(e1.loc, e1.type, ta.index))
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
49 {
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
50 // Convert key to type of key
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
51 e1 = e1.implicitCastTo(sc, ta.index);
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
52 }
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
53
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
54 // Return type is pointer to value
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
55 type = ta.nextOf().pointerTo();
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
56 }
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
57 return this;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 int isBit()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 {
8
d42cd5917df4 wysiwyg strings, alias this, templates, TypeSlice implementation
dkoroskin <>
parents: 0
diff changeset
62 return 0;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 Identifier opId()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 Identifier opId_r()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 elem* toElem(IRState* irs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80