comparison dmd/TypeInstance.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 5c9b78899f5d
comparison
equal deleted inserted replaced
-1:000000000000 0:10317f0c89a5
1 module dmd.TypeInstance;
2
3 import dmd.TypeQualified;
4 import dmd.TemplateInstance;
5 import dmd.MOD;
6 import dmd.MATCH;
7 import dmd.Loc;
8 import dmd.Global;
9 import dmd.Type;
10 import dmd.OutBuffer;
11 import dmd.HdrGenState;
12 import dmd.Dsymbol;
13 import dmd.Expression;
14 import dmd.Scope;
15 import dmd.ArrayTypes;
16 import dmd.TY;
17
18 /* Similar to TypeIdentifier, but with a TemplateInstance as the root
19 */
20 class TypeInstance : TypeQualified
21 {
22 TemplateInstance tempinst;
23
24 this(Loc loc, TemplateInstance tempinst)
25 {
26 super(Tinstance, loc);
27 this.tempinst = tempinst;
28 }
29
30 version (DumbClone) {
31 } else {
32 Type clone()
33 {
34 assert(false);
35 }
36 }
37
38 Type syntaxCopy()
39 {
40 assert(false);
41 }
42
43 //char *toChars();
44
45 //void toDecoBuffer(OutBuffer *buf, int flag);
46
47 void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
48 {
49 assert(false);
50 }
51
52 void resolve(Loc loc, Scope sc, Expression* pe, Type* pt, Dsymbol* ps)
53 {
54 // Note close similarity to TypeIdentifier::resolve()
55 Dsymbol s;
56
57 *pe = null;
58 *pt = null;
59 *ps = null;
60
61 static if (false) {
62 if (!idents.dim)
63 {
64 error(loc, "template instance '%s' has no identifier", toChars());
65 return;
66 }
67 }
68 //id = (Identifier *)idents.data[0];
69 //printf("TypeInstance::resolve(sc = %p, idents = '%s')\n", sc, id->toChars());
70 s = tempinst;
71 if (s)
72 s.semantic(sc);
73 resolveHelper(loc, sc, s, null, pe, pt, ps);
74 if (*pt)
75 *pt = (*pt).addMod(mod);
76 //printf("pt = '%s'\n", (*pt)->toChars());
77 }
78
79 Type semantic(Loc loc, Scope sc)
80 {
81 assert(false);
82 }
83
84 Dsymbol toDsymbol(Scope sc)
85 {
86 Type t;
87 Expression e;
88 Dsymbol s;
89
90 //printf("TypeInstance::semantic(%s)\n", toChars());
91
92 if (sc.parameterSpecialization)
93 {
94 uint errors = global.errors;
95 global.gag++;
96
97 resolve(loc, sc, &e, &t, &s);
98
99 global.gag--;
100 if (errors != global.errors)
101 {
102 if (global.gag == 0)
103 global.errors = errors;
104
105 return null;
106 }
107 }
108 else
109 resolve(loc, sc, &e, &t, &s);
110
111 return s;
112 }
113
114 MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes)
115 {
116 assert(false);
117 }
118 }