comparison dmd/Parser.d @ 2:7427ded8caf7

Removed unreferenced modules First step at fixing GC issues - now calling GC.malloc instead of malloc (ditto calloc and realloc), get rid of free
author korDen
date Sun, 25 Oct 2009 03:20:59 +0300
parents 10317f0c89a5
children d706d958e4e8
comparison
equal deleted inserted replaced
1:5a2059196104 2:7427ded8caf7
199 import dmd.VersionSymbol; 199 import dmd.VersionSymbol;
200 import dmd.AliasThis; 200 import dmd.AliasThis;
201 import dmd.Global; 201 import dmd.Global;
202 202
203 import core.stdc.string : memcpy; 203 import core.stdc.string : memcpy;
204 import core.stdc.stdlib : malloc;
205 204
206 import std.contracts; 205 import std.contracts;
206 import dmd.Memory;
207 207
208 class Parser : Lexer 208 class Parser : Lexer
209 { 209 {
210 ModuleDeclaration md; 210 ModuleDeclaration md;
211 LINK linkage; 211 LINK linkage;
1180 } 1180 }
1181 check(endtok, "template argument list"); 1181 check(endtok, "template argument list");
1182 return tiargs; 1182 return tiargs;
1183 } 1183 }
1184 1184
1185 /*****************************
1186 * Parse single template argument, to support the syntax:
1187 * foo!arg
1188 * Input:
1189 * current token is the arg
1190 */
1185 Objects parseTemplateArgument() 1191 Objects parseTemplateArgument()
1186 { 1192 {
1187 assert(false); 1193 //printf("parseTemplateArgument()\n");
1194 Objects tiargs = new Objects();
1195 Type ta;
1196 switch (token.value)
1197 {
1198 case TOKidentifier:
1199 ta = new TypeIdentifier(loc, token.ident);
1200 goto LabelX;
1201
1202 case TOKvoid: ta = Type.tvoid; goto LabelX;
1203 case TOKint8: ta = Type.tint8; goto LabelX;
1204 case TOKuns8: ta = Type.tuns8; goto LabelX;
1205 case TOKint16: ta = Type.tint16; goto LabelX;
1206 case TOKuns16: ta = Type.tuns16; goto LabelX;
1207 case TOKint32: ta = Type.tint32; goto LabelX;
1208 case TOKuns32: ta = Type.tuns32; goto LabelX;
1209 case TOKint64: ta = Type.tint64; goto LabelX;
1210 case TOKuns64: ta = Type.tuns64; goto LabelX;
1211 case TOKfloat32: ta = Type.tfloat32; goto LabelX;
1212 case TOKfloat64: ta = Type.tfloat64; goto LabelX;
1213 case TOKfloat80: ta = Type.tfloat80; goto LabelX;
1214 case TOKimaginary32: ta = Type.timaginary32; goto LabelX;
1215 case TOKimaginary64: ta = Type.timaginary64; goto LabelX;
1216 case TOKimaginary80: ta = Type.timaginary80; goto LabelX;
1217 case TOKcomplex32: ta = Type.tcomplex32; goto LabelX;
1218 case TOKcomplex64: ta = Type.tcomplex64; goto LabelX;
1219 case TOKcomplex80: ta = Type.tcomplex80; goto LabelX;
1220 case TOKbit: ta = Type.tbit; goto LabelX;
1221 case TOKbool: ta = Type.tbool; goto LabelX;
1222 case TOKchar: ta = Type.tchar; goto LabelX;
1223 case TOKwchar: ta = Type.twchar; goto LabelX;
1224 case TOKdchar: ta = Type.tdchar; goto LabelX;
1225 LabelX:
1226 tiargs.push(cast(void*)ta);
1227 nextToken();
1228 break;
1229
1230 case TOKint32v:
1231 case TOKuns32v:
1232 case TOKint64v:
1233 case TOKuns64v:
1234 case TOKfloat32v:
1235 case TOKfloat64v:
1236 case TOKfloat80v:
1237 case TOKimaginary32v:
1238 case TOKimaginary64v:
1239 case TOKimaginary80v:
1240 case TOKnull:
1241 case TOKtrue:
1242 case TOKfalse:
1243 case TOKcharv:
1244 case TOKwcharv:
1245 case TOKdcharv:
1246 case TOKstring:
1247 case TOKfile:
1248 case TOKline:
1249 {
1250 // Template argument is an expression
1251 Expression ea = parsePrimaryExp();
1252 tiargs.push(cast(void*)ea);
1253 break;
1254 }
1255
1256 default:
1257 error("template argument expected following !");
1258 break;
1259 }
1260
1261 if (token.value == TOKnot)
1262 error("multiple ! arguments are not allowed");
1263 return tiargs;
1188 } 1264 }
1189 1265
1190 /********************************** 1266 /**********************************
1191 * Parse a static assertion. 1267 * Parse a static assertion.
1192 */ 1268 */
4869 } 4945 }
4870 4946
4871 len1 = len; 4947 len1 = len;
4872 len2 = token.len; 4948 len2 = token.len;
4873 len = len1 + len2; 4949 len = len1 + len2;
4874 s2 = cast(char*)malloc((len + 1) * ubyte.sizeof); 4950 s2 = cast(char*)GC.malloc((len + 1) * ubyte.sizeof);
4875 memcpy(s2, s, len1 * ubyte.sizeof); 4951 memcpy(s2, s, len1 * ubyte.sizeof);
4876 memcpy(s2 + len1, token.ustring, (len2 + 1) * ubyte.sizeof); 4952 memcpy(s2 + len1, token.ustring, (len2 + 1) * ubyte.sizeof);
4877 s = s2; 4953 s = s2;
4878 } 4954 }
4879 else 4955 else