comparison dmd/TypeInfoStructDeclaration.d @ 130:60bb0fe4563e

dmdfe 2.037 first main iteration
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Thu, 09 Sep 2010 22:51:44 +0100
parents 1765f3ef917d
children 206db751bd4c
comparison
equal deleted inserted replaced
129:010eb8f0e18d 130:60bb0fe4563e
3 import dmd.common; 3 import dmd.common;
4 import dmd.Type; 4 import dmd.Type;
5 import dmd.TY; 5 import dmd.TY;
6 import dmd.MOD; 6 import dmd.MOD;
7 import dmd.Loc; 7 import dmd.Loc;
8 import dmd.Argument; 8 import dmd.Parameter;
9 import dmd.STC; 9 import dmd.STC;
10 import dmd.TypeStruct; 10 import dmd.TypeStruct;
11 import dmd.TypeFunction; 11 import dmd.TypeFunction;
12 import dmd.StructDeclaration; 12 import dmd.StructDeclaration;
13 import dmd.FuncDeclaration; 13 import dmd.FuncDeclaration;
107 } else { 107 } else {
108 // arg type is const T* 108 // arg type is const T*
109 auto arg = new Argument(STC.STCin, tc.pointerTo(), null, null); 109 auto arg = new Argument(STC.STCin, tc.pointerTo(), null, null);
110 } 110 }
111 111
112 arguments.push(arg);
113 tfeqptr = new TypeFunction(arguments, Type.tbool, 0, LINK.LINKd);
114 tfeqptr.mod = MODconst;
115 tfeqptr = cast(TypeFunction)tfeqptr.semantic(0, &sc);
116 }
117
118 TypeFunction *tfcmpptr;
119 {
120 Scope sc;
121 auto arguments = new Arguments;
122 version(STRUCTTHISREF) {
123 // arg type is ref const T
124 auto arg = new Argument(STC.STCref, tc.constOf(), null, null);
125 } else {
126 // arg type is const T*
127 auto arg = new Argument(STC.STCin, tc.pointerTo(), null, null);
128 }
129
112 arguments.push(arg); 130 arguments.push(arg);
113 tfeqptr = new TypeFunction(arguments, Type.tbool, 0, LINK.LINKd); 131 tfeqptr = new TypeFunction(arguments, Type.tbool, 0, LINK.LINKd);
114 tfeqptr.mod = MOD.MODconst; 132 tfeqptr.mod = MOD.MODconst;
115 tfeqptr = cast(TypeFunction)tfeqptr.semantic(Loc(0), sc); 133 tfeqptr = cast(TypeFunction)tfeqptr.semantic(Loc(0), sc);
116 } 134 }
117 135
118 TypeFunction tfcmpptr; 136 TypeFunction tfcmpptr;
119 { 137 {
120 scope Scope sc = new Scope(); 138 scope Scope sc = new Scope();
121 auto arguments = new Arguments; 139 auto arguments = new Parameters;
122 version (STRUCTTHISREF) { 140 version (STRUCTTHISREF) {
123 // arg type is ref const T 141 // arg type is ref const T
124 auto arg = new Argument(STC.STCref, tc.constOf(), null, null); 142 auto arg = new Parameter(STC.STCref, tc.constOf(), null, null);
125 } else { 143 } else {
126 // arg type is const T* 144 // arg type is const T*
127 auto arg = new Argument(STC.STCin, tc.pointerTo(), null, null); 145 auto arg = new Parameter(STC.STCin, tc.pointerTo(), null, null);
128 } 146 }
129 147
130 arguments.push(arg); 148 arguments.push(arg);
131 tfcmpptr = new TypeFunction(arguments, Type.tint32, 0, LINK.LINKd); 149 tfcmpptr = new TypeFunction(arguments, Type.tint32, 0, LINK.LINKd);
132 tfcmpptr.mod = MOD.MODconst; 150 tfcmpptr.mod = MOD.MODconst;
145 dtdword(pdt, 0); 163 dtdword(pdt, 0);
146 } 164 }
147 else 165 else
148 dtdword(pdt, 0); 166 dtdword(pdt, 0);
149 167
150 s = search_function(sd, Id.eq); 168 if (sd.eq)
151 fdx = s ? s.isFuncDeclaration() : null; 169 dtxoff(pdt, sd.eq.toSymbol(), 0, TYnptr);
152 if (fdx)
153 {
154 //printf("test1 %s, %s, %s\n", fdx.toChars(), fdx.type.toChars(), tfeqptr.toChars());
155 fd = fdx.overloadExactMatch(tfeqptr);
156 if (fd)
157 dtxoff(pdt, fd.toSymbol(), 0, TYM.TYnptr);
158 else
159 {
160 fd = fdx.overloadExactMatch(tfcmpptr);
161 if (fd)
162 fdx.error("must return bool, not int");
163 //fdx.error("must be declared as extern (D) int %s(%s*)", fdx.toChars(), sd.toChars());
164 dtdword(pdt, 0);
165 }
166 }
167 else 170 else
168 dtdword(pdt, 0); 171 dtdword(pdt, 0);
169 172
170 s = search_function(sd, Id.cmp); 173 s = search_function(sd, Id.cmp);
171 fdx = s ? s.isFuncDeclaration() : null; 174 fdx = s ? s.isFuncDeclaration() : null;