added the ability to pre-declare a struct, like extern
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40174
This commit is contained in:
parent
73eb8bfd40
commit
f43b4468c6
@ -214,6 +214,7 @@ typedef struct s_symbol {
|
|||||||
#define uENUMFIELD 0x040
|
#define uENUMFIELD 0x040
|
||||||
#define uMISSING 0x080
|
#define uMISSING 0x080
|
||||||
#define uFORWARD 0x100
|
#define uFORWARD 0x100
|
||||||
|
#define uSTRUCT 0x200 /* :TODO: make this an ident */
|
||||||
/* uRETNONE is not stored in the "usage" field of a symbol. It is
|
/* uRETNONE is not stored in the "usage" field of a symbol. It is
|
||||||
* used during parsing a function, to detect a mix of "return;" and
|
* used during parsing a function, to detect a mix of "return;" and
|
||||||
* "return value;" in a few special cases.
|
* "return value;" in a few special cases.
|
||||||
|
@ -1700,7 +1700,7 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
|||||||
int cur_litidx = 0;
|
int cur_litidx = 0;
|
||||||
cell *values, *found;
|
cell *values, *found;
|
||||||
int usage;
|
int usage;
|
||||||
symbol *mysym;
|
symbol *mysym,*sym;
|
||||||
|
|
||||||
strcpy(name, firstname);
|
strcpy(name, firstname);
|
||||||
|
|
||||||
@ -1709,23 +1709,53 @@ static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct)
|
|||||||
|
|
||||||
memset(found, 0, sizeof(cell) * pstruct->argcount);
|
memset(found, 0, sizeof(cell) * pstruct->argcount);
|
||||||
|
|
||||||
|
//:TODO: Make this work with stock
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lastly, very lastly, we will insert a copy of this variable.
|
* Lastly, very lastly, we will insert a copy of this variable.
|
||||||
* This is soley to expose the pubvar.
|
* This is soley to expose the pubvar.
|
||||||
*/
|
*/
|
||||||
usage = uDEFINE|uREAD|uCONST;
|
usage = uREAD|uCONST|uSTRUCT;
|
||||||
if (fpublic)
|
if (fpublic)
|
||||||
{
|
{
|
||||||
usage |= uPUBLIC;
|
usage |= uPUBLIC;
|
||||||
}
|
}
|
||||||
mysym=addsym(name, 0, iVARIABLE, sGLOBAL, pc_addtag(pstruct->name), usage);
|
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)
|
||||||
|
{
|
||||||
|
error(21, name);
|
||||||
|
} else {
|
||||||
|
if (sym->usage & uPUBLIC && !fpublic)
|
||||||
|
{
|
||||||
|
error(42);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error(21, name);
|
||||||
|
}
|
||||||
|
mysym = sym;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!mysym)
|
||||||
|
{
|
||||||
|
mysym=addsym(name, 0, iVARIABLE, sGLOBAL, pc_addtag(pstruct->name), usage);
|
||||||
|
}
|
||||||
|
|
||||||
/* Maybe error with "public struct requires initialization?" */
|
if (!matchtoken('='))
|
||||||
if (!needtoken('='))
|
|
||||||
{
|
{
|
||||||
matchtoken(';');
|
matchtoken(';');
|
||||||
|
/* Mark it as undefined instead */
|
||||||
|
mysym->usage = uSTOCK|uSTRUCT;
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
mysym->usage = usage;
|
||||||
}
|
}
|
||||||
needtoken('{');
|
needtoken('{');
|
||||||
do
|
do
|
||||||
@ -1792,7 +1822,6 @@ 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) {
|
||||||
symbol *sym = NULL;
|
|
||||||
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user