Mercurial > projects > ddmd
diff 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 |
line wrap: on
line diff
--- a/dmd/Parser.d Sat Oct 24 17:25:59 2009 +0400 +++ b/dmd/Parser.d Sun Oct 25 03:20:59 2009 +0300 @@ -201,9 +201,9 @@ import dmd.Global; import core.stdc.string : memcpy; -import core.stdc.stdlib : malloc; import std.contracts; +import dmd.Memory; class Parser : Lexer { @@ -1182,9 +1182,85 @@ return tiargs; } + /***************************** + * Parse single template argument, to support the syntax: + * foo!arg + * Input: + * current token is the arg + */ Objects parseTemplateArgument() { - assert(false); + //printf("parseTemplateArgument()\n"); + Objects tiargs = new Objects(); + Type ta; + switch (token.value) + { + case TOKidentifier: + ta = new TypeIdentifier(loc, token.ident); + goto LabelX; + + case TOKvoid: ta = Type.tvoid; goto LabelX; + case TOKint8: ta = Type.tint8; goto LabelX; + case TOKuns8: ta = Type.tuns8; goto LabelX; + case TOKint16: ta = Type.tint16; goto LabelX; + case TOKuns16: ta = Type.tuns16; goto LabelX; + case TOKint32: ta = Type.tint32; goto LabelX; + case TOKuns32: ta = Type.tuns32; goto LabelX; + case TOKint64: ta = Type.tint64; goto LabelX; + case TOKuns64: ta = Type.tuns64; goto LabelX; + case TOKfloat32: ta = Type.tfloat32; goto LabelX; + case TOKfloat64: ta = Type.tfloat64; goto LabelX; + case TOKfloat80: ta = Type.tfloat80; goto LabelX; + case TOKimaginary32: ta = Type.timaginary32; goto LabelX; + case TOKimaginary64: ta = Type.timaginary64; goto LabelX; + case TOKimaginary80: ta = Type.timaginary80; goto LabelX; + case TOKcomplex32: ta = Type.tcomplex32; goto LabelX; + case TOKcomplex64: ta = Type.tcomplex64; goto LabelX; + case TOKcomplex80: ta = Type.tcomplex80; goto LabelX; + case TOKbit: ta = Type.tbit; goto LabelX; + case TOKbool: ta = Type.tbool; goto LabelX; + case TOKchar: ta = Type.tchar; goto LabelX; + case TOKwchar: ta = Type.twchar; goto LabelX; + case TOKdchar: ta = Type.tdchar; goto LabelX; + LabelX: + tiargs.push(cast(void*)ta); + nextToken(); + break; + + case TOKint32v: + case TOKuns32v: + case TOKint64v: + case TOKuns64v: + case TOKfloat32v: + case TOKfloat64v: + case TOKfloat80v: + case TOKimaginary32v: + case TOKimaginary64v: + case TOKimaginary80v: + case TOKnull: + case TOKtrue: + case TOKfalse: + case TOKcharv: + case TOKwcharv: + case TOKdcharv: + case TOKstring: + case TOKfile: + case TOKline: + { + // Template argument is an expression + Expression ea = parsePrimaryExp(); + tiargs.push(cast(void*)ea); + break; + } + + default: + error("template argument expected following !"); + break; + } + + if (token.value == TOKnot) + error("multiple ! arguments are not allowed"); + return tiargs; } /********************************** @@ -4871,7 +4947,7 @@ len1 = len; len2 = token.len; len = len1 + len2; - s2 = cast(char*)malloc((len + 1) * ubyte.sizeof); + s2 = cast(char*)GC.malloc((len + 1) * ubyte.sizeof); memcpy(s2, s, len1 * ubyte.sizeof); memcpy(s2 + len1, token.ustring, (len2 + 1) * ubyte.sizeof); s = s2;