Mercurial > projects > ldc
diff dmd/func.c @ 510:6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Thu, 14 Aug 2008 06:55:41 +0200 |
parents | 45a67b6f1310 |
children | 49466efd4fba |
line wrap: on
line diff
--- a/dmd/func.c Thu Aug 14 03:09:26 2008 +0200 +++ b/dmd/func.c Thu Aug 14 06:55:41 2008 +0200 @@ -68,6 +68,9 @@ fes = NULL; introducing = 0; tintro = NULL; + /* The type given for "infer the return type" is a TypeFunction with + * NULL for the return type. + */ inferRetType = (type && type->nextOf() == NULL); scope = NULL; hasReturnExp = 0; @@ -112,7 +115,7 @@ if (isFuncLiteralDeclaration()) printf("\tFuncLiteralDeclaration()\n"); printf("sc->parent = %s\n", sc->parent->toChars()); - printf("type: %s\n", type->toChars()); + printf("type: %p, %s\n", type, type->toChars()); #endif if (type->nextOf()) @@ -281,8 +284,11 @@ vi = findVtblIndex(&cd->vtbl, cd->baseClass ? cd->baseClass->vtbl.dim : 0); switch (vi) { - case -1: // didn't find one - // This is an 'introducing' function. + case -1: + /* Didn't find one, so + * This is an 'introducing' function which gets a new + * slot in the vtbl[]. + */ // Verify this doesn't override previous final function if (cd->baseClass) @@ -632,9 +638,8 @@ // Check the 'throws' clause if (fthrows) - { int i; - - for (i = 0; i < fthrows->dim; i++) + { + for (int i = 0; i < fthrows->dim; i++) { Type *t = (Type *)fthrows->data[i]; @@ -696,9 +701,11 @@ } else if (isNested()) { - VarDeclaration *v; - - v = new ThisDeclaration(Type::tvoid->pointerTo()); + /* The 'this' for a nested function is the link to the + * enclosing function's stack frame. + * Note that nested functions and member functions are disjoint. + */ + VarDeclaration *v = new ThisDeclaration(Type::tvoid->pointerTo()); v->storage_class |= STCparameter | STCin; v->semantic(sc2); if (!sc2->insert(v)) @@ -781,11 +788,7 @@ /* Generate identifier for un-named parameter, * because we need it later on. */ - OutBuffer buf; - buf.printf("_param_%"PRIuSIZE, i); - char *name = (char *)buf.extractData(); - id = new Identifier(name, TOKidentifier); - arg->ident = id; + arg->ident = id = Identifier::generateId("_param_", i); } VarDeclaration *v = new VarDeclaration(loc, arg->type, id, NULL); //printf("declaring parameter %s of type %s\n", v->toChars(), v->type->toChars()); @@ -824,11 +827,11 @@ assert(narg->ident); VarDeclaration *v = sc2->search(0, narg->ident, NULL)->isVarDeclaration(); assert(v); - Expression *e = new VarExp(0, v); + Expression *e = new VarExp(v->loc, v); exps->data[j] = (void *)e; } assert(arg->ident); - TupleDeclaration *v = new TupleDeclaration(0, arg->ident, exps); + TupleDeclaration *v = new TupleDeclaration(loc, arg->ident, exps); //printf("declaring tuple %s\n", v->toChars()); v->isexp = 1; if (!sc2->insert(v)) @@ -1569,10 +1572,8 @@ if (f != m->lastf) // skip duplicates { - TypeFunction *tf; - m->anyf = f; - tf = (TypeFunction *)f->type; + TypeFunction *tf = (TypeFunction *)f->type; match = (MATCH) tf->callMatch(arguments); //printf("match = %d\n", match); if (match != MATCHnomatch) @@ -1910,8 +1911,16 @@ int FuncDeclaration::isWinMain() { + //printf("FuncDeclaration::isWinMain() %s\n", toChars()); +#if 0 + int x = ident == Id::WinMain && + linkage != LINKc && !isMember(); + printf("%s\n", x ? "yes" : "no"); + return x; +#else return ident == Id::WinMain && linkage != LINKc && !isMember(); +#endif } int FuncDeclaration::isDllMain() @@ -2090,7 +2099,7 @@ goto Lyes; // assume f escapes this function's scope // Look to see if any parents of f that are below this escape - for (Dsymbol *s = f->parent; s != this; s = s->parent) + for (Dsymbol *s = f->parent; s && s != this; s = s->parent) { f = s->isFuncDeclaration(); if (f && (f->isThis() || f->tookAddressOf)) @@ -2196,7 +2205,7 @@ { this->arguments = arguments; this->varargs = varargs; - //printf("CtorDeclaration() %s\n", toChars()); + //printf("CtorDeclaration(loc = %s) %s\n", loc.toChars(), toChars()); } Dsymbol *CtorDeclaration::syntaxCopy(Dsymbol *s)