Some modifications for running on smaller machines
This commit is contained in:
parent
62bad715c2
commit
3686d24064
|
@ -93,6 +93,7 @@ CaseEnd(nd, exit_label)
|
|||
CaseCode(nd->nd_lab, ch, exit_label);
|
||||
|
||||
FreeCh(ch);
|
||||
FreeNode(nd);
|
||||
}
|
||||
|
||||
FreeCh(ch)
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue