[Issue 2101] CTFE: Please may I use mutable arrays at compile time?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 10 14:11:17 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2101
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #3 from Don <clugdbug at yahoo.com.au> 2010-01-10 14:11:14 PST ---
Janice's first case has compiled for quite a long time now. The third case,
involving 'new', is very straightforward. The final case (changing length) is
doubtful whether it is a good idea. I think with implementing 'new', we can
close this bug.
PATCH to allow dynamic array creation with new. Insert this code into
interpret.c, around line 2690. Also add the declaration for it in NewExp in
expression.h. Also need to change the spec to remove the restriction on using
'new'.
------------
Expression *NewExp::interpret(InterState *istate)
{
#if LOG
printf("NewExp::interpret() %s\n", toChars());
#endif
if (newtype->ty == Tarray && arguments && arguments->dim == 1)
{
Expression *lenExpr = ((Expression
*)(arguments->data[0]))->interpret(istate);
if (lenExpr == EXP_CANT_INTERPRET)
return EXP_CANT_INTERPRET;
return createBlockDuplicatedArrayLiteral(newtype,
newtype->defaultInitLiteral(), lenExpr->toInteger());
}
error("Cannot interpret %s at compile time", toChars());
return EXP_CANT_INTERPRET;
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list