From: ceriel Date: Wed, 11 Nov 1987 13:10:08 +0000 (+0000) Subject: Fixed some problems: X-Git-Tag: release-5-5~3733 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=603c65950c2491ad9e3fb582b327ccaf6b38ae5c;p=ack.git 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 --- diff --git a/lang/m2/comp/Makefile b/lang/m2/comp/Makefile index 4c62d252f..92a46abbf 100644 --- a/lang/m2/comp/Makefile +++ b/lang/m2/comp/Makefile @@ -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 diff --git a/lang/m2/comp/Version.c b/lang/m2/comp/Version.c index 1fa3d2ab1..ee822b09b 100644 --- a/lang/m2/comp/Version.c +++ b/lang/m2/comp/Version.c @@ -1 +1 @@ -static char Version[] = "ACK Modula-2 compiler Version 0.25"; +static char Version[] = "ACK Modula-2 compiler Version 0.26"; diff --git a/lang/m2/comp/casestat.C b/lang/m2/comp/casestat.C index ec81d2570..5d163a047 100644 --- a/lang/m2/comp/casestat.C +++ b/lang/m2/comp/casestat.C @@ -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; } diff --git a/lang/m2/comp/chk_expr.c b/lang/m2/comp/chk_expr.c index f21e48f4a..e77b89f67 100644 --- a/lang/m2/comp/chk_expr.c +++ b/lang/m2/comp/chk_expr.c @@ -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; } diff --git a/lang/m2/comp/def.c b/lang/m2/comp/def.c index ba7b6bcab..5f2e8f5db 100644 --- a/lang/m2/comp/def.c +++ b/lang/m2/comp/def.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #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 diff --git a/lang/m2/comp/defmodule.c b/lang/m2/comp/defmodule.c index 5cb99d821..2af9d4300 100644 --- a/lang/m2/comp/defmodule.c +++ b/lang/m2/comp/defmodule.c @@ -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; diff --git a/lang/m2/comp/enter.c b/lang/m2/comp/enter.c index 4afbdccdf..10e47f449 100644 --- a/lang/m2/comp/enter.c +++ b/lang/m2/comp/enter.c @@ -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, diff --git a/lang/m2/comp/error.c b/lang/m2/comp/error.c index 8ec53462c..b6275bd49 100644 --- a/lang/m2/comp/error.c +++ b/lang/m2/comp/error.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "strict3rd.h" #include "input.h" diff --git a/lang/m2/comp/lookup.c b/lang/m2/comp/lookup.c index 8375aacb4..05b7a9c63 100644 --- a/lang/m2/comp/lookup.c +++ b/lang/m2/comp/lookup.c @@ -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; } diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index a7c416786..498d597f6 100644 --- a/lang/m2/comp/main.c +++ b/lang/m2/comp/main.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "strict3rd.h" diff --git a/lang/m2/comp/scope.C b/lang/m2/comp/scope.C index 4e92c4049..6b4a91c82 100644 --- a/lang/m2/comp/scope.C +++ b/lang/m2/comp/scope.C @@ -49,7 +49,6 @@ open_scope(scopetype) if (scopetype == OPENSCOPE) { ls->sc_next = ls->sc_encl; } - else ls->sc_next = PervVis; CurrVis = ls; } diff --git a/lang/m2/comp/tmpvar.C b/lang/m2/comp/tmpvar.C index 8bb65a019..d90104e17 100644 --- a/lang/m2/comp/tmpvar.C +++ b/lang/m2/comp/tmpvar.C @@ -20,6 +20,7 @@ #include #include +#include #include #include #include diff --git a/lang/m2/comp/type.c b/lang/m2/comp/type.c index 2ebf2bf64..d7e896740 100644 --- a/lang/m2/comp/type.c +++ b/lang/m2/comp/type.c @@ -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 */