Skip to content

Commit

Permalink
redo pull #1179
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 21, 2013
1 parent 4ea6cb4 commit 528ad8e
Show file tree
Hide file tree
Showing 4 changed files with 676 additions and 204 deletions.
35 changes: 29 additions & 6 deletions src/attrib.c
Expand Up @@ -472,7 +472,14 @@ void StorageClassDeclaration::semantic(Scope *sc)
}
}

void StorageClassDeclaration::stcToCBuffer(OutBuffer *buf, StorageClass stc)

/*************************************************
* Pick off one of the storage classes from stc,
* and return a pointer to a string representation of it.
* stc is reduced by the one picked.
* tmp[] is a buffer big enough to hold that string.
*/
const char *StorageClassDeclaration::stcToChars(char tmp[], StorageClass& stc)
{
struct SCstring
{
Expand Down Expand Up @@ -516,21 +523,37 @@ void StorageClassDeclaration::stcToCBuffer(OutBuffer *buf, StorageClass stc)

for (int i = 0; i < sizeof(table)/sizeof(table[0]); i++)
{
if (stc & table[i].stc)
StorageClass tbl = table[i].stc;
assert(tbl & STCStorageClass);
if (stc & tbl)
{
stc &= ~tbl;
enum TOK tok = table[i].tok;
#if DMDV2
if (tok == TOKat)
{
buf->writeByte('@');
buf->writestring(table[i].id->toChars());
tmp[0] = '@';
strcpy(tmp + 1, table[i].id->toChars());
return tmp;
}
else
#endif
buf->writestring(Token::toChars(tok));
buf->writeByte(' ');
return Token::toChars(tok);
}
}
//printf("stc = %llx\n", (unsigned long long)stc);
return NULL;
}

void StorageClassDeclaration::stcToCBuffer(OutBuffer *buf, StorageClass stc)
{
while (stc)
{ char tmp[20];
const char *p = stcToChars(tmp, stc);
assert(strlen(p) < sizeof(tmp));
buf->writestring(p);
buf->writeByte(' ');
}
}

void StorageClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
Expand Down
1 change: 1 addition & 0 deletions src/attrib.h
Expand Up @@ -72,6 +72,7 @@ struct StorageClassDeclaration : AttribDeclaration
int oneMember(Dsymbol **ps, Identifier *ident);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);

static const char *stcToChars(char tmp[], StorageClass& stc);
static void stcToCBuffer(OutBuffer *buf, StorageClass stc);
};

Expand Down
9 changes: 9 additions & 0 deletions src/declaration.h
Expand Up @@ -87,6 +87,12 @@ enum PURE;
#define STCtemp 0x10000000000LL // temporary variable introduced by inlining
// and used only in backend process, so it's rvalue

#define STCStorageClass (STCauto | STCscope | STCstatic | STCextern | STCconst | STCfinal | \
STCabstract | STCsynchronized | STCdeprecated | STCoverride | STClazy | STCalias | \
STCout | STCin | \
STCmanifest | STCimmutable | STCshared | STCnothrow | STCpure | STCref | STCtls | \
STCgshared | STCproperty | STCsafe | STCtrusted | STCsystem | STCdisable)

#ifdef BUG6652
#define STCbug6652 0x800000000000LL //
#endif
Expand Down Expand Up @@ -290,6 +296,7 @@ struct VarDeclaration : Declaration
void semantic2(Scope *sc);
const char *kind();
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void toJson(JsonOut *json);
Type *htype;
Initializer *hinit;
AggregateDeclaration *isThis();
Expand Down Expand Up @@ -640,6 +647,7 @@ struct FuncDeclaration : Declaration

void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs);
void toJson(JsonOut *json);
int overrides(FuncDeclaration *fd);
int findVtblIndex(Dsymbols *vtbl, int dim);
int overloadInsert(Dsymbol *s);
Expand Down Expand Up @@ -768,6 +776,7 @@ struct PostBlitDeclaration : FuncDeclaration
Dsymbol *syntaxCopy(Dsymbol *);
void semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void toJson(JsonOut *json);
int isVirtual();
int addPreInvariant();
int addPostInvariant();
Expand Down

0 comments on commit 528ad8e

Please sign in to comment.