D_BUSY added, to check recursive deps in def modules

This commit is contained in:
ceriel 1986-12-16 15:22:33 +00:00
parent 33a89a8684
commit a92c8bf067
4 changed files with 10 additions and 5 deletions

View file

@ -97,7 +97,7 @@ struct def { /* list of definitions for a name */
#define D_VALUE (D_PROCEDURE|D_VARIABLE|D_FIELD|D_ENUM|D_CONST|D_PROCHEAD) #define D_VALUE (D_PROCEDURE|D_VARIABLE|D_FIELD|D_ENUM|D_CONST|D_PROCHEAD)
#define D_ISTYPE (D_HIDDEN|D_TYPE|D_FTYPE) #define D_ISTYPE (D_HIDDEN|D_TYPE|D_FTYPE)
#define is_type(dfx) ((dfx)->df_kind & D_ISTYPE) #define is_type(dfx) ((dfx)->df_kind & D_ISTYPE)
char df_flags; unsigned short df_flags;
#define D_NOREG 0x01 /* set if it may not reside in a register */ #define D_NOREG 0x01 /* set if it may not reside in a register */
#define D_USED 0x02 /* set if used (future use ???) */ #define D_USED 0x02 /* set if used (future use ???) */
#define D_DEFINED 0x04 /* set if it is assigned a value (future use ???) */ #define D_DEFINED 0x04 /* set if it is assigned a value (future use ???) */
@ -105,6 +105,7 @@ struct def { /* list of definitions for a name */
#define D_VALPAR 0x10 /* set if it is a value parameter */ #define D_VALPAR 0x10 /* set if it is a value parameter */
#define D_EXPORTED 0x20 /* set if exported */ #define D_EXPORTED 0x20 /* set if exported */
#define D_QEXPORTED 0x40 /* set if qualified exported */ #define D_QEXPORTED 0x40 /* set if qualified exported */
#define D_BUSY 0x80 /* set if busy reading this definition module */
struct type *df_type; struct type *df_type;
union { union {
struct module df_module; struct module df_module;
@ -120,8 +121,6 @@ struct def { /* list of definitions for a name */
} df_value; } df_value;
}; };
#define SetUsed(df) ((df)->df_flags |= D_USED)
/* ALLOCDEF "def" 50 */ /* ALLOCDEF "def" 50 */
extern struct def extern struct def

View file

@ -55,7 +55,7 @@ GetDefinitionModule(id, incr)
We may have to read the definition module itself. We may have to read the definition module itself.
Also increment level by "incr". Also increment level by "incr".
*/ */
struct def *df; register struct def *df;
static int level; static int level;
struct scopelist *vis; struct scopelist *vis;
@ -101,6 +101,10 @@ GetDefinitionModule(id, incr)
df->mod_vis = vis; df->mod_vis = vis;
} }
} }
else if (df->df_flags & D_BUSY) {
error("definition module \"%s\" depends on itself",
id->id_text);
}
else if (df == Defined && level == 1) { else if (df == Defined && level == 1) {
error("cannot import from currently defined module"); error("cannot import from currently defined module");
df->df_kind = D_ERROR; df->df_kind = D_ERROR;

View file

@ -121,6 +121,7 @@ DefinitionModule
} : } :
DEFINITION DEFINITION
MODULE IDENT { df = define(dot.TOK_IDF, GlobalScope, D_MODULE); MODULE IDENT { df = define(dot.TOK_IDF, GlobalScope, D_MODULE);
df->df_flags |= D_BUSY;
if (!Defined) Defined = df; if (!Defined) Defined = df;
if (df->df_idf != DefId) { if (df->df_idf != DefId) {
error("DEFINITION MODULE name is not \"%s\"", error("DEFINITION MODULE name is not \"%s\"",
@ -155,6 +156,7 @@ node_warning(exportlist, W_OLDFASHIONED, "export list in definition module ignor
} }
DefinitionModule--; DefinitionModule--;
match_id(df->df_idf, dot.TOK_IDF); match_id(df->df_idf, dot.TOK_IDF);
df->df_flags &= ~D_BUSY;
} }
'.' '.'
; ;

View file

@ -383,7 +383,7 @@ set_type(tp)
} }
tp = construct_type(T_SET, tp); tp = construct_type(T_SET, tp);
tp->tp_size = WA(((ub - lb) + 8) >> 3); tp->tp_size = WA((ub - lb + 8) >> 3);
return tp; return tp;
} }