[hackers] [scc] [cc2] Move INITF to sclass || Roberto E. Vargas Caballero
commit de755db38679f8349e10fda5d6150ad10e1aaac5
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Sep 16 14:23:11 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Sep 16 14:23:11 2016 +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.
diff --git a/cc2/arch/amd64-sysv/code.c b/cc2/arch/amd64-sysv/code.c
index 1a374d4..7aa4081 100644
--- a/cc2/arch/amd64-sysv/code.c
+++ b/cc2/arch/amd64-sysv/code.c
_AT_@ -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
index 5238908..fdf5d63 100644
--- a/cc2/arch/i386-sysv/code.c
+++ b/cc2/arch/i386-sysv/code.c
_AT_@ -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
index 72dc4d7..1d9164b 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -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
index b15f58e..d3f70be 100644
--- a/cc2/arch/z80/code.c
+++ b/cc2/arch/z80/code.c
_AT_@ -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
index 888f026..9bc248c 100644
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
_AT_@ -12,7 +12,6 @@ enum tflags {
UNIONF = 16,
FUNF = 32,
PARF = 64,
- INITF = 128
};
enum sclass {
_AT_@ -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
index d616ff7..34da9a9 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
_AT_@ -571,7 +571,7 @@ vardecl(void)
sym->kind = sclass;
if (ininit)
- sym->type.flags |= INITF;
+ sym->kind = INITF;
decl(sym);
delnode(np);
}
Received on Fri Sep 16 2016 - 14:57:36 CEST
This archive was generated by hypermail 2.3.0
: Fri Sep 16 2016 - 15:00:26 CEST