From: ceriel Date: Thu, 21 Mar 1991 10:45:42 +0000 (+0000) Subject: Some modifications for running on smaller machines X-Git-Tag: release-5-5~1162 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3686d24064780da85c471be42a3279d1630488d2;p=ack.git Some modifications for running on smaller machines --- diff --git a/lang/pc/comp/casestat.C b/lang/pc/comp/casestat.C index ab6a6c9b4..83223c09d 100644 --- a/lang/pc/comp/casestat.C +++ b/lang/pc/comp/casestat.C @@ -93,6 +93,7 @@ CaseEnd(nd, exit_label) CaseCode(nd->nd_lab, ch, exit_label); FreeCh(ch); + FreeNode(nd); } FreeCh(ch) diff --git a/lang/pc/comp/const.h b/lang/pc/comp/const.h index 0e40f064d..45e77bcfc 100644 --- a/lang/pc/comp/const.h +++ b/lang/pc/comp/const.h @@ -2,8 +2,6 @@ extern long mach_long_sign; /* sign bit of the machine long */ -extern int - mach_long_size; /* size of long on this machine == sizeof(long) */ extern arith max_int, /* maximum integer on target machine */ wrd_bits, /* number of bits in a word */ diff --git a/lang/pc/comp/cstoper.c b/lang/pc/comp/cstoper.c index 6ea44324e..a35a32c94 100644 --- a/lang/pc/comp/cstoper.c +++ b/lang/pc/comp/cstoper.c @@ -16,7 +16,6 @@ #include "type.h" long mach_long_sign; /* sign bit of the machine long */ -int mach_long_size; /* size of long on this machine == sizeof(long) */ long full_mask[MAXSIZE+1];/* full_mask[1] == 0xFF, full_mask[2] == 0xFFFF, .. */ arith max_int; /* maximum integer on the target machine */ arith min_int; /* mimimum integer on the target machin */ @@ -459,7 +458,7 @@ CutSize(expr) else if( remainder != 0 && remainder != ~full_mask[size] || (o1 & full_mask[size]) == 1 << (size * 8 - 1) ) { /* integers in [-maxint .. maxint] */ - int nbits = (int) (mach_long_size - size) * 8; + int nbits = (int) (sizeof(long) - size) * 8; /* overflow(expr); */ /* sign bit of o1 in sign bit of mach_long */ @@ -483,15 +482,14 @@ InitCst() fatal("array full_mask too small for this machine"); full_mask[i] = bt; } - mach_long_size = i; - mach_long_sign = 1 << (mach_long_size * 8 - 1); - if( int_size > mach_long_size ) + mach_long_sign = 1L << (sizeof(long) * 8 - 1); + if( int_size > sizeof(long) ) fatal("sizeof (long) insufficient on this machine"); - max_int = full_mask[int_size] & ~(1 << (int_size * 8 - 1)); + max_int = full_mask[int_size] & ~(1L << (int_size * 8 - 1)); min_int = - max_int; maxint_str = long2str(max_int, 10); maxint_str = Salloc(maxint_str, (unsigned int) strlen(maxint_str)); - wrd_bits = 8 * word_size; + wrd_bits = 8 * (int) word_size; if( !max_intset ) max_intset = wrd_bits - 1; } diff --git a/lang/pc/comp/declar.g b/lang/pc/comp/declar.g index a9c5b4f1f..be6bece65 100644 --- a/lang/pc/comp/declar.g +++ b/lang/pc/comp/declar.g @@ -288,7 +288,7 @@ ProcedureDeclaration */ { open_scope(); } ProcedureHeading(&nd, &tp) ';' - { scl = CurrVis; close_scope(); } + { scl = CurrVis; close_scope(0); } [ Directive { DoDirective(dot.TOK_IDF, nd, tp, scl, 0); } @@ -303,7 +303,7 @@ ProcedureDeclaration #ifdef DBSYMTAB if (options['g']) stb_string(df, D_PEND); #endif /* DBSYMTAB */ - close_scope(); + close_scope(1); } ] ; @@ -360,7 +360,7 @@ FunctionDeclaration */ { open_scope(); } FunctionHeading(&nd, &tp) ';' - { scl = CurrVis; close_scope(); } + { scl = CurrVis; close_scope(0); } [ Directive { if( !tp ) { @@ -391,7 +391,7 @@ FunctionDeclaration } /* open_scope() is simulated in DeclFunc() */ - close_scope(); + close_scope(1); } ] ; @@ -553,7 +553,7 @@ RecordType(register struct type **ptp; unsigned short packed;) RECORD { open_scope(); /* scope for fields of record */ scope = CurrentScope; - close_scope(); + close_scope(0); } FieldList(scope, &size, &xalign, packed, &sel) { if( size == 0 ) { diff --git a/lang/pc/comp/scope.c b/lang/pc/comp/scope.c index f96b6ef4c..5bb6aa46f 100644 --- a/lang/pc/comp/scope.c +++ b/lang/pc/comp/scope.c @@ -25,10 +25,8 @@ InitScope() register struct scope *sc = new_scope(); register struct scopelist *ls = new_scopelist(); - sc->sc_def = 0; sc->sc_level = proclevel; PervasiveScope = sc; - ls->next = 0; ls->sc_scope = PervasiveScope; ls->sc_count = ++sccount; CurrVis = ls; @@ -46,13 +44,20 @@ open_scope() CurrVis = ls; } -close_scope() +close_scope(doclean) { /* When this procedure is called, the next visible scope is equal to the statically enclosing scope */ + register struct def *df; assert(CurrentScope != 0); + df = CurrentScope->sc_def; + if (doclean) while (df) { + struct def *next = df->df_nextinscope; + remove_def(df); + df = next; + } CurrVis = CurrVis->next; } diff --git a/lang/pc/comp/statement.g b/lang/pc/comp/statement.g index b6c6a3e86..3c4f6f4bb 100644 --- a/lang/pc/comp/statement.g +++ b/lang/pc/comp/statement.g @@ -89,7 +89,9 @@ SimpleStatement %if( !options['s'] && !strcmp(dot.TOK_IDF->id_text, "assert") ) IDENT { line = LineNumber; } Expression(&expp) - { AssertStat(expp, line); } + { AssertStat(expp, line); + FreeNode(expp); + } | IDENT { pnd = MkLeaf(Name, &dot); } [ %default @@ -233,6 +235,7 @@ IfStatement ds = InitDesig; if( !err_occurred ) CodeExpr(nd, &ds, l1); + FreeNode(nd); } THEN Statement { chk_labels(slevel + 1); } @@ -318,6 +321,7 @@ RepeatStatement ds = InitDesig; if( !err_occurred ) CodeExpr(nd, &ds, repeatlb); + FreeNode(nd); } ; @@ -337,6 +341,7 @@ WhileStatement ds = InitDesig; if( !err_occurred ) CodeExpr(nd, &ds, exitlb); + FreeNode(nd); } DO Statement