Move is_new and has_postdims bits out of declinfo and into typeinfo.

This commit is contained in:
David Anderson 2014-11-07 17:05:27 -08:00
parent b89bd36335
commit 2c31b99ce3
2 changed files with 14 additions and 14 deletions

View File

@ -287,14 +287,14 @@ typedef struct {
int numtags; // Number of tags found. int numtags; // Number of tags found.
int ident; // Either iREFERENCE, iARRAY, or iVARIABLE. int ident; // Either iREFERENCE, iARRAY, or iVARIABLE.
char usage; // Usage flags. char usage; // Usage flags.
bool is_new; // New-style declaration.
bool has_postdims; // Dimensions, if present, were in postfix position.
} typeinfo_t; } typeinfo_t;
/* For parsing declarations. */ /* For parsing declarations. */
typedef struct { typedef struct {
char name[sNAMEMAX + 1]; char name[sNAMEMAX + 1];
typeinfo_t type; typeinfo_t type;
int is_new; // New-style declaration.
int has_postdims; // Dimensions, if present, were in postfix position.
int opertok; // Operator token, if applicable. int opertok; // Operator token, if applicable.
} declinfo_t; } declinfo_t;

View File

@ -1451,8 +1451,8 @@ static void dodecl(const token_t *tok)
decl.type.tag = 0; decl.type.tag = 0;
} }
if (!decl.opertok && (tok->id == tNEW || decl.has_postdims || !lexpeek('('))) { if (!decl.opertok && (tok->id == tNEW || decl.type.has_postdims || !lexpeek('('))) {
if (tok->id == tNEW && decl.is_new) if (tok->id == tNEW && decl.type.is_new)
error(143); error(143);
if (decl.type.tag & STRUCTTAG) { if (decl.type.tag & STRUCTTAG) {
pstruct_t *pstruct = pstructs_find(pc_tagname(decl.type.tag)); pstruct_t *pstruct = pstructs_find(pc_tagname(decl.type.tag));
@ -2030,7 +2030,7 @@ static void declglb(declinfo_t *decl,int fpublic,int fstatic,int fstock)
if (!matchtoken(',')) if (!matchtoken(','))
break; break;
if (decl->is_new) if (decl->type.is_new)
reparse_new_decl(decl, DECLFLAG_VARIABLE|DECLFLAG_ENUMROOT); reparse_new_decl(decl, DECLFLAG_VARIABLE|DECLFLAG_ENUMROOT);
else else
reparse_old_decl(decl, DECLFLAG_VARIABLE|DECLFLAG_ENUMROOT); reparse_old_decl(decl, DECLFLAG_VARIABLE|DECLFLAG_ENUMROOT);
@ -2221,7 +2221,7 @@ static void declloc(int tokid)
if (!matchtoken(',')) if (!matchtoken(','))
break; break;
if (decl.is_new) if (decl.type.is_new)
reparse_new_decl(&decl, declflags); reparse_new_decl(&decl, declflags);
else else
reparse_old_decl(&decl, declflags); reparse_old_decl(&decl, declflags);
@ -3168,7 +3168,7 @@ static void parse_old_array_dims(declinfo_t *decl, int flags)
type->ident = iARRAY; type->ident = iARRAY;
} }
decl->has_postdims = TRUE; decl->type.has_postdims = TRUE;
} }
static int parse_old_decl(declinfo_t *decl, int flags) static int parse_old_decl(declinfo_t *decl, int flags)
@ -3310,7 +3310,7 @@ static int parse_new_decl(declinfo_t *decl, const token_t *first, int flags)
} }
} }
decl->is_new = TRUE; decl->type.is_new = TRUE;
return TRUE; return TRUE;
} }
@ -3320,7 +3320,7 @@ static int reparse_new_decl(declinfo_t *decl, int flags)
if (expecttoken(tSYMBOL, &tok)) if (expecttoken(tSYMBOL, &tok))
strcpy(decl->name, tok.str); strcpy(decl->name, tok.str);
if (decl->has_postdims) { if (decl->type.has_postdims) {
// We have something like: // We have something like:
// int x[], y... // int x[], y...
// //
@ -3330,7 +3330,7 @@ static int reparse_new_decl(declinfo_t *decl, int flags)
decl->type.enumroot = NULL; decl->type.enumroot = NULL;
decl->type.ident = iVARIABLE; decl->type.ident = iVARIABLE;
decl->type.size = 0; decl->type.size = 0;
decl->has_postdims = FALSE; decl->type.has_postdims = false;
if (matchtoken('[')) if (matchtoken('['))
parse_old_array_dims(decl, flags); parse_old_array_dims(decl, flags);
} else { } else {
@ -3403,7 +3403,7 @@ int parse_decl(declinfo_t *decl, int flags)
// This must be a newdecl, "x[] y" or "x[] &y", the latter of which // This must be a newdecl, "x[] y" or "x[] &y", the latter of which
// is illegal, but we flow it through the right path anyway. // is illegal, but we flow it through the right path anyway.
lexpush(); lexpush();
decl->has_postdims = FALSE; decl->type.has_postdims = false;
return parse_new_decl(decl, &ident.tok, flags); return parse_new_decl(decl, &ident.tok, flags);
} }
@ -3532,7 +3532,7 @@ symbol *parse_inline_function(methodmap_t *map, const typeinfo_t *type, const ch
} else { } else {
decl.type = *type; decl.type = *type;
} }
decl.is_new = TRUE; decl.type.is_new = TRUE;
const int *thistag = NULL; const int *thistag = NULL;
if (!is_ctor) if (!is_ctor)
@ -5281,7 +5281,7 @@ static int newfunc(declinfo_t *decl, const int *thistag, int fpublic, int fstati
lexpush(); lexpush();
} else { } else {
// We require '{' for new methods. // We require '{' for new methods.
if (decl->is_new) if (decl->type.is_new)
needtoken('{'); needtoken('{');
/* Insert a separator so that comments following the statement will not /* Insert a separator so that comments following the statement will not
@ -5302,7 +5302,7 @@ static int newfunc(declinfo_t *decl, const int *thistag, int fpublic, int fstati
if (sym->tag == pc_tag_void && if (sym->tag == pc_tag_void &&
(sym->usage & uFORWARD) && (sym->usage & uFORWARD) &&
!decl->type.tag && !decl->type.tag &&
!decl->is_new) !decl->type.is_new)
{ {
// We got something like: // We got something like:
// forward void X(); // forward void X();