commit de755db38679f8349e10fda5d6150ad10e1aaac5
parent a5e164c3c1c4ba912837cdbda8686ecd37b42a38
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 16 Sep 2016 14:23:11 +0200
[cc2] Move INITF to sclass
If the symbol is a initializer is something that is not related
to the type of the symbol, so the best place for it is in the
storage class, which is a property of the symbol, not of the
type.
Diffstat:
6 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/cc2/arch/amd64-sysv/code.c b/cc2/arch/amd64-sysv/code.c
@@ -139,13 +139,13 @@ data(Node *np)
static void
label(Symbol *sym)
{
- int seg, flags = sym->type.flags;
+ int seg;
char *name = symname(sym);
Type *tp = &sym->type;
- if (flags & FUNF)
+ if (sym->type.flags & FUNF)
seg = CODESEG;
- else if (flags & INITF)
+ else if (sym->kind == INITF)
seg = DATASEG;
else
seg = BSSSEG;
diff --git a/cc2/arch/i386-sysv/code.c b/cc2/arch/i386-sysv/code.c
@@ -138,13 +138,13 @@ data(Node *np)
static void
label(Symbol *sym)
{
- int seg, flags = sym->type.flags;
+ int seg;
char *name = symname(sym);
Type *tp = &sym->type;
- if (flags & FUNF)
+ if (sym->type.flags & FUNF)
seg = CODESEG;
- else if (flags & INITF)
+ else if (sym->kind == INITF)
seg = DATASEG;
else
seg = BSSSEG;
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
@@ -271,7 +271,7 @@ defglobal(Symbol *sym)
if (sym->kind == SGLOB)
fputs("export ", stdout);
printf("data %s = {\n", symname(sym));
- if (sym->type.flags & INITF)
+ if (sym->kind == INITF)
return;
printf("\tz\t%lu\n}\n", sym->type.size);
}
diff --git a/cc2/arch/z80/code.c b/cc2/arch/z80/code.c
@@ -55,12 +55,12 @@ symname(Symbol *sym)
static void
label(Symbol *sym)
{
- int seg, flags = sym->type.flags;
+ int seg;
char *name = symname(sym);
- if (flags & FUNF)
+ if (sym->type.flags & FUNF)
seg = CODESEG;
- else if (flags & INITF)
+ else if (sym->kind == INITF)
seg = DATASEG;
else
seg = BSSSEG;
diff --git a/cc2/cc2.h b/cc2/cc2.h
@@ -12,7 +12,6 @@ enum tflags {
UNIONF = 16,
FUNF = 32,
PARF = 64,
- INITF = 128
};
enum sclass {
@@ -28,6 +27,7 @@ enum sclass {
SMEMB = 'M',
SCONST = '#',
STRING = '"',
+ INITF = '=',
SNONE = 0 /* cc2 relies on SNONE being 0 in nextpc() */
};
diff --git a/cc2/parser.c b/cc2/parser.c
@@ -571,7 +571,7 @@ vardecl(void)
sym->kind = sclass;
if (ininit)
- sym->type.flags |= INITF;
+ sym->kind = INITF;
decl(sym);
delnode(np);
}