[svn r175] merged dmd 1.029

This commit is contained in:
Christian Kamm
2008-05-01 15:15:28 +02:00
parent 4cd137f9d4
commit 7ae4bc6477
27 changed files with 38673 additions and 38027 deletions

View File

@@ -1,6 +1,6 @@
// Compiler implementation of the D programming language
// Copyright (c) 1999-2007 by Digital Mars
// Copyright (c) 1999-2008 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
@@ -109,7 +109,7 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument
istatex.caller = istate;
istatex.fd = this;
Expressions vsave;
Expressions vsave; // place to save previous parameter values
size_t dim = 0;
if (arguments)
{
@@ -117,9 +117,40 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument
assert(!dim || parameters->dim == dim);
vsave.setDim(dim);
/* Evaluate all the arguments to the function,
* store the results in eargs[]
*/
Expressions eargs;
eargs.setDim(dim);
for (size_t i = 0; i < dim; i++)
{ Expression *earg = (Expression *)arguments->data[i];
Argument *arg = Argument::getNth(tf->parameters, i);
if (arg->storageClass & (STCout | STCref))
{
}
else
{ /* Value parameters
*/
Type *ta = arg->type->toBasetype();
if (ta->ty == Tsarray && earg->op == TOKaddress)
{
/* Static arrays are passed by a simple pointer.
* Skip past this to get at the actual arg.
*/
earg = ((AddrExp *)earg)->e1;
}
earg = earg->interpret(istate ? istate : &istatex);
if (earg == EXP_CANT_INTERPRET)
return NULL;
}
eargs.data[i] = earg;
}
for (size_t i = 0; i < dim; i++)
{ Expression *earg = (Expression *)eargs.data[i];
Argument *arg = Argument::getNth(tf->parameters, i);
VarDeclaration *v = (VarDeclaration *)parameters->data[i];
vsave.data[i] = v->value;
#if LOG
@@ -161,17 +192,6 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument
else
{ /* Value parameters
*/
Type *ta = arg->type->toBasetype();
if (ta->ty == Tsarray && earg->op == TOKaddress)
{
/* Static arrays are passed by a simple pointer.
* Skip past this to get at the actual arg.
*/
earg = ((AddrExp *)earg)->e1;
}
earg = earg->interpret(istate ? istate : &istatex);
if (earg == EXP_CANT_INTERPRET)
return NULL;
v->value = earg;
}
#if LOG
@@ -584,6 +604,8 @@ Expression *ForStatement::interpret(InterState *istate)
while (1)
{
if (!condition)
goto Lhead;
e = condition->interpret(istate);
if (e == EXP_CANT_INTERPRET)
break;
@@ -592,7 +614,9 @@ Expression *ForStatement::interpret(InterState *istate)
break;
}
if (e->isBool(TRUE))
{ e = body ? body->interpret(istate) : NULL;
{
Lhead:
e = body ? body->interpret(istate) : NULL;
if (e == EXP_CANT_INTERPRET)
break;
if (e == EXP_BREAK_INTERPRET)
@@ -602,9 +626,12 @@ Expression *ForStatement::interpret(InterState *istate)
if (e && e != EXP_CONTINUE_INTERPRET)
break;
Lcontinue:
e = increment->interpret(istate);
if (e == EXP_CANT_INTERPRET)
break;
if (increment)
{
e = increment->interpret(istate);
if (e == EXP_CANT_INTERPRET)
break;
}
}
else if (e->isBool(FALSE))
{ e = NULL;