annotate dmd/TypeReturn.d @ 132:c494af1dba80

Fixes for dmd 2.037
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Fri, 10 Sep 2010 19:14:09 +0100
parents 60bb0fe4563e
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.TypeReturn;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.MOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.TypeQualified;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.HdrGenState;
1
5a2059196104 Project build commands update
korDen
parents: 0
diff changeset
12 import dmd.Identifier;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 class TypeReturn : TypeQualified
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 this(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 super(TY.Treturn, loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 version (DumbClone) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 Type clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 1
diff changeset
30 override Type syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 TypeReturn t = new TypeReturn(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 t.syntaxCopyHelper(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 t.mod = mod;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 1
diff changeset
38 override Dsymbol toDsymbol(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 {
1
5a2059196104 Project build commands update
korDen
parents: 0
diff changeset
40 Type t = semantic(Loc(0), sc);
5a2059196104 Project build commands update
korDen
parents: 0
diff changeset
41 if (t is this)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 return null;
1
5a2059196104 Project build commands update
korDen
parents: 0
diff changeset
43
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 return t.toDsymbol(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 1
diff changeset
47 override Type semantic(Loc loc, Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 if (!sc.func)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 error(loc, "typeof(return) must be inside function");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 goto Lerr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 t = sc.func.type.nextOf();
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
56 if (!t)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
57 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
58 error(loc, "cannot use typeof(return) inside function %s with inferred return type", sc.func.toChars());
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
59 goto Lerr;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
60 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 t = t.addMod(mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 if (idents.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 Dsymbol s = t.toDsymbol(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 for (size_t i = 0; i < idents.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 if (!s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 Identifier id = cast(Identifier)idents.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 s = s.searchX(loc, sc, id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 if (s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 t = s.getType();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 if (!t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 error(loc, "%s is not a type", s.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 goto Lerr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 error(loc, "cannot resolve .property for %s", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 goto Lerr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 Lerr:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 return terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 1
diff changeset
95 override void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 1
diff changeset
99 }