delinted somewhat

This commit is contained in:
ceriel 1988-10-13 15:43:23 +00:00
parent c08c3e5cf6
commit ce0ec1c143
8 changed files with 50 additions and 51 deletions

View file

@ -400,7 +400,7 @@ again:
*/ */
enum statetp {Oct,OptHex,Hex,Dec,OctEndOrHex,End,OptReal,Real}; enum statetp {Oct,OptHex,Hex,Dec,OctEndOrHex,End,OptReal,Real};
register enum statetp state; register enum statetp state;
register int base; register int base = 8;
register char *np = &buf[1]; register char *np = &buf[1];
/* allow a '-' to be added */ /* allow a '-' to be added */
@ -416,7 +416,6 @@ again:
LoadChar(ch); LoadChar(ch);
} }
if (ch == 'B' || ch == 'C') { if (ch == 'B' || ch == 'C') {
base = 8;
state = OctEndOrHex; state = OctEndOrHex;
break; break;
} }
@ -480,7 +479,6 @@ again:
UnloadChar(ch); UnloadChar(ch);
ch = *--np; ch = *--np;
*np++ = '\0'; *np++ = '\0';
base = 8;
/* Fall through */ /* Fall through */
case End: { case End: {

View file

@ -10,6 +10,7 @@ MKDEP = $(EMHOME)/bin/mkdep
PRID = $(EMHOME)/bin/prid PRID = $(EMHOME)/bin/prid
CID = $(EMHOME)/bin/cid CID = $(EMHOME)/bin/cid
CURRDIR = . CURRDIR = .
LINT = lint
INCLUDES = -I$(MHDIR) -I$(EMHOME)/h -I$(PKGDIR) INCLUDES = -I$(MHDIR) -I$(EMHOME)/h -I$(PKGDIR)
OLIBS = $(LIBDIR)/libem_mes.a $(OBJECTCODE) $(LIBDIR)/libinput.a $(LIBDIR)/libassert.a $(LIBDIR)/liballoc.a $(MALLOC) $(LIBDIR)/libprint.a $(LIBDIR)/libstring.a $(LIBDIR)/libsystem.a OLIBS = $(LIBDIR)/libem_mes.a $(OBJECTCODE) $(LIBDIR)/libinput.a $(LIBDIR)/libassert.a $(LIBDIR)/liballoc.a $(MALLOC) $(LIBDIR)/libprint.a $(LIBDIR)/libstring.a $(LIBDIR)/libsystem.a
@ -20,7 +21,8 @@ GFILES =$(GENGFILES) $(GF)
LLGENOPTIONS = -v LLGENOPTIONS = -v
PROFILE = PROFILE =
COPTIONS= COPTIONS=
CFLAGS = $(PROFILE) $(INCLUDES) $(COPTIONS) -O -DSTATIC= OPTIM=-O
CFLAGS = $(PROFILE) $(INCLUDES) $(COPTIONS) $(OPTIM) -DSTATIC=
LINTFLAGS = -DSTATIC= -DNORCSID LINTFLAGS = -DSTATIC= -DNORCSID
MALLOC = $(LIBDIR)/malloc.o MALLOC = $(LIBDIR)/malloc.o
LDFLAGS = -i $(PROFILE) LDFLAGS = -i $(PROFILE)
@ -153,7 +155,7 @@ depend: Cfiles
#INCLINCLINCLINCL #INCLINCLINCLINCL
Xlint: Xlint:
lint $(INCLUDES) $(LINTFLAGS) $(SRC) \ $(LINT) $(INCLUDES) $(LINTFLAGS) $(SRC) \
$(LIBDIR)/llib-lem_mes.ln \ $(LIBDIR)/llib-lem_mes.ln \
$(LIBDIR)/llib-lemk.ln \ $(LIBDIR)/llib-lemk.ln \
$(LIBDIR)/llib-linput.ln \ $(LIBDIR)/llib-linput.ln \

View file

@ -480,7 +480,7 @@ CodeStd(nd)
{ {
register t_node *arg = nd->nd_right; register t_node *arg = nd->nd_right;
register t_node *left = 0; register t_node *left = 0;
register t_type *tp; register t_type *tp = 0;
int std = nd->nd_left->nd_def->df_value.df_stdname; int std = nd->nd_left->nd_def->df_value.df_stdname;
if (arg) { if (arg) {
@ -863,12 +863,10 @@ CodeOper(expr, true_label, false_label)
break; break;
case OR: case OR:
case AND: { case AND: {
label l_maybe = ++text_label, l_end; label l_maybe = ++text_label, l_end = NO_LABEL;
t_desig *Des = new_desig(); t_desig *Des = new_desig();
int genlabels = 0;
if (true_label == NO_LABEL) { if (true_label == NO_LABEL) {
genlabels = 1;
true_label = ++text_label; true_label = ++text_label;
false_label = ++text_label; false_label = ++text_label;
l_end = ++text_label; l_end = ++text_label;
@ -881,7 +879,7 @@ CodeOper(expr, true_label, false_label)
def_ilb(l_maybe); def_ilb(l_maybe);
clear((char *) Des, sizeof(t_desig)); clear((char *) Des, sizeof(t_desig));
CodeExpr(rightop, Des, true_label, false_label); CodeExpr(rightop, Des, true_label, false_label);
if (genlabels) { if (l_end != NO_LABEL) {
def_ilb(true_label); def_ilb(true_label);
c_loc(1); c_loc(1);
C_bra(l_end); C_bra(l_end);

View file

@ -68,7 +68,7 @@ cstunary(expp)
expression below it, and the result restored in expp. expression below it, and the result restored in expp.
*/ */
register t_node *right = expp->nd_right; register t_node *right = expp->nd_right;
arith o1; arith o1 = right->nd_INT;
switch(expp->nd_symb) { switch(expp->nd_symb) {
/* Should not get here /* Should not get here
@ -77,15 +77,15 @@ cstunary(expp)
*/ */
case '-': case '-':
if (right->nd_INT == min_int[(int)(right->nd_type->tp_size)]) if (o1 == min_int[(int)(right->nd_type->tp_size)])
overflow(expp); overflow(expp);
o1 = -right->nd_INT; o1 = -o1;
break; break;
case NOT: case NOT:
case '~': case '~':
o1 = !right->nd_INT; o1 = !o1;
break; break;
default: default:

View file

@ -27,6 +27,8 @@
#include "Lpars.h" #include "Lpars.h"
#include "warning.h" #include "warning.h"
extern char *sprint();
STATIC STATIC
internal(c) internal(c)
register char *c; register char *c;
@ -254,7 +256,6 @@ DeclProc(type, id)
*/ */
register t_def *df; register t_def *df;
register t_scope *scope; register t_scope *scope;
extern char *sprint();
static int nmcount; static int nmcount;
char buf[256]; char buf[256];
@ -338,7 +339,6 @@ DefineLocalModule(id)
register t_scope *sc; register t_scope *sc;
static int modulecount = 0; static int modulecount = 0;
char buf[256]; char buf[256];
extern char *sprint();
extern int proclevel; extern int proclevel;
sprint(buf, "_%d%s_", ++modulecount, id->id_text); sprint(buf, "_%d%s_", ++modulecount, id->id_text);

View file

@ -105,6 +105,7 @@ GetDefinitionModule(id, incr)
ForeignFlag = 0; ForeignFlag = 0;
DefId = id; DefId = id;
open_scope(CLOSEDSCOPE); open_scope(CLOSEDSCOPE);
vis = CurrVis;
if (!strcmp(id->id_text, "SYSTEM")) { if (!strcmp(id->id_text, "SYSTEM")) {
do_SYSTEM(); do_SYSTEM();
df = lookup(id, GlobalScope, D_IMPORTED, 0); df = lookup(id, GlobalScope, D_IMPORTED, 0);
@ -138,7 +139,6 @@ GetDefinitionModule(id, incr)
df = lookup(id, GlobalScope, D_IMPORTED, 0); df = lookup(id, GlobalScope, D_IMPORTED, 0);
newsc->sc_name = id->id_text; newsc->sc_name = id->id_text;
} }
vis = CurrVis;
} }
close_scope(SC_CHKFORW); close_scope(SC_CHKFORW);
if (! df) { if (! df) {

View file

@ -27,6 +27,8 @@
#include "f_info.h" #include "f_info.h"
#include "warning.h" #include "warning.h"
extern t_def *GetDefinitionModule();
} }
/* /*
The grammar as given by Wirth is already almost LL(1); the The grammar as given by Wirth is already almost LL(1); the
@ -95,8 +97,13 @@ import(int local;)
t_node *ImportList; t_node *ImportList;
register t_node *FromId = 0; register t_node *FromId = 0;
register t_def *df; register t_def *df;
extern t_def *GetDefinitionModule();
} : } :
/*
When parsing a global module, this is the place where we must
read already compiled definition modules.
If the FROM clause is present, the identifier in it is a module
name, otherwise the names in the import list are module names.
*/
[ FROM [ FROM
IDENT { FromId = dot2leaf(Name); IDENT { FromId = dot2leaf(Name);
if (local) { if (local) {
@ -104,21 +111,16 @@ import(int local;)
} }
else df = GetDefinitionModule(dot.TOK_IDF, 1); else df = GetDefinitionModule(dot.TOK_IDF, 1);
} }
|
]
IMPORT IdentList(&ImportList) ';' IMPORT IdentList(&ImportList) ';'
/* { EnterFromImportList(ImportList, df, FromId); }
When parsing a global module, this is the place where we must |
read already compiled definition modules. IMPORT IdentList(&ImportList) ';'
If the FROM clause is present, the identifier in it is a module { EnterImportList(ImportList,
name, otherwise the names in the import list are module names.
*/
{ if (FromId) {
EnterFromImportList(ImportList, df, FromId);
}
else EnterImportList(ImportList,
local, local,
enclosing(CurrVis)->sc_scope); enclosing(CurrVis)->sc_scope);
}
]
{
FreeNode(ImportList); FreeNode(ImportList);
} }
; ;
@ -207,7 +209,6 @@ definition
ProgramModule ProgramModule
{ {
extern t_def *GetDefinitionModule();
register t_def *df; register t_def *df;
} : } :
MODULE MODULE

View file

@ -366,7 +366,7 @@ WalkProcedure(procedure)
WalkDefList(procscope->sc_def, UseWarnings); WalkDefList(procscope->sc_def, UseWarnings);
} }
static int static
WalkDef(df) WalkDef(df)
register t_def *df; register t_def *df;
{ {
@ -394,7 +394,7 @@ WalkDef(df)
} }
} }
static int static
MkCalls(df) MkCalls(df)
register t_def *df; register t_def *df;
{ {
@ -570,10 +570,8 @@ WalkStat(nd, exit_label)
ForLoopVarExpr(nd); ForLoopVarExpr(nd);
C_stl(tmp2); C_stl(tmp2);
} }
}
WalkNode(right, exit_label); WalkNode(right, exit_label);
nd->nd_def->df_flags &= ~D_FORLOOP; nd->nd_def->df_flags &= ~D_FORLOOP;
if (good_forvar) {
if (tmp2 != 0) { if (tmp2 != 0) {
label x = ++text_label; label x = ++text_label;
C_lol(tmp2); C_lol(tmp2);
@ -598,6 +596,10 @@ WalkStat(nd, exit_label)
CodeDStore(nd); CodeDStore(nd);
} }
} }
else {
WalkNode(right, exit_label);
nd->nd_def->df_flags &= ~D_FORLOOP;
}
C_bra(l1); C_bra(l1);
def_ilb(l2); def_ilb(l2);
FreeInt(tmp); FreeInt(tmp);
@ -830,38 +832,36 @@ DoAssign(left, right)
free_desig(dsr); free_desig(dsr);
} }
static int static
RegisterMessage(df) RegisterMessage(df)
register t_def *df; register t_def *df;
{ {
register t_type *tp; register t_type *tp;
arith sz;
int regtype;
if (df->df_kind == D_VARIABLE) { if (df->df_kind == D_VARIABLE) {
if ( !(df->df_flags & D_NOREG)) { if ( !(df->df_flags & D_NOREG)) {
/* Examine type and size /* Examine type and size
*/ */
regtype = -1;
tp = BaseType(df->df_type); tp = BaseType(df->df_type);
if ((df->df_flags & D_VARPAR) || if ((df->df_flags & D_VARPAR) ||
(tp->tp_fund&(T_POINTER|T_HIDDEN|T_EQUAL))) { (tp->tp_fund&(T_POINTER|T_HIDDEN|T_EQUAL))) {
sz = pointer_size; C_ms_reg(df->var_off,
regtype = reg_pointer; pointer_size,
reg_pointer,
0);
} }
else if (tp->tp_fund & T_NUMERIC) { else if (tp->tp_fund & T_NUMERIC) {
sz = tp->tp_size; C_ms_reg(df->var_off,
regtype = tp->tp_fund == T_REAL ? tp->tp_size,
reg_float : reg_any; tp->tp_fund == T_REAL ?
} reg_float : reg_any,
if (regtype >= 0) { 0);
C_ms_reg(df->var_off, sz, regtype, 0);
} }
} }
} }
} }
static int static
UseWarnings(df) UseWarnings(df)
register t_def *df; register t_def *df;
{ {