Fixed some problems:

files that use the em_code module must include the em_code.h file
improved checking of definitions after use
fixed problem with ranges in case statements
This commit is contained in:
ceriel 1987-11-11 13:10:08 +00:00
parent b434cd85a0
commit 603c65950c
13 changed files with 46 additions and 37 deletions

View file

@ -183,7 +183,7 @@ error.o: input.h
error.o: inputtype.h error.o: inputtype.h
error.o: main.h error.o: main.h
error.o: node.h error.o: node.h
error.o: squeeze.h error.o: nostrict.h
error.o: strict3rd.h error.o: strict3rd.h
error.o: warning.h error.o: warning.h
main.o: LLlex.h main.o: LLlex.h
@ -221,6 +221,7 @@ type.o: def.h
type.o: idf.h type.o: idf.h
type.o: nocross.h type.o: nocross.h
type.o: node.h type.o: node.h
type.o: nostrict.h
type.o: scope.h type.o: scope.h
type.o: squeeze.h type.o: squeeze.h
type.o: target_sizes.h type.o: target_sizes.h
@ -316,8 +317,8 @@ chk_expr.o: main.h
chk_expr.o: misc.h chk_expr.o: misc.h
chk_expr.o: nocross.h chk_expr.o: nocross.h
chk_expr.o: node.h chk_expr.o: node.h
chk_expr.o: nostrict.h
chk_expr.o: scope.h chk_expr.o: scope.h
chk_expr.o: squeeze.h
chk_expr.o: standards.h chk_expr.o: standards.h
chk_expr.o: strict3rd.h chk_expr.o: strict3rd.h
chk_expr.o: target_sizes.h chk_expr.o: target_sizes.h
@ -326,7 +327,7 @@ chk_expr.o: warning.h
options.o: idfsize.h options.o: idfsize.h
options.o: main.h options.o: main.h
options.o: nocross.h options.o: nocross.h
options.o: squeeze.h options.o: nostrict.h
options.o: strict3rd.h options.o: strict3rd.h
options.o: target_sizes.h options.o: target_sizes.h
options.o: type.h options.o: type.h
@ -416,8 +417,8 @@ declar.o: main.h
declar.o: misc.h declar.o: misc.h
declar.o: nocross.h declar.o: nocross.h
declar.o: node.h declar.o: node.h
declar.o: nostrict.h
declar.o: scope.h declar.o: scope.h
declar.o: squeeze.h
declar.o: strict3rd.h declar.o: strict3rd.h
declar.o: target_sizes.h declar.o: target_sizes.h
declar.o: type.h declar.o: type.h

View file

@ -1 +1 @@
static char Version[] = "ACK Modula-2 compiler Version 0.25"; static char Version[] = "ACK Modula-2 compiler Version 0.26";

View file

@ -238,10 +238,13 @@ AddCases(sh, node, lbl)
assert(node->nd_right->nd_class == Value); assert(node->nd_right->nd_class == Value);
node->nd_type = node->nd_left->nd_type; node->nd_type = node->nd_left->nd_type;
for (node->nd_INT = node->nd_left->nd_INT; node->nd_INT = node->nd_left->nd_INT;
node->nd_INT != node->nd_right->nd_INT; for (;;) {
node->nd_INT++) {
if (! AddOneCase(sh, node, lbl)) return 0; if (! AddOneCase(sh, node, lbl)) return 0;
if (node->nd_INT == node->nd_right->nd_INT) {
break;
}
node->nd_INT++;
} }
return 1; return 1;
} }

View file

@ -266,7 +266,7 @@ ChkLinkOrName(expp, flags)
return 0; return 0;
} }
if (!(df = lookup(expp->nd_IDF, left->nd_type->rec_scope, 1, flags))) { if (!(df = lookup(expp->nd_IDF, left->nd_type->rec_scope, D_IMPORTED, flags))) {
id_not_declared(expp); id_not_declared(expp);
return 0; return 0;
} }

View file

@ -14,6 +14,7 @@
#include <alloc.h> #include <alloc.h>
#include <em_arith.h> #include <em_arith.h>
#include <em_label.h> #include <em_label.h>
#include <em_code.h>
#include <assert.h> #include <assert.h>
#include "LLlex.h" #include "LLlex.h"
@ -96,14 +97,9 @@ define(id, scope, kind)
*/ */
register t_def *df; register t_def *df;
df = lookup(id, scope, 2, 0); df = lookup(id, scope, D_IMPORT, 0);
if ( /* Already in this scope */ if ( /* Already in this scope */
df df
|| /* A closed scope, and id defined in the pervasive scope */
(
scopeclosed(scope)
&&
(df = lookup(id, PervasiveScope, 2, 0)))
) { ) {
switch(df->df_kind) { switch(df->df_kind) {
case D_INUSE: case D_INUSE:
@ -265,7 +261,7 @@ DeclProc(type, id)
else { else {
char *name; char *name;
df = lookup(id, CurrentScope, 1, 0); df = lookup(id, CurrentScope, D_IMPORTED, 0);
if (df && df->df_kind == D_PROCHEAD) { if (df && df->df_kind == D_PROCHEAD) {
/* C_exp already generated when we saw the definition /* C_exp already generated when we saw the definition
in the definition module in the definition module

View file

@ -97,14 +97,14 @@ GetDefinitionModule(id, incr)
t_scope *newsc = CurrentScope; t_scope *newsc = CurrentScope;
level += incr; level += incr;
df = lookup(id, GlobalScope, 1, 0); df = lookup(id, GlobalScope, D_IMPORTED, 0);
if (!df) { if (!df) {
/* Read definition module. Make an exception for SYSTEM. /* Read definition module. Make an exception for SYSTEM.
*/ */
DefId = id; DefId = id;
if (!strcmp(id->id_text, "SYSTEM")) { if (!strcmp(id->id_text, "SYSTEM")) {
do_SYSTEM(); do_SYSTEM();
df = lookup(id, GlobalScope, 1, 0); df = lookup(id, GlobalScope, D_IMPORTED, 0);
} }
else { else {
extern int ForeignFlag; extern int ForeignFlag;
@ -115,7 +115,7 @@ GetDefinitionModule(id, incr)
if (!is_anon_idf(id) && GetFile(id->id_text)) { if (!is_anon_idf(id) && GetFile(id->id_text)) {
DefModule(); DefModule();
df = lookup(id, GlobalScope, 1, 0); df = lookup(id, GlobalScope, D_IMPORTED, 0);
if (level == 1 && if (level == 1 &&
(!df || !(df->df_flags & D_FOREIGN))) { (!df || !(df->df_flags & D_FOREIGN))) {
/* The module is directly imported by /* The module is directly imported by
@ -137,7 +137,7 @@ GetDefinitionModule(id, incr)
} }
} }
else { else {
df = lookup(id, GlobalScope, 1, 0); df = lookup(id, GlobalScope, D_IMPORTED, 0);
newsc->sc_name = id->id_text; newsc->sc_name = id->id_text;
} }
vis = CurrVis; vis = CurrVis;

View file

@ -129,7 +129,7 @@ EnterVarList(Idlist, type, local)
for (; idlist; idlist = idlist->nd_right) { for (; idlist; idlist = idlist->nd_right) {
df = define(idlist->nd_IDF, CurrentScope, D_VARIABLE); df = define(idlist->nd_IDF, CurrentScope, D_VARIABLE);
df->df_type = type; df->df_type = type;
df->df_flags &= ~(D_USED | D_DEFINED); /* df->df_flags &= ~(D_USED | D_DEFINED); */
if (idlist->nd_left) { if (idlist->nd_left) {
/* An address was supplied /* An address was supplied
*/ */
@ -382,7 +382,9 @@ EnterExportList(Idlist, qualified)
scope imports it. scope imports it.
*/ */
df1 = lookup(idlist->nd_IDF, df1 = lookup(idlist->nd_IDF,
enclosing(CurrVis)->sc_scope, 1, 0); enclosing(CurrVis)->sc_scope,
D_IMPORTED,
0);
if (df1) { if (df1) {
/* It was already defined in the enclosing /* It was already defined in the enclosing
scope. There are two legal possibilities, scope. There are two legal possibilities,

View file

@ -20,6 +20,7 @@
#include <system.h> #include <system.h>
#include <em_arith.h> #include <em_arith.h>
#include <em_label.h> #include <em_label.h>
#include <em_code.h>
#include "strict3rd.h" #include "strict3rd.h"
#include "input.h" #include "input.h"

View file

@ -44,6 +44,12 @@ lookup(id, scope, import, flags)
df && df->df_scope != scope; df && df->df_scope != scope;
df1 = df, df = df->df_next) { /* nothing */ } df1 = df, df = df->df_next) { /* nothing */ }
if (! df && import && scopeclosed(scope)) {
for (df = id->id_def, df1 = 0;
df && df->df_scope != PervasiveScope;
df1 = df, df = df->df_next) { /* nothing */ }
}
if (df) { if (df) {
/* Found it /* Found it
*/ */
@ -55,12 +61,9 @@ lookup(id, scope, import, flags)
id->id_def = df; id->id_def = df;
} }
df->df_flags |= flags; df->df_flags |= flags;
if (import) { while (df->df_kind & import) {
while (df->df_kind & D_IMPORTED) { assert(df->imp_def != 0);
if (df->df_kind == D_INUSE && import != 1) break; df = df->imp_def;
assert(df->imp_def != 0);
df = df->imp_def;
}
} }
} }
return df; return df;
@ -79,14 +82,16 @@ lookfor(id, vis, message, flags)
t_def *df; t_def *df;
while (sc) { while (sc) {
df = lookup(id->nd_IDF, sc->sc_scope, 1, flags); df = lookup(id->nd_IDF, sc->sc_scope, D_IMPORTED, flags);
if (df) { if (df) {
if (pass_1 && if (pass_1 && message) {
message && while (vis->sc_scope->sc_level >
sc->sc_scope->sc_level < vis->sc_scope->sc_level && sc->sc_scope->sc_level) {
! scopeclosed(vis->sc_scope)) { define( id->nd_IDF,
define(id->nd_IDF, vis->sc_scope, D_INUSE)-> vis->sc_scope,
imp_def = df; D_INUSE)-> imp_def = df;
vis = nextvisible(vis);
}
} }
return df; return df;
} }

View file

@ -14,6 +14,7 @@
#include <system.h> #include <system.h>
#include <em_arith.h> #include <em_arith.h>
#include <em_label.h> #include <em_label.h>
#include <em_code.h>
#include <alloc.h> #include <alloc.h>
#include "strict3rd.h" #include "strict3rd.h"

View file

@ -49,7 +49,6 @@ open_scope(scopetype)
if (scopetype == OPENSCOPE) { if (scopetype == OPENSCOPE) {
ls->sc_next = ls->sc_encl; ls->sc_next = ls->sc_encl;
} }
else ls->sc_next = PervVis;
CurrVis = ls; CurrVis = ls;
} }

View file

@ -20,6 +20,7 @@
#include <em_arith.h> #include <em_arith.h>
#include <em_label.h> #include <em_label.h>
#include <em_code.h>
#include <em_reg.h> #include <em_reg.h>
#include <alloc.h> #include <alloc.h>
#include <assert.h> #include <assert.h>

View file

@ -623,7 +623,7 @@ type_or_forward(ptp)
register t_node *nd; register t_node *nd;
register t_def *df, *df1; register t_def *df, *df1;
if ((df1 = lookup(dot.TOK_IDF, CurrentScope, 1, D_USED))) { if ((df1 = lookup(dot.TOK_IDF, CurrentScope, D_IMPORTED, D_USED))) {
/* Either a Module or a Type, but in both cases defined /* Either a Module or a Type, but in both cases defined
in this scope, so this is the correct identification in this scope, so this is the correct identification
*/ */