definition module not found, corrected typo.
- changed mechanism for variables that have their address given.
- added option for symmetric integer ranges
fund1 = T_CARDINAL;
break;
}
- switch(fund2 = t1->tp_fund) {
+ switch(fund2 = t2->tp_fund) {
case T_WORD:
fund2 = T_INTEGER;
break;
if (tp->tp_fund == T_INTEGER) C_adi(size);
else C_adu(size);
}
- if (size == word_size) RangeCheck(tp, int_type);
+ if (size == word_size) {
+ RangeCheck(tp, tp->tp_fund == T_INTEGER ?
+ int_type : card_type);
+ }
CodeDStore(left);
break;
}
struct variable {
arith va_off; /* address or offset of variable */
char *va_name; /* name of variable if given */
- char va_addrgiven; /* an address was given in the program */
#define var_off df_value.df_variable.va_off
#define var_name df_value.df_variable.va_name
-#define var_addrgiven df_value.df_variable.va_addrgiven
};
struct constant {
struct forwtype {
struct node *f_node;
- struct type *f_type;
-#define df_forw_type df_value.df_fortype.f_type
#define df_forw_node df_value.df_fortype.f_node
};
#define D_QEXPORTED 0x40 /* set if qualified exported */
#define D_BUSY 0x80 /* set if busy reading this definition module */
#define D_FOREIGN 0x100 /* set for foreign language modules */
+#define D_ADDRGIVEN 0x200 /* set if address given for variable */
struct type *df_type;
union {
struct module df_module;
if (kind == D_FORWTYPE) return df;
if (kind == D_TYPE) {
df->df_kind = D_FTYPE;
- FreeNode(df->df_forw_node);
}
else {
error("identifier \"%s\" must be a type",
struct scopelist *vis;
char *fn = FileName;
int ln = LineNumber;
+ struct scope *newsc = CurrentScope;
level += incr;
df = lookup(id, GlobalScope, 1);
ForeignFlag = 0;
open_scope(CLOSEDSCOPE);
+ newsc = CurrentScope;
if (!is_anon_idf(id) && GetFile(id->id_text)) {
DefModule();
}
else {
df = lookup(id, GlobalScope, 1);
- CurrentScope->sc_name = id->id_text;
+ newsc->sc_name = id->id_text;
}
vis = CurrVis;
close_scope(SC_CHKFORW);
df = MkDef(id, GlobalScope, D_ERROR);
df->df_type = error_type;
df->mod_vis = vis;
+ newsc->sc_definedby = df;
}
}
else if (df->df_flags & D_BUSY) {
*/
assert(ds->dsg_kind == DSG_INIT);
- if (df->var_addrgiven) {
+ if (df->df_flags & D_ADDRGIVEN) {
/* the programmer specified an address in the declaration of
the variable. Generate code to push the address.
*/
.IP \fB\-i\fR\fInum\fR
maximum number of bits in a set. When not used, a default value is
retained.
+.IP \fB\-s\fR
+make INTEGER ranges symmetric, t.i., MIN(INTEGER) = - MAX(INTEGER).
+This is useful for interpreters that use the "real" MIN(INTEGER) to
+indicate "undefined".
.LP
.SH FILES
.IR ~em/lib/em_m2 :
*/
register struct type *tp = idlist->nd_left->nd_type;
- df->var_addrgiven = 1;
- df->df_flags |= D_NOREG;
+ df->df_flags |= D_ADDRGIVEN | D_NOREG;
if (tp != error_type && !(tp->tp_fund & T_CARDINAL)){
node_error(idlist->nd_left,
"illegal type for address");
allow for warning messages whose class is a member of \fIclasses\fR.
.IP \fB\-x\fR
make all procedure names global, so that \fIadb\fR(1) understands them.
+.IP \fB\-Xs\fR
+make INTEGER ranges symmetric, t.i., MIN(INTEGER) = - MAX(INTEGER).
+This is useful for interpreters that use the "real" MIN(INTEGER) to
+indicate "undefined".
.LP
.SH SEE ALSO
\fIack\fR(1), \fIem_m2\fR(6)
while (df = *pdf) {
if (df->df_kind == D_FORWTYPE) {
register struct def *df1 = df;
+ register struct node *nd = df->df_forw_node;
*pdf = df->df_nextinscope;
RemoveFromIdList(df);
- df = lookfor(df->df_forw_node, CurrVis, 1);
+ df = lookfor(nd, CurrVis, 1);
if (! df->df_kind & (D_ERROR|D_FTYPE|D_TYPE)) {
-node_error(df1->df_forw_node, "\"%s\" is not a type", df1->df_idf->id_text);
+node_error(nd, "\"%s\" is not a type", df1->df_idf->id_text);
+ }
+ while (nd) {
+ nd->nd_type->next = df->df_type;
+ nd = nd->nd_right;
}
- df1->df_forw_type->next = df->df_type;
FreeNode(df1->df_forw_node);
free_def(df1);
continue;
}
else if (df->df_kind == D_FTYPE) {
+ register struct node *nd = df->df_forw_node;
+
df->df_kind = D_TYPE;
- df->df_forw_type->next = df->df_type;
+ while (nd) {
+ nd->nd_type->next = df->df_type;
+ nd = nd->nd_right;
+ }
+ FreeNode(df->df_forw_node);
}
else if (df->df_kind & (D_FORWARD|D_FORWMODULE)) {
/* These definitions must be found in
else {
register struct def *df = nd->nd_def;
- if (df->df_kind&(D_ISTYPE|D_FORWARD|D_ERROR)) {
+ if (df->df_kind&(D_ISTYPE|D_FORWARD|D_FORWTYPE|D_ERROR)) {
if (! df->df_type) {
node_error(nd,"type \"%s\" not (yet) declared", df->df_idf->id_text);
}
- else tp = df->df_type;
+ else {
+ if (df->df_kind == D_FORWTYPE) {
+ df->df_kind = D_FTYPE;
+ }
+ tp = df->df_type;
+ }
}
else {
node_error(nd,"identifier \"%s\" is not a type", df->df_idf->id_text);
in "dot". This routine handles the different cases.
*/
register struct node *nd;
+ register struct def *df1;
*ptp = construct_type(T_POINTER, NULLTYPE);
- if (lookup(dot.TOK_IDF, CurrentScope, 1)) {
+ if ((df1 = lookup(dot.TOK_IDF, CurrentScope, 1))) {
/* Either a Module or a Type, but in both cases defined
in this scope, so this is the correct identification
*/
+ if (df1->df_kind == D_FORWTYPE) {
+ nd = new_node();
+ nd->nd_token = dot;
+ nd->nd_right = df1->df_forw_node;
+ df1->df_forw_node = nd;
+ nd->nd_type = *ptp;
+ }
return 1;
}
nd = new_node();
nd->nd_token = dot;
- if (lookfor(nd, CurrVis, 0)->df_kind == D_MODULE) {
+ if ((df1 = lookfor(nd, CurrVis, 0))->df_kind == D_MODULE) {
/* A Modulename in one of the enclosing scopes.
It is not clear from the language definition that
it is correct to handle these like this, but
if (df->df_kind == D_TYPE) {
(*ptp)->next = df->df_type;
+ free_node(nd);
}
else {
- df->df_forw_type = *ptp;
+ nd->nd_type = *ptp;
df->df_forw_node = nd;
+ if (df1->df_kind == D_TYPE) {
+ df->df_type = df1->df_type;
+ }
}
}
return 0;
WalkProcedure(df);
break;
case D_VARIABLE:
- if (!proclevel && !df->var_addrgiven) {
+ if (!proclevel && !(df->df_flags & D_ADDRGIVEN)) {
C_df_dnam(df->var_name);
C_bss_cst(
WA(df->df_type->tp_size),