Skip to content

Commit

Permalink
[style] fix indent
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Apr 6, 2014
1 parent 6d10394 commit 5c86c0f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 30 deletions.
6 changes: 4 additions & 2 deletions src/expression.c
Expand Up @@ -5585,12 +5585,14 @@ Expression *FuncExp::semantic(Scope *sc)

// Set target of return type inference
if (fd->treq && !fd->type->nextOf())
{ TypeFunction *tfv = NULL;
{
TypeFunction *tfv = NULL;
if (fd->treq->ty == Tdelegate ||
(fd->treq->ty == Tpointer && fd->treq->nextOf()->ty == Tfunction))
tfv = (TypeFunction *)fd->treq->nextOf();
if (tfv)
{ TypeFunction *tfl = (TypeFunction *)fd->type;
{
TypeFunction *tfl = (TypeFunction *)fd->type;
tfl->next = tfv->nextOf();
}
}
Expand Down
83 changes: 55 additions & 28 deletions src/func.c
Expand Up @@ -1318,7 +1318,8 @@ void FuncDeclaration::semantic3(Scope *sc)
{
#ifndef IN_GCC
if (global.params.is64bit && !global.params.isWindows)
{ // Declare save area for varargs registers
{
// Declare save area for varargs registers
Type *t = new TypeIdentifier(loc, Id::va_argsave_t);
t = t->semantic(loc, sc);
if (t == Type::terror)
Expand All @@ -1338,7 +1339,8 @@ void FuncDeclaration::semantic3(Scope *sc)
#endif

if (f->linkage == LINKd)
{ // Declare _arguments[]
{
// Declare _arguments[]
v_arguments = new VarDeclaration(Loc(), Type::typeinfotypelist->type, Id::_arguments_typeinfo, NULL);
v_arguments->storage_class |= STCtemp | STCparameter;
v_arguments->semantic(sc2);
Expand All @@ -1354,7 +1356,8 @@ void FuncDeclaration::semantic3(Scope *sc)
_arguments->parent = this;
}
if (f->linkage == LINKd || (f->parameters && Parameter::dim(f->parameters)))
{ // Declare _argptr
{
// Declare _argptr
Type *t = Type::tvalist;
argptr = new VarDeclaration(Loc(), t, Id::_argptr, NULL);
argptr->storage_class |= STCtemp;
Expand All @@ -1369,14 +1372,17 @@ void FuncDeclaration::semantic3(Scope *sc)
if (f->parameters)
{
for (size_t i = 0; i < f->parameters->dim; i++)
{ Parameter *arg = (*f->parameters)[i];
{
Parameter *arg = (*f->parameters)[i];

//printf("[%d] arg->type->ty = %d %s\n", i, arg->type->ty, arg->type->toChars());
if (arg->type->ty == Ttuple)
{ TypeTuple *t = (TypeTuple *)arg->type;
{
TypeTuple *t = (TypeTuple *)arg->type;
size_t dim = Parameter::dim(t->arguments);
for (size_t j = 0; j < dim; j++)
{ Parameter *narg = Parameter::getNth(t->arguments, j);
{
Parameter *narg = Parameter::getNth(t->arguments, j);
narg->storageClass = arg->storageClass;
}
}
Expand All @@ -1389,7 +1395,8 @@ void FuncDeclaration::semantic3(Scope *sc)
*/
size_t nparams = Parameter::dim(f->parameters);
if (nparams)
{ /* parameters[] has all the tuples removed, as the back end
{
/* parameters[] has all the tuples removed, as the back end
* doesn't know about tuples
*/
parameters = new VarDeclarations();
Expand Down Expand Up @@ -1430,17 +1437,20 @@ void FuncDeclaration::semantic3(Scope *sc)
if (f->parameters)
{
for (size_t i = 0; i < f->parameters->dim; i++)
{ Parameter *arg = (*f->parameters)[i];
{
Parameter *arg = (*f->parameters)[i];

if (!arg->ident)
continue; // never used, so ignore
if (arg->type->ty == Ttuple)
{ TypeTuple *t = (TypeTuple *)arg->type;
{
TypeTuple *t = (TypeTuple *)arg->type;
size_t dim = Parameter::dim(t->arguments);
Objects *exps = new Objects();
exps->setDim(dim);
for (size_t j = 0; j < dim; j++)
{ Parameter *narg = Parameter::getNth(t->arguments, j);
{
Parameter *narg = Parameter::getNth(t->arguments, j);
assert(narg->ident);
VarDeclaration *v = sc2->search(Loc(), narg->ident, NULL)->isVarDeclaration();
assert(v);
Expand Down Expand Up @@ -1485,7 +1495,8 @@ void FuncDeclaration::semantic3(Scope *sc)
}
}
else
{ // Call invariant virtually
{
// Call invariant virtually
Expression *v = new ThisExp(Loc());
v->type = vthis->type;
if (ad->isStructDeclaration())
Expand Down Expand Up @@ -1525,7 +1536,8 @@ void FuncDeclaration::semantic3(Scope *sc)
}
}
else
{ // Call invariant virtually
{
// Call invariant virtually
Expression *v = new ThisExp(Loc());
v->type = vthis->type;
if (ad->isStructDeclaration())
Expand All @@ -1539,7 +1551,8 @@ void FuncDeclaration::semantic3(Scope *sc)
if (fensure || addPostInvariant())
{
if ((fensure && global.params.useOut) || fpostinv)
{ returnLabel = new LabelDsymbol(Id::returnLabel);
{
returnLabel = new LabelDsymbol(Id::returnLabel);
}

// scope of out contract (need for vresult->semantic)
Expand Down Expand Up @@ -1773,7 +1786,8 @@ void FuncDeclaration::semantic3(Scope *sc)
* [out] postconditions.
*/
if (freq)
{ /* frequire is composed of the [in] contracts
{
/* frequire is composed of the [in] contracts
*/
ScopeDsymbol *sym = new ScopeDsymbol();
sym->parent = sc2->scopesym;
Expand All @@ -1793,7 +1807,8 @@ void FuncDeclaration::semantic3(Scope *sc)
}

if (fens)
{ /* fensure is composed of the [out] contracts
{
/* fensure is composed of the [out] contracts
*/
if (type->nextOf()->ty == Tvoid && outId)
{
Expand Down Expand Up @@ -1827,7 +1842,8 @@ void FuncDeclaration::semantic3(Scope *sc)

// Merge in initialization of 'out' parameters
if (parameters)
{ for (size_t i = 0; i < parameters->dim; i++)
{
for (size_t i = 0; i < parameters->dim; i++)
{
VarDeclaration *v = (*parameters)[i];
if (v->storage_class & STCout)
Expand All @@ -1843,15 +1859,17 @@ void FuncDeclaration::semantic3(Scope *sc)
}

if (argptr)
{ // Initialize _argptr
{
// Initialize _argptr
#ifdef IN_GCC
// Handled in FuncDeclaration::toObjFile
v_argptr = argptr;
v_argptr->init = new VoidInitializer(loc);
#else
Type *t = argptr->type;
if (global.params.is64bit && !global.params.isWindows)
{ // Initialize _argptr to point to v_argsave
{
// Initialize _argptr to point to v_argsave
Expression *e1 = new VarExp(Loc(), argptr);
Expression *e = new SymOffExp(Loc(), v_argsave, 6*8 + 8*16);
e->type = argptr->type;
Expand All @@ -1860,7 +1878,8 @@ void FuncDeclaration::semantic3(Scope *sc)
a->push(new ExpStatement(Loc(), e));
}
else
{ // Initialize _argptr to point past non-variadic arg
{
// Initialize _argptr to point past non-variadic arg
VarDeclaration *p;
unsigned offset = 0;
Expression *e;
Expand Down Expand Up @@ -1889,8 +1908,9 @@ void FuncDeclaration::semantic3(Scope *sc)
else
p = v_arguments; // last parameter is _arguments[]
if (global.params.is64bit && global.params.isWindows)
{ offset += Target::ptrsize;
if (p->storage_class & STClazy || p->type->size() > Target::ptrsize)
{
offset += Target::ptrsize;
if (p->storage_class & STClazy || p->type->size() > Target::ptrsize)
{
/* Necessary to offset the extra level of indirection the Win64
* ABI demands
Expand Down Expand Up @@ -1972,15 +1992,17 @@ void FuncDeclaration::semantic3(Scope *sc)
// Create: return vresult;
Expression *e = new VarExp(Loc(), vresult);
if (tintro)
{ e = e->implicitCastTo(sc, tintro->nextOf());
{
e = e->implicitCastTo(sc, tintro->nextOf());
e = e->semantic(sc);
}
ReturnStatement *s = new ReturnStatement(Loc(), e);
a->push(s);
}
}
if (isMain() && type->nextOf()->ty == Tvoid)
{ // Add a return 0; statement
{
// Add a return 0; statement
Statement *s = new ReturnStatement(Loc(), new IntegerExp(0));
a->push(s);
}
Expand All @@ -1989,7 +2011,8 @@ void FuncDeclaration::semantic3(Scope *sc)
/* Append destructor calls for parameters as finally blocks.
*/
if (parameters)
{ for (size_t i = 0; i < parameters->dim; i++)
{
for (size_t i = 0; i < parameters->dim; i++)
{
VarDeclaration *v = (*parameters)[i];

Expand All @@ -2001,7 +2024,8 @@ void FuncDeclaration::semantic3(Scope *sc)

Expression *e = v->edtor;
if (e)
{ Statement *s = new ExpStatement(Loc(), e);
{
Statement *s = new ExpStatement(Loc(), e);
s = s->semantic(sc2);
int nothrowErrors = global.errors;
bool isnothrow = f->isnothrow & !(flags & FUNCFLAGnothrowInprocess);
Expand All @@ -2021,7 +2045,8 @@ void FuncDeclaration::semantic3(Scope *sc)
flags &= ~FUNCFLAGnothrowInprocess;

if (isSynchronized())
{ /* Wrap the entire function body in a synchronized statement
{
/* Wrap the entire function body in a synchronized statement
*/
ClassDeclaration *cd = isThis() ? isThis()->isClassDeclaration() : parent->isClassDeclaration();

Expand All @@ -2039,11 +2064,13 @@ void FuncDeclaration::semantic3(Scope *sc)
{
Expression *vsync;
if (isStatic())
{ // The monitor is in the ClassInfo
{
// The monitor is in the ClassInfo
vsync = new DotIdExp(loc, new DsymbolExp(loc, cd), Id::classinfo);
}
else
{ // 'this' is the monitor
{
// 'this' is the monitor
vsync = new VarExp(loc, vthis);
}
fbody = new PeelStatement(fbody); // don't redo semantic()
Expand Down

0 comments on commit 5c86c0f

Please sign in to comment.