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: main.h
error.o: node.h
error.o: squeeze.h
error.o: nostrict.h
error.o: strict3rd.h
error.o: warning.h
main.o: LLlex.h
@ -221,6 +221,7 @@ type.o: def.h
type.o: idf.h
type.o: nocross.h
type.o: node.h
type.o: nostrict.h
type.o: scope.h
type.o: squeeze.h
type.o: target_sizes.h
@ -316,8 +317,8 @@ chk_expr.o: main.h
chk_expr.o: misc.h
chk_expr.o: nocross.h
chk_expr.o: node.h
chk_expr.o: nostrict.h
chk_expr.o: scope.h
chk_expr.o: squeeze.h
chk_expr.o: standards.h
chk_expr.o: strict3rd.h
chk_expr.o: target_sizes.h
@ -326,7 +327,7 @@ chk_expr.o: warning.h
options.o: idfsize.h
options.o: main.h
options.o: nocross.h
options.o: squeeze.h
options.o: nostrict.h
options.o: strict3rd.h
options.o: target_sizes.h
options.o: type.h
@ -416,8 +417,8 @@ declar.o: main.h
declar.o: misc.h
declar.o: nocross.h
declar.o: node.h
declar.o: nostrict.h
declar.o: scope.h
declar.o: squeeze.h
declar.o: strict3rd.h
declar.o: target_sizes.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);
node->nd_type = node->nd_left->nd_type;
for (node->nd_INT = node->nd_left->nd_INT;
node->nd_INT != node->nd_right->nd_INT;
node->nd_INT++) {
node->nd_INT = node->nd_left->nd_INT;
for (;;) {
if (! AddOneCase(sh, node, lbl)) return 0;
if (node->nd_INT == node->nd_right->nd_INT) {
break;
}
node->nd_INT++;
}
return 1;
}

View file

@ -266,7 +266,7 @@ ChkLinkOrName(expp, flags)
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);
return 0;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -623,7 +623,7 @@ type_or_forward(ptp)
register t_node *nd;
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
in this scope, so this is the correct identification
*/