mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-10-26 19:57:26 +01:00
Fix white space.
This commit is contained in:
+90
-90
@@ -1,6 +1,6 @@
|
||||
|
||||
// Compiler implementation of the D programming language
|
||||
// Copyright (c) 1999-2011 by Digital Mars
|
||||
// Copyright (c) 1999-2011 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
@@ -51,10 +51,10 @@ AggregateDeclaration::AggregateDeclaration(Loc loc, Identifier *id)
|
||||
|
||||
ctor = NULL;
|
||||
defaultCtor = NULL;
|
||||
aliasthis = NULL;
|
||||
noDefaultCtor = FALSE;
|
||||
aliasthis = NULL;
|
||||
noDefaultCtor = FALSE;
|
||||
#endif
|
||||
dtor = NULL;
|
||||
dtor = NULL;
|
||||
|
||||
#if IN_LLVM
|
||||
availableExternally = true; // assume this unless proven otherwise
|
||||
@@ -78,7 +78,7 @@ void AggregateDeclaration::semantic2(Scope *sc)
|
||||
sc = sc->push(this);
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
s->semantic2(sc);
|
||||
}
|
||||
sc->pop();
|
||||
@@ -86,7 +86,7 @@ void AggregateDeclaration::semantic2(Scope *sc)
|
||||
}
|
||||
|
||||
void AggregateDeclaration::semantic3(Scope *sc)
|
||||
{
|
||||
{
|
||||
// LDC
|
||||
if (!global.params.useAvailableExternally)
|
||||
availableExternally = false;
|
||||
@@ -95,9 +95,9 @@ void AggregateDeclaration::semantic3(Scope *sc)
|
||||
if (members)
|
||||
{
|
||||
sc = sc->push(this);
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
s->semantic3(sc);
|
||||
}
|
||||
sc->pop();
|
||||
@@ -105,13 +105,13 @@ void AggregateDeclaration::semantic3(Scope *sc)
|
||||
}
|
||||
|
||||
void AggregateDeclaration::inlineScan()
|
||||
{
|
||||
{
|
||||
//printf("AggregateDeclaration::inlineScan(%s)\n", toChars());
|
||||
if (members)
|
||||
{
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
//printf("inline scan aggregate symbol '%s'\n", s->toChars());
|
||||
s->inlineScan();
|
||||
}
|
||||
@@ -142,11 +142,11 @@ int AggregateDeclaration::isDeprecated()
|
||||
return isdeprecated;
|
||||
}
|
||||
|
||||
int AggregateDeclaration::isExport()
|
||||
{
|
||||
return protection == PROTexport;
|
||||
}
|
||||
|
||||
int AggregateDeclaration::isExport()
|
||||
{
|
||||
return protection == PROTexport;
|
||||
}
|
||||
|
||||
/****************************
|
||||
* Do byte or word alignment as necessary.
|
||||
* Align sizes of 0, as we may not know array sizes yet.
|
||||
@@ -161,7 +161,7 @@ void AggregateDeclaration::alignmember(
|
||||
if (salign > 1)
|
||||
{
|
||||
assert(size != 3);
|
||||
unsigned sa = size;
|
||||
unsigned sa = size;
|
||||
if (sa == 0 || salign < sa)
|
||||
sa = salign;
|
||||
*poffset = (*poffset + sa - 1) & ~(sa - 1);
|
||||
@@ -222,10 +222,10 @@ void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v)
|
||||
if (!isUnionDeclaration())
|
||||
sc->offset = ofs;
|
||||
#endif
|
||||
if (global.params.is64bit && sc->structalign == 8 && memalignsize == 16)
|
||||
/* Not sure how to handle this */
|
||||
;
|
||||
else if (sc->structalign < memalignsize)
|
||||
if (global.params.is64bit && sc->structalign == 8 && memalignsize == 16)
|
||||
/* Not sure how to handle this */
|
||||
;
|
||||
else if (sc->structalign < memalignsize)
|
||||
memalignsize = sc->structalign;
|
||||
if (alignsize < memalignsize)
|
||||
alignsize = memalignsize;
|
||||
@@ -236,57 +236,57 @@ void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v)
|
||||
fields.push(v);
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* If field[indx] is not part of a union, return indx.
|
||||
* Otherwise, return the lowest field index of the union.
|
||||
*/
|
||||
int AggregateDeclaration::firstFieldInUnion(int indx)
|
||||
{
|
||||
if (isUnionDeclaration())
|
||||
return 0;
|
||||
VarDeclaration * vd = fields.tdata()[indx];
|
||||
int firstNonZero = indx; // first index in the union with non-zero size
|
||||
for (; ;)
|
||||
{
|
||||
if (indx == 0)
|
||||
return firstNonZero;
|
||||
VarDeclaration * v = fields.tdata()[indx - 1];
|
||||
if (v->offset != vd->offset)
|
||||
return firstNonZero;
|
||||
--indx;
|
||||
/* If it is a zero-length field, it's ambiguous: we don't know if it is
|
||||
* in the union unless we find an earlier non-zero sized field with the
|
||||
* same offset.
|
||||
*/
|
||||
if (v->size(loc) != 0)
|
||||
firstNonZero = indx;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* Count the number of fields starting at firstIndex which are part of the
|
||||
* same union as field[firstIndex]. If not a union, return 1.
|
||||
*/
|
||||
int AggregateDeclaration::numFieldsInUnion(int firstIndex)
|
||||
{
|
||||
VarDeclaration * vd = fields.tdata()[firstIndex];
|
||||
/* If it is a zero-length field, AND we can't find an earlier non-zero
|
||||
* sized field with the same offset, we assume it's not part of a union.
|
||||
*/
|
||||
if (vd->size(loc) == 0 && !isUnionDeclaration() &&
|
||||
firstFieldInUnion(firstIndex) == firstIndex)
|
||||
return 1;
|
||||
int count = 1;
|
||||
for (size_t i = firstIndex+1; i < fields.dim; ++i)
|
||||
{
|
||||
VarDeclaration * v = fields.tdata()[i];
|
||||
// If offsets are different, they are not in the same union
|
||||
if (v->offset != vd->offset)
|
||||
break;
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
/****************************************
|
||||
* If field[indx] is not part of a union, return indx.
|
||||
* Otherwise, return the lowest field index of the union.
|
||||
*/
|
||||
int AggregateDeclaration::firstFieldInUnion(int indx)
|
||||
{
|
||||
if (isUnionDeclaration())
|
||||
return 0;
|
||||
VarDeclaration * vd = fields.tdata()[indx];
|
||||
int firstNonZero = indx; // first index in the union with non-zero size
|
||||
for (; ;)
|
||||
{
|
||||
if (indx == 0)
|
||||
return firstNonZero;
|
||||
VarDeclaration * v = fields.tdata()[indx - 1];
|
||||
if (v->offset != vd->offset)
|
||||
return firstNonZero;
|
||||
--indx;
|
||||
/* If it is a zero-length field, it's ambiguous: we don't know if it is
|
||||
* in the union unless we find an earlier non-zero sized field with the
|
||||
* same offset.
|
||||
*/
|
||||
if (v->size(loc) != 0)
|
||||
firstNonZero = indx;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* Count the number of fields starting at firstIndex which are part of the
|
||||
* same union as field[firstIndex]. If not a union, return 1.
|
||||
*/
|
||||
int AggregateDeclaration::numFieldsInUnion(int firstIndex)
|
||||
{
|
||||
VarDeclaration * vd = fields.tdata()[firstIndex];
|
||||
/* If it is a zero-length field, AND we can't find an earlier non-zero
|
||||
* sized field with the same offset, we assume it's not part of a union.
|
||||
*/
|
||||
if (vd->size(loc) == 0 && !isUnionDeclaration() &&
|
||||
firstFieldInUnion(firstIndex) == firstIndex)
|
||||
return 1;
|
||||
int count = 1;
|
||||
for (size_t i = firstIndex+1; i < fields.dim; ++i)
|
||||
{
|
||||
VarDeclaration * v = fields.tdata()[i];
|
||||
// If offsets are different, they are not in the same union
|
||||
if (v->offset != vd->offset)
|
||||
break;
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/********************************* StructDeclaration ****************************/
|
||||
|
||||
@@ -317,7 +317,7 @@ Dsymbol *StructDeclaration::syntaxCopy(Dsymbol *s)
|
||||
}
|
||||
|
||||
void StructDeclaration::semantic(Scope *sc)
|
||||
{
|
||||
{
|
||||
Scope *sc2;
|
||||
|
||||
//printf("+StructDeclaration::semantic(this=%p, '%s')\n", this, toChars());
|
||||
@@ -370,9 +370,9 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
|
||||
if (sizeok == 0) // if not already done the addMember step
|
||||
{
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
//printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars());
|
||||
s->addMember(sc, this, 1);
|
||||
}
|
||||
@@ -387,13 +387,13 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
sc2->protection = PROTpublic;
|
||||
sc2->explicitProtection = 0;
|
||||
|
||||
size_t members_dim = members->dim;
|
||||
size_t members_dim = members->dim;
|
||||
|
||||
/* Set scope so if there are forward references, we still might be able to
|
||||
* resolve individual members like enums.
|
||||
*/
|
||||
for (size_t i = 0; i < members_dim; i++)
|
||||
{ Dsymbol *s = members->tdata()[i];
|
||||
for (size_t i = 0; i < members_dim; i++)
|
||||
{ Dsymbol *s = members->tdata()[i];
|
||||
/* There are problems doing this in the general case because
|
||||
* Scope keeps track of things like 'offset'
|
||||
*/
|
||||
@@ -404,9 +404,9 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < members_dim; i++)
|
||||
for (size_t i = 0; i < members_dim; i++)
|
||||
{
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
s->semantic(sc2);
|
||||
#if 0
|
||||
if (sizeok == 2)
|
||||
@@ -416,10 +416,10 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DMDV1
|
||||
/* This doesn't work for DMDV2 because (ref S) and (S) parameter
|
||||
* lists will overload the same.
|
||||
*/
|
||||
#if DMDV1
|
||||
/* This doesn't work for DMDV2 because (ref S) and (S) parameter
|
||||
* lists will overload the same.
|
||||
*/
|
||||
/* The TypeInfo_Struct is expecting an opEquals and opCmp with
|
||||
* a parameter that is a pointer to the struct. But if there
|
||||
* isn't one, but is an opEquals or opCmp with a value, write
|
||||
@@ -477,7 +477,7 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
|
||||
id = Id::cmp;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if DMDV2
|
||||
dtor = buildDtor(sc2);
|
||||
postblit = buildPostBlit(sc2);
|
||||
@@ -523,7 +523,7 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
|
||||
// Determine if struct is all zeros or not
|
||||
zeroInit = 1;
|
||||
for (size_t i = 0; i < fields.dim; i++)
|
||||
for (size_t i = 0; i < fields.dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||
VarDeclaration *vd = s->isVarDeclaration();
|
||||
@@ -566,7 +566,7 @@ Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags)
|
||||
{
|
||||
//printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars());
|
||||
|
||||
if (scope && !symtab)
|
||||
if (scope && !symtab)
|
||||
semantic(scope);
|
||||
|
||||
if (!members || !symtab)
|
||||
@@ -579,7 +579,7 @@ Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags)
|
||||
}
|
||||
|
||||
void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
{
|
||||
buf->printf("%s ", kind());
|
||||
if (!isAnonymous())
|
||||
buf->writestring(toChars());
|
||||
@@ -592,9 +592,9 @@ void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
buf->writenl();
|
||||
buf->writeByte('{');
|
||||
buf->writenl();
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
|
||||
buf->writestring(" ");
|
||||
s->toCBuffer(buf, hgs);
|
||||
|
||||
Reference in New Issue
Block a user