Fix indentation, spacing, and style in declstruct().
This commit is contained in:
parent
d2c7064e2b
commit
16177e9ecc
@ -1778,25 +1778,17 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
||||
*/
|
||||
usage = uREAD|uCONST|uSTRUCT;
|
||||
if (fpublic)
|
||||
{
|
||||
usage |= uPUBLIC;
|
||||
}
|
||||
mysym = NULL;
|
||||
for (sym=glbtab.next; sym!=NULL; sym=sym->next)
|
||||
{
|
||||
if (strcmp(name, sym->name) == 0)
|
||||
{
|
||||
if ((sym->usage & uSTRUCT) && sym->vclass == sGLOBAL)
|
||||
{
|
||||
if (sym->usage & uDEFINE)
|
||||
{
|
||||
for (sym=glbtab.next; sym!=NULL; sym=sym->next) {
|
||||
if (strcmp(name, sym->name) == 0) {
|
||||
if ((sym->usage & uSTRUCT) && sym->vclass == sGLOBAL) {
|
||||
if (sym->usage & uDEFINE) {
|
||||
error(21, name);
|
||||
} else {
|
||||
if (sym->usage & uPUBLIC && !fpublic)
|
||||
{
|
||||
error(42);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error(21, name);
|
||||
}
|
||||
@ -1805,51 +1797,42 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
||||
}
|
||||
}
|
||||
if (!mysym)
|
||||
{
|
||||
mysym=addsym(name, 0, iVARIABLE, sGLOBAL, pc_addtag(pstruct->name), usage);
|
||||
}
|
||||
|
||||
if (!matchtoken('='))
|
||||
{
|
||||
if (!matchtoken('=')) {
|
||||
matchtoken(';');
|
||||
/* Mark it as undefined instead */
|
||||
mysym->usage = uSTOCK|uSTRUCT;
|
||||
free(found);
|
||||
free(values);
|
||||
return;
|
||||
} else {
|
||||
mysym->usage = usage;
|
||||
}
|
||||
|
||||
mysym->usage = usage;
|
||||
needtoken('{');
|
||||
do
|
||||
{
|
||||
|
||||
do {
|
||||
structarg_t *arg;
|
||||
/* Detect early exit */
|
||||
if (matchtoken('}'))
|
||||
{
|
||||
if (matchtoken('}')) {
|
||||
lexpush();
|
||||
break;
|
||||
}
|
||||
tok=lex(&val,&str);
|
||||
if (tok != tSYMBOL)
|
||||
{
|
||||
if (tok != tSYMBOL) {
|
||||
error(1, "-identifier-", str);
|
||||
continue;
|
||||
}
|
||||
arg=pstructs_getarg(pstruct,str);
|
||||
if (arg == NULL)
|
||||
{
|
||||
error(96, str, sym->name);
|
||||
}
|
||||
needtoken('=');
|
||||
cur_litidx = litidx;
|
||||
tok=lex(&val,&str);
|
||||
if (!arg)
|
||||
{
|
||||
if (!arg) {
|
||||
continue;
|
||||
}
|
||||
if (tok == tSTRING)
|
||||
{
|
||||
if (tok == tSTRING) {
|
||||
assert(litidx != 0);
|
||||
if (arg->dimcount != 1)
|
||||
{
|
||||
@ -1863,8 +1846,7 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
||||
} else if (tok == tNUMBER || tok == tRATIONAL) {
|
||||
/* eat optional 'f' */
|
||||
matchtoken('f');
|
||||
if (arg->ident != iVARIABLE && arg->ident != iREFERENCE)
|
||||
{
|
||||
if (arg->ident != iVARIABLE && arg->ident != iREFERENCE) {
|
||||
error(23);
|
||||
} else {
|
||||
if ((arg->tag == pc_addtag("Float") && tok == tNUMBER) ||
|
||||
@ -1872,8 +1854,7 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
||||
{
|
||||
error(213);
|
||||
}
|
||||
if (arg->ident == iVARIABLE)
|
||||
{
|
||||
if (arg->ident == iVARIABLE) {
|
||||
values[arg->index] = val;
|
||||
} else if (arg->ident == iREFERENCE) {
|
||||
values[arg->index] = glb_declared * sizeof(cell);
|
||||
@ -1884,37 +1865,27 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
||||
found[arg->index] = 1;
|
||||
}
|
||||
} else if (tok == tSYMBOL) {
|
||||
for (sym=glbtab.next; sym!=NULL; sym=sym->next)
|
||||
{
|
||||
for (sym=glbtab.next; sym!=NULL; sym=sym->next) {
|
||||
if (sym->vclass != sGLOBAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (strcmp(sym->name, str) == 0)
|
||||
{
|
||||
if (arg->ident == iREFERENCE && sym->ident != iVARIABLE)
|
||||
{
|
||||
if (strcmp(sym->name, str) == 0) {
|
||||
if (arg->ident == iREFERENCE && sym->ident != iVARIABLE) {
|
||||
error(97, str);
|
||||
} else if (arg->ident == iARRAY) {
|
||||
if (sym->ident != iARRAY)
|
||||
{
|
||||
if (sym->ident != iARRAY) {
|
||||
error(97, str);
|
||||
} else {
|
||||
/* :TODO: We should check dimension sizes here... */
|
||||
}
|
||||
} else if (arg->ident == iREFARRAY) {
|
||||
if (sym->ident != iARRAY)
|
||||
{
|
||||
error(97, str);
|
||||
}
|
||||
/* :TODO: Check dimension sizes! */
|
||||
} else {
|
||||
error(97, str);
|
||||
}
|
||||
if (sym->tag != arg->tag)
|
||||
{
|
||||
error(213);
|
||||
}
|
||||
sym->usage |= uREAD;
|
||||
values[arg->index] = sym->addr;
|
||||
found[arg->index] = 1;
|
||||
@ -1923,9 +1894,7 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
||||
}
|
||||
}
|
||||
if (!sym)
|
||||
{
|
||||
error(17, str);
|
||||
}
|
||||
} else {
|
||||
error(1, "-identifier-", str);
|
||||
}
|
||||
@ -1933,13 +1902,10 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
||||
needtoken('}');
|
||||
matchtoken(';'); /* eat up optional semicolon */
|
||||
|
||||
for (i=0; i<pstruct->argcount; i++)
|
||||
{
|
||||
if (!found[i])
|
||||
{
|
||||
for (i=0; i<pstruct->argcount; i++) {
|
||||
if (!found[i]) {
|
||||
structarg_t *arg = pstruct->args[i];
|
||||
if (arg->ident == iREFARRAY)
|
||||
{
|
||||
if (arg->ident == iREFARRAY) {
|
||||
values[arg->index] = glb_declared * sizeof(cell);
|
||||
glb_declared += 1;
|
||||
litadd(0);
|
||||
@ -1956,9 +1922,7 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
||||
glb_declared += pstruct->argcount;
|
||||
|
||||
for (i=0; i<pstruct->argcount; i++)
|
||||
{
|
||||
litadd(values[i]);
|
||||
}
|
||||
|
||||
begdseg();
|
||||
dumplits();
|
||||
|
Loading…
Reference in New Issue
Block a user