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