Mercurial > projects > ldc
diff dmd/mtype.c @ 130:a7dfa0ed966c trunk
[svn r134] Merged the DMD 1.024 frontend.
Added std.base64.
author | lindquist |
---|---|
date | Fri, 28 Dec 2007 23:52:40 +0100 |
parents | facc562f5674 |
children | 5825d48b27d1 |
line wrap: on
line diff
--- a/dmd/mtype.c Fri Dec 28 22:55:24 2007 +0100 +++ b/dmd/mtype.c Fri Dec 28 23:52:40 2007 +0100 @@ -2742,38 +2742,50 @@ } //printf("TypeFunction::semantic() this = %p\n", this); - linkage = sc->linkage; - if (!next) + TypeFunction *tf = (TypeFunction *)mem.malloc(sizeof(TypeFunction)); + memcpy(tf, this, sizeof(TypeFunction)); + if (parameters) + { tf->parameters = (Arguments *)parameters->copy(); + for (size_t i = 0; i < parameters->dim; i++) + { Argument *arg = (Argument *)parameters->data[i]; + Argument *cpy = (Argument *)mem.malloc(sizeof(Argument)); + memcpy(cpy, arg, sizeof(Argument)); + tf->parameters->data[i] = (void *)cpy; + } + } + + tf->linkage = sc->linkage; + if (!tf->next) { assert(global.errors); - next = tvoid; - } - next = next->semantic(loc,sc); - if (next->toBasetype()->ty == Tsarray) - { error(loc, "functions cannot return static array %s", next->toChars()); - next = Type::terror; - } - if (next->toBasetype()->ty == Tfunction) + tf->next = tvoid; + } + tf->next = tf->next->semantic(loc,sc); + if (tf->next->toBasetype()->ty == Tsarray) + { error(loc, "functions cannot return static array %s", tf->next->toChars()); + tf->next = Type::terror; + } + if (tf->next->toBasetype()->ty == Tfunction) { error(loc, "functions cannot return a function"); - next = Type::terror; - } - if (next->toBasetype()->ty == Ttuple) + tf->next = Type::terror; + } + if (tf->next->toBasetype()->ty == Ttuple) { error(loc, "functions cannot return a tuple"); - next = Type::terror; - } - if (next->isauto() && !(sc->flags & SCOPEctor)) - error(loc, "functions cannot return auto %s", next->toChars()); - - if (parameters) - { size_t dim = Argument::dim(parameters); + tf->next = Type::terror; + } + if (tf->next->isauto() && !(sc->flags & SCOPEctor)) + error(loc, "functions cannot return auto %s", tf->next->toChars()); + + if (tf->parameters) + { size_t dim = Argument::dim(tf->parameters); for (size_t i = 0; i < dim; i++) - { Argument *arg = Argument::getNth(parameters, i); + { Argument *arg = Argument::getNth(tf->parameters, i); Type *t; - inuse++; + tf->inuse++; arg->type = arg->type->semantic(loc,sc); - if (inuse == 1) inuse--; + if (tf->inuse == 1) tf->inuse--; t = arg->type->toBasetype(); if (arg->storageClass & (STCout | STCref | STClazy)) @@ -2795,27 +2807,27 @@ * change. */ if (t->ty == Ttuple) - { dim = Argument::dim(parameters); + { dim = Argument::dim(tf->parameters); i--; } } } - deco = merge()->deco; - - if (inuse) + tf->deco = tf->merge()->deco; + + if (tf->inuse) { error(loc, "recursive type"); - inuse = 0; + tf->inuse = 0; return terror; } - if (varargs == 1 && linkage != LINKd && Argument::dim(parameters) == 0) + if (tf->varargs == 1 && tf->linkage != LINKd && Argument::dim(tf->parameters) == 0) error(loc, "variadic functions with non-D linkage must have at least one parameter"); /* Don't return merge(), because arg identifiers and default args * can be different * even though the types match */ - return this; + return tf; } /********************************