Cleaned up a bit

This commit is contained in:
ceriel 1991-03-13 13:49:56 +00:00
parent 17266fb373
commit 52842cd09a
13 changed files with 112 additions and 177 deletions

View file

@ -76,12 +76,6 @@
*/ */
!File: bigparam.h
#undef PASS_BIG_VAL_AS_VAR 1 /* define when big value parameters must be
passed as addresses
*/
!File: bigresult.h !File: bigresult.h
#define BIG_RESULT_ON_STACK 1 /* define when function results must be #define BIG_RESULT_ON_STACK 1 /* define when function results must be
put on the stack; in this case, caller put on the stack; in this case, caller
@ -99,3 +93,7 @@
#define USE_INSERT 1 /* use C_insertpart mechanism */ #define USE_INSERT 1 /* use C_insertpart mechanism */
!File: uns_arith.h
#define UNSIGNED_ARITH unsigned arith

View file

@ -74,10 +74,10 @@ EXTRA_O =
OBJ = $(COBJ) $(LOBJ) Lpars.o $(EXTRA_O) OBJ = $(COBJ) $(LOBJ) Lpars.o $(EXTRA_O)
GENH = errout.h \ GENH = errout.h \
idfsize.h numsize.h strsize.h target_sizes.h bigparam.h bigresult.h \ idfsize.h numsize.h strsize.h target_sizes.h bigresult.h \
inputtype.h density.h squeeze.h nocross.h nostrict.h \ inputtype.h density.h squeeze.h nocross.h nostrict.h \
def.h debugcst.h type.h Lpars.h node.h desig.h strict3rd.h real.h \ def.h debugcst.h type.h Lpars.h node.h desig.h strict3rd.h real.h \
use_insert.h dbsymtab.h use_insert.h dbsymtab.h uns_arith.h
HFILES =LLlex.h \ HFILES =LLlex.h \
chk_expr.h class.h debug.h f_info.h idf.h \ chk_expr.h class.h debug.h f_info.h idf.h \
input.h main.h misc.h scope.h standards.h tokenname.h \ input.h main.h misc.h scope.h standards.h tokenname.h \
@ -210,7 +210,6 @@ $(CURRDIR)cemain: $(OBJ) #$(CURRDIR)Makefile
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO #AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
LLlex.o: LLlex.h LLlex.o: LLlex.h
LLlex.o: Lpars.h LLlex.o: Lpars.h
LLlex.o: bigparam.h
LLlex.o: class.h LLlex.o: class.h
LLlex.o: dbsymtab.h LLlex.o: dbsymtab.h
LLlex.o: debug.h LLlex.o: debug.h
@ -248,7 +247,6 @@ error.o: warning.h
main.o: LLlex.h main.o: LLlex.h
main.o: Lpars.h main.o: Lpars.h
main.o: SYSTEM.h main.o: SYSTEM.h
main.o: bigparam.h
main.o: dbsymtab.h main.o: dbsymtab.h
main.o: debug.h main.o: debug.h
main.o: debugcst.h main.o: debugcst.h
@ -275,7 +273,6 @@ input.o: f_info.h
input.o: input.h input.o: input.h
input.o: inputtype.h input.o: inputtype.h
type.o: LLlex.h type.o: LLlex.h
type.o: bigparam.h
type.o: chk_expr.h type.o: chk_expr.h
type.o: dbsymtab.h type.o: dbsymtab.h
type.o: debug.h type.o: debug.h
@ -294,7 +291,6 @@ type.o: walk.h
type.o: warning.h type.o: warning.h
def.o: LLlex.h def.o: LLlex.h
def.o: Lpars.h def.o: Lpars.h
def.o: bigparam.h
def.o: dbsymtab.h def.o: dbsymtab.h
def.o: debug.h def.o: debug.h
def.o: debugcst.h def.o: debugcst.h
@ -315,7 +311,6 @@ misc.o: misc.h
misc.o: node.h misc.o: node.h
misc.o: real.h misc.o: real.h
enter.o: LLlex.h enter.o: LLlex.h
enter.o: bigparam.h
enter.o: dbsymtab.h enter.o: dbsymtab.h
enter.o: debug.h enter.o: debug.h
enter.o: debugcst.h enter.o: debugcst.h
@ -332,7 +327,6 @@ enter.o: target_sizes.h
enter.o: type.h enter.o: type.h
defmodule.o: LLlex.h defmodule.o: LLlex.h
defmodule.o: Lpars.h defmodule.o: Lpars.h
defmodule.o: bigparam.h
defmodule.o: dbsymtab.h defmodule.o: dbsymtab.h
defmodule.o: debug.h defmodule.o: debug.h
defmodule.o: debugcst.h defmodule.o: debugcst.h
@ -350,7 +344,6 @@ defmodule.o: scope.h
defmodule.o: target_sizes.h defmodule.o: target_sizes.h
defmodule.o: type.h defmodule.o: type.h
typequiv.o: LLlex.h typequiv.o: LLlex.h
typequiv.o: bigparam.h
typequiv.o: dbsymtab.h typequiv.o: dbsymtab.h
typequiv.o: debug.h typequiv.o: debug.h
typequiv.o: debugcst.h typequiv.o: debugcst.h
@ -365,7 +358,6 @@ typequiv.o: target_sizes.h
typequiv.o: type.h typequiv.o: type.h
typequiv.o: warning.h typequiv.o: warning.h
node.o: LLlex.h node.o: LLlex.h
node.o: bigparam.h
node.o: dbsymtab.h node.o: dbsymtab.h
node.o: debug.h node.o: debug.h
node.o: debugcst.h node.o: debugcst.h
@ -378,7 +370,6 @@ node.o: target_sizes.h
node.o: type.h node.o: type.h
cstoper.o: LLlex.h cstoper.o: LLlex.h
cstoper.o: Lpars.h cstoper.o: Lpars.h
cstoper.o: bigparam.h
cstoper.o: dbsymtab.h cstoper.o: dbsymtab.h
cstoper.o: debug.h cstoper.o: debug.h
cstoper.o: debugcst.h cstoper.o: debugcst.h
@ -389,10 +380,10 @@ cstoper.o: real.h
cstoper.o: standards.h cstoper.o: standards.h
cstoper.o: target_sizes.h cstoper.o: target_sizes.h
cstoper.o: type.h cstoper.o: type.h
cstoper.o: uns_arith.h
cstoper.o: warning.h cstoper.o: warning.h
chk_expr.o: LLlex.h chk_expr.o: LLlex.h
chk_expr.o: Lpars.h chk_expr.o: Lpars.h
chk_expr.o: bigparam.h
chk_expr.o: chk_expr.h chk_expr.o: chk_expr.h
chk_expr.o: dbsymtab.h chk_expr.o: dbsymtab.h
chk_expr.o: debug.h chk_expr.o: debug.h
@ -411,7 +402,6 @@ chk_expr.o: strict3rd.h
chk_expr.o: target_sizes.h chk_expr.o: target_sizes.h
chk_expr.o: type.h chk_expr.o: type.h
chk_expr.o: warning.h chk_expr.o: warning.h
options.o: bigparam.h
options.o: class.h options.o: class.h
options.o: dbsymtab.h options.o: dbsymtab.h
options.o: idfsize.h options.o: idfsize.h
@ -425,7 +415,6 @@ options.o: type.h
options.o: warning.h options.o: warning.h
walk.o: LLlex.h walk.o: LLlex.h
walk.o: Lpars.h walk.o: Lpars.h
walk.o: bigparam.h
walk.o: bigresult.h walk.o: bigresult.h
walk.o: chk_expr.h walk.o: chk_expr.h
walk.o: dbsymtab.h walk.o: dbsymtab.h
@ -449,7 +438,6 @@ walk.o: use_insert.h
walk.o: walk.h walk.o: walk.h
walk.o: warning.h walk.o: warning.h
desig.o: LLlex.h desig.o: LLlex.h
desig.o: bigparam.h
desig.o: dbsymtab.h desig.o: dbsymtab.h
desig.o: debug.h desig.o: debug.h
desig.o: debugcst.h desig.o: debugcst.h
@ -466,7 +454,6 @@ desig.o: walk.h
desig.o: warning.h desig.o: warning.h
code.o: LLlex.h code.o: LLlex.h
code.o: Lpars.h code.o: Lpars.h
code.o: bigparam.h
code.o: bigresult.h code.o: bigresult.h
code.o: dbsymtab.h code.o: dbsymtab.h
code.o: debug.h code.o: debug.h
@ -483,7 +470,6 @@ code.o: target_sizes.h
code.o: type.h code.o: type.h
code.o: walk.h code.o: walk.h
lookup.o: LLlex.h lookup.o: LLlex.h
lookup.o: bigparam.h
lookup.o: dbsymtab.h lookup.o: dbsymtab.h
lookup.o: debug.h lookup.o: debug.h
lookup.o: debugcst.h lookup.o: debugcst.h
@ -497,7 +483,6 @@ lookup.o: scope.h
lookup.o: target_sizes.h lookup.o: target_sizes.h
lookup.o: type.h lookup.o: type.h
stab.o: LLlex.h stab.o: LLlex.h
stab.o: bigparam.h
stab.o: dbsymtab.h stab.o: dbsymtab.h
stab.o: def.h stab.o: def.h
stab.o: idf.h stab.o: idf.h
@ -510,7 +495,6 @@ stab.o: type.h
tokenfile.o: Lpars.h tokenfile.o: Lpars.h
program.o: LLlex.h program.o: LLlex.h
program.o: Lpars.h program.o: Lpars.h
program.o: bigparam.h
program.o: dbsymtab.h program.o: dbsymtab.h
program.o: debug.h program.o: debug.h
program.o: debugcst.h program.o: debugcst.h
@ -529,7 +513,6 @@ program.o: type.h
program.o: warning.h program.o: warning.h
declar.o: LLlex.h declar.o: LLlex.h
declar.o: Lpars.h declar.o: Lpars.h
declar.o: bigparam.h
declar.o: chk_expr.h declar.o: chk_expr.h
declar.o: dbsymtab.h declar.o: dbsymtab.h
declar.o: debug.h declar.o: debug.h
@ -549,7 +532,6 @@ declar.o: type.h
declar.o: warning.h declar.o: warning.h
expression.o: LLlex.h expression.o: LLlex.h
expression.o: Lpars.h expression.o: Lpars.h
expression.o: bigparam.h
expression.o: chk_expr.h expression.o: chk_expr.h
expression.o: dbsymtab.h expression.o: dbsymtab.h
expression.o: debug.h expression.o: debug.h
@ -564,7 +546,6 @@ expression.o: type.h
expression.o: warning.h expression.o: warning.h
statement.o: LLlex.h statement.o: LLlex.h
statement.o: Lpars.h statement.o: Lpars.h
statement.o: bigparam.h
statement.o: dbsymtab.h statement.o: dbsymtab.h
statement.o: def.h statement.o: def.h
statement.o: idf.h statement.o: idf.h
@ -579,7 +560,6 @@ char.o: class.h
Lpars.o: Lpars.h Lpars.o: Lpars.h
casestat.o: LLlex.h casestat.o: LLlex.h
casestat.o: Lpars.h casestat.o: Lpars.h
casestat.o: bigparam.h
casestat.o: chk_expr.h casestat.o: chk_expr.h
casestat.o: dbsymtab.h casestat.o: dbsymtab.h
casestat.o: debug.h casestat.o: debug.h
@ -595,7 +575,6 @@ casestat.o: target_sizes.h
casestat.o: type.h casestat.o: type.h
casestat.o: walk.h casestat.o: walk.h
tmpvar.o: LLlex.h tmpvar.o: LLlex.h
tmpvar.o: bigparam.h
tmpvar.o: dbsymtab.h tmpvar.o: dbsymtab.h
tmpvar.o: debug.h tmpvar.o: debug.h
tmpvar.o: debugcst.h tmpvar.o: debugcst.h
@ -607,7 +586,6 @@ tmpvar.o: scope.h
tmpvar.o: target_sizes.h tmpvar.o: target_sizes.h
tmpvar.o: type.h tmpvar.o: type.h
scope.o: LLlex.h scope.o: LLlex.h
scope.o: bigparam.h
scope.o: dbsymtab.h scope.o: dbsymtab.h
scope.o: debug.h scope.o: debug.h
scope.o: debugcst.h scope.o: debugcst.h

View file

@ -76,12 +76,6 @@
*/ */
!File: bigparam.h
#undef PASS_BIG_VAL_AS_VAR 1 /* define when big value parameters must be
passed as addresses
*/
!File: bigresult.h !File: bigresult.h
#define BIG_RESULT_ON_STACK 1 /* define when function results must be #define BIG_RESULT_ON_STACK 1 /* define when function results must be
put on the stack; in this case, caller put on the stack; in this case, caller
@ -98,3 +92,7 @@
#undef USE_INSERT 1 /* use C_insertpart mechanism */ #undef USE_INSERT 1 /* use C_insertpart mechanism */
!File: uns_arith.h
#define UNSIGNED_ARITH unsigned arith

View file

@ -1245,8 +1245,8 @@ ChkStandard(expp)
case S_ORD: case S_ORD:
if (! (left = getarg(&arg, T_NOSUB, 0, edf))) return 0; if (! (left = getarg(&arg, T_NOSUB, 0, edf))) return 0;
exp->nd_type = card_type; exp->nd_type = card_type;
if (arg->nd_LEFT->nd_class == Value) { if (left->nd_class == Value) {
arg->nd_LEFT->nd_type = card_type; left->nd_type = card_type;
free_it = 1; free_it = 1;
} }
break; break;
@ -1309,11 +1309,11 @@ ChkStandard(expp)
#endif #endif
#ifndef STRICT_3RD_ED #ifndef STRICT_3RD_ED
if (! options['3'] && edf->df_value.df_stdname == S_TSIZE) { if (! options['3'] && edf->df_value.df_stdname == S_TSIZE) {
if (arg->nd_RIGHT) { if (left = arg->nd_RIGHT) {
node_warning(arg->nd_RIGHT, node_warning(left,
W_OLDFASHIONED, W_OLDFASHIONED,
"TSIZE with multiple parameters, only first parameter used"); "TSIZE with multiple parameters, only first parameter used");
FreeNode(arg->nd_RIGHT); FreeNode(left);
arg->nd_RIGHT = 0; arg->nd_RIGHT = 0;
} }
} }

View file

@ -417,7 +417,7 @@ CodeParameters(param, arg)
} }
c_loc(0); c_loc(0);
} }
if (IsConformantArray(tp) || IsVarParam(param) || IsBigParamTp(tp)) { if (IsConformantArray(tp) || IsVarParam(param)) {
if (arg->nd_symb == STRING) { if (arg->nd_symb == STRING) {
CodeString(arg); CodeString(arg);
} }

View file

@ -11,6 +11,7 @@
#include "debug.h" #include "debug.h"
#include "target_sizes.h" #include "target_sizes.h"
#include "uns_arith.h"
#include <em_arith.h> #include <em_arith.h>
#include <em_label.h> #include <em_label.h>
@ -58,13 +59,14 @@ underflow(expp)
STATIC STATIC
commonbin(expp) commonbin(expp)
register t_node **expp; t_node **expp;
{ {
register t_type *tp = (*expp)->nd_type; register t_node *exp = *expp;
register t_node *right = (*expp)->nd_RIGHT; t_type *tp = exp->nd_type;
register t_node *right = exp->nd_RIGHT;
(*expp)->nd_RIGHT = 0; exp->nd_RIGHT = 0;
FreeNode(*expp); FreeNode(exp);
*expp = right; *expp = right;
right->nd_type = tp; right->nd_type = tp;
} }
@ -86,7 +88,8 @@ cstunary(expp)
*/ */
case '-': case '-':
if (o1 == min_int[(int)(right->nd_type->tp_size)]) { if (! options['s'] &&
o1 == min_int[(int)(right->nd_type->tp_size)]) {
overflow(exp); overflow(exp);
} }
o1 = -o1; o1 = -o1;
@ -116,6 +119,7 @@ divide(pdiv, prem)
register arith o1 = *pdiv; register arith o1 = *pdiv;
register arith o2 = *prem; register arith o2 = *prem;
#ifndef UNSIGNED_ARITH
/* this is more of a problem than you might /* this is more of a problem than you might
think on C compilers which do not have think on C compilers which do not have
unsigned long. unsigned long.
@ -154,6 +158,10 @@ divide(pdiv, prem)
*prem -= o2; *prem -= o2;
} }
} }
#else
*pdiv = (UNSIGNED_ARITH) o1 / (UNSIGNED_ARITH) o2;
*prem = (UNSIGNED_ARITH) o1 % (UNSIGNED_ARITH) o2;
#endif
} }
cstibin(expp) cstibin(expp)
@ -191,31 +199,22 @@ cstibin(expp)
break; break;
case DIV: case DIV:
if (o2 == 0) {
node_error(exp, "division by 0");
return;
}
if ((o1 < 0) != (o2 < 0)) {
if (o1 < 0) o1 = -o1;
else o2 = -o2;
o1 = -((o1+o2-1)/o2);
}
else {
o1 /= o2;
}
break;
case MOD: case MOD:
if (o2 == 0) { if (o2 == 0) {
node_error(exp, "modulo by 0"); node_error(exp, exp->nd_symb == DIV ?
"division by 0" :
"modulo by 0");
return; return;
} }
if ((o1 < 0) != (o2 < 0)) { if ((o1 < 0) != (o2 < 0)) {
if (o1 < 0) o1 = -o1; if (o1 < 0) o1 = -o1;
else o2 = -o2; else o2 = -o2;
o1 = ((o1+o2-1)/o2) * o2 - o1; if (exp->nd_symb == DIV) o1 = -((o1+o2-1)/o2);
else o1 = ((o1+o2-1)/o2) * o2 - o1;
} }
else { else {
o1 %= o2; if (exp->nd_symb == DIV) o1 /= o2;
else o1 %= o2;
} }
break; break;
@ -496,13 +495,14 @@ cstset(expp)
assert(exp->nd_LEFT->nd_class == Value); assert(exp->nd_LEFT->nd_class == Value);
exp->nd_LEFT->nd_INT -= exp->nd_RIGHT->nd_type->set_low; exp->nd_LEFT->nd_INT -= exp->nd_RIGHT->nd_type->set_low;
i = exp->nd_LEFT->nd_INT; exp = exp->nd_LEFT;
i = exp->nd_INT;
/* Careful here; use exp->nd_LEFT->nd_INT to see if /* Careful here; use exp->nd_LEFT->nd_INT to see if
it falls in the range of the set. Do not use i it falls in the range of the set. Do not use i
for this, as i may be truncated. for this, as i may be truncated.
*/ */
i = (exp->nd_LEFT->nd_INT >= 0 && i = (exp->nd_INT >= 0 &&
exp->nd_LEFT->nd_INT < setsize * wrd_bits && exp->nd_INT < setsize * wrd_bits &&
(set2[i / wrd_bits] & (1 << (i % wrd_bits)))); (set2[i / wrd_bits] & (1 << (i % wrd_bits))));
FreeSet(set2); FreeSet(set2);
exp = getnode(Value); exp = getnode(Value);
@ -607,7 +607,8 @@ cstcall(expp, call)
switch(call) { switch(call) {
case S_ABS: case S_ABS:
if (expr->nd_INT < 0) { if (expr->nd_INT < 0) {
if (expr->nd_INT <= min_int[(int)(tp->tp_size)]) { if (! options['s'] &&
expr->nd_INT <= min_int[(int)(tp->tp_size)]) {
overflow(expr); overflow(expr);
} }
expr->nd_INT = - expr->nd_INT; expr->nd_INT = - expr->nd_INT;

View file

@ -584,7 +584,6 @@ CodeVarDesig(df, ds)
*/ */
C_lxa((arith) difflevel); C_lxa((arith) difflevel);
if ((df->df_flags & D_VARPAR) || if ((df->df_flags & D_VARPAR) ||
IsBigParamTp(df->df_type) ||
IsConformantArray(df->df_type)) { IsConformantArray(df->df_type)) {
/* var parameter, big parameter, /* var parameter, big parameter,
or conformant array. or conformant array.
@ -606,7 +605,6 @@ CodeVarDesig(df, ds)
/* Now, finally, we have a local variable or a local parameter /* Now, finally, we have a local variable or a local parameter
*/ */
if ((df->df_flags & D_VARPAR) || if ((df->df_flags & D_VARPAR) ||
((df->df_flags & D_VALPAR) && IsBigParamTp(df->df_type)) ||
IsConformantArray(df->df_type)) { IsConformantArray(df->df_type)) {
/* a var parameter; address directly accessible. /* a var parameter; address directly accessible.
*/ */

View file

@ -234,7 +234,7 @@ EnterParamList(ppr, Idlist, type, VARp, off)
type->arr_high = *off + pointer_size + word_size; type->arr_high = *off + pointer_size + word_size;
*off += pointer_size + word_size + dword_size; *off += pointer_size + word_size + dword_size;
} }
else if (VARp == D_VARPAR || IsBigParamTp(type)) { else if (VARp == D_VARPAR) {
*off += pointer_size; *off += pointer_size;
} }
else { else {

View file

@ -95,22 +95,6 @@ dot2leaf(class)
return MkLeaf(class, &dot); return MkLeaf(class, &dot);
} }
FreeLR(nd)
register t_node *nd;
{
switch(nsubnodes[nd->nd_class]) {
case 2:
FreeNode(nd->nd_LEFT);
FreeNode(nd->nd_RIGHT);
nd->nd_LEFT = nd->nd_RIGHT = 0;
break;
case 1:
FreeNode(nd->nd_NEXT);
nd->nd_NEXT = 0;
break;
}
}
FreeNode(nd) FreeNode(nd)
register t_node *nd; register t_node *nd;
{ {
@ -118,7 +102,15 @@ FreeNode(nd)
list list
*/ */
if (!nd) return; if (!nd) return;
FreeLR(nd); switch(nsubnodes[nd->nd_class]) {
case 2:
FreeNode(nd->nd_LEFT);
FreeNode(nd->nd_RIGHT);
break;
case 1:
FreeNode(nd->nd_NEXT);
break;
}
free_node(nd); free_node(nd);
} }

View file

@ -123,16 +123,16 @@ import(int local;)
} }
else df = GetDefinitionModule(dot.TOK_IDF, 1); else df = GetDefinitionModule(dot.TOK_IDF, 1);
} }
IMPORT IdentList(&ImportList) ';' ]?
{ EnterFromImportList(ImportList, df, FromId); } IMPORT IdentList(&ImportList) ';'
| { if (FromId) {
IMPORT IdentList(&ImportList) ';' EnterFromImportList(ImportList, df, FromId);
{ EnterImportList(ImportList, }
local, else {
enclosing(CurrVis)->sc_scope); EnterImportList(ImportList,
} local,
] enclosing(CurrVis)->sc_scope);
{ }
FreeNode(ImportList); FreeNode(ImportList);
} }
; ;

View file

@ -78,7 +78,11 @@ statement(register t_node **pnd;)
| |
ForStatement(pnd) ForStatement(pnd)
| |
WithStatement(pnd) WITH { *pnd = nd = dot2leaf(Stat); }
designator(&(nd->nd_LEFT))
DO
StatementSequence(&(nd->nd_RIGHT))
END
| |
EXIT EXIT
{ if (!loopcount) error("EXIT not in a LOOP"); { if (!loopcount) error("EXIT not in a LOOP");
@ -247,7 +251,6 @@ LoopStatement(t_node **pnd;):
StatementSequence(&((*pnd)->nd_RIGHT)) StatementSequence(&((*pnd)->nd_RIGHT))
END END
; ;
*/
WithStatement(t_node **pnd;) WithStatement(t_node **pnd;)
{ {
@ -259,6 +262,7 @@ WithStatement(t_node **pnd;)
StatementSequence(&(nd->nd_RIGHT)) StatementSequence(&(nd->nd_RIGHT))
END END
; ;
*/
ReturnStatement(t_node **pnd;) ReturnStatement(t_node **pnd;)
{ {

View file

@ -238,13 +238,6 @@ extern t_type
#define IsConstructed(tpx) ((tpx)->tp_fund & T_CONSTRUCTED) #define IsConstructed(tpx) ((tpx)->tp_fund & T_CONSTRUCTED)
#define TooBigForReturnArea(tpx) ((tpx)->tp_size > ret_area_size) #define TooBigForReturnArea(tpx) ((tpx)->tp_size > ret_area_size)
#include "bigparam.h"
#ifdef PASS_BIG_VAL_AS_VAR
#define IsBigParamTp(tpx) ((tpx)->tp_size > double_size)
#else
#define IsBigParamTp(tpx) (0)
#endif PASS_BIG_VAL_AS_VAR
extern arith full_mask[]; extern arith full_mask[];
extern arith max_int[]; extern arith max_int[];
extern arith min_int[]; extern arith min_int[];

View file

@ -124,7 +124,11 @@ DoLineno(nd)
{ {
/* Generate line number information, if necessary. /* Generate line number information, if necessary.
*/ */
if ((! options['L'] || options['g']) && if ((! options['L']
#ifdef DBSYMTAB
|| options['g']
#endif /* DBSYMTAB */
) &&
nd->nd_lineno && nd->nd_lineno &&
nd->nd_lineno != oldlineno) { nd->nd_lineno != oldlineno) {
oldlineno = nd->nd_lineno; oldlineno = nd->nd_lineno;
@ -255,9 +259,9 @@ WalkProcedure(procedure)
local definitions, checking and generating code. local definitions, checking and generating code.
*/ */
t_scopelist *savevis = CurrVis; t_scopelist *savevis = CurrVis;
register t_scope *procscope = procedure->prc_vis->sc_scope;
register t_type *tp; register t_type *tp;
register t_param *param; register t_param *param;
register t_scope *procscope = procedure->prc_vis->sc_scope;
label too_big = 0; /* returnsize larger than returnarea */ label too_big = 0; /* returnsize larger than returnarea */
arith StackAdjustment = 0; /* space for conformant arrays */ arith StackAdjustment = 0; /* space for conformant arrays */
arith retsav = 0; /* temporary space for return value */ arith retsav = 0; /* temporary space for return value */
@ -310,7 +314,7 @@ WalkProcedure(procedure)
#ifdef USE_INSERT #ifdef USE_INSERT
C_insertpart(partno2); /* procedure header */ C_insertpart(partno2); /* procedure header */
#else #else
C_pro_narg(procscope->sc_name); C_pro_narg(procedure->prc_name);
#ifdef DBSYMTAB #ifdef DBSYMTAB
if (options['g']) { if (options['g']) {
C_ms_std((char *) 0, N_LBRAC, proclevel); C_ms_std((char *) 0, N_LBRAC, proclevel);
@ -383,67 +387,43 @@ WalkProcedure(procedure)
C_lol(param->par_def->var_off); C_lol(param->par_def->var_off);
STL(param->par_def->var_off, STL(param->par_def->var_off,
tp->tp_size); tp->tp_size);
continue;
}
if (IsBigParamTp(tp) &&
(param->par_def->df_flags & D_DEFINED)){
/* Value parameter changed in body.
Make a copy
*/
arith tmp = TmpSpace(tp->tp_size,
tp->tp_align);
LOL(param->par_def->var_off,
pointer_size);
C_lal(tmp);
CodeConst(WA(tp->tp_size),
(int)pointer_size);
C_bls(pointer_size);
C_lal(tmp);
STL(param->par_def->var_off,
pointer_size);
} }
continue; continue;
} }
#ifdef PASS_BIG_VAL_AS_VAR /* Here, we have to make a copy of the
if (param->par_def->df_flags & D_DEFINED) array. We must also remember how much
#endif room is reserved for copies, because
{ we have to adjust the stack pointer before
/* Here, we have to make a copy of the a RET is done. This is even more complicated
array. We must also remember how much when the procedure returns a value.
room is reserved for copies, because Then, the value must be saved,
we have to adjust the stack pointer before the stack adjusted, the return value pushed
a RET is done. This is even more complicated again, and then RET
when the procedure returns a value. */
Then, the value must be saved, if (! StackAdjustment) {
the stack adjusted, the return value pushed /* First time we get here
again, and then RET
*/ */
if (! StackAdjustment) { if (func_type && !too_big) {
/* First time we get here /* Some local space, only
needed if the value itself
is returned
*/ */
if (func_type && !too_big) { retsav= TmpSpace(func_res_size, 1);
/* Some local space, only
needed if the value itself
is returned
*/
retsav= TmpSpace(func_res_size,
1);
}
StackAdjustment = NewPtr();
C_lor((arith) 1);
STL(StackAdjustment, pointer_size);
} }
/* First compute new stackpointer */ StackAdjustment = NewPtr();
C_lal(param->par_def->var_off); C_lor((arith) 1);
CAL("new_stackptr", (int)pointer_size); STL(StackAdjustment, pointer_size);
C_lfr(pointer_size);
C_ass(pointer_size);
/* adjusted stack pointer */
LOL(param->par_def->var_off, pointer_size);
/* push source address */
CAL("copy_array", (int)pointer_size);
/* copy */
} }
/* First compute new stackpointer */
C_lal(param->par_def->var_off);
CAL("new_stackptr", (int)pointer_size);
C_lfr(pointer_size);
C_ass(pointer_size);
/* adjusted stack pointer */
LOL(param->par_def->var_off, pointer_size);
/* push source address */
CAL("copy_array", (int)pointer_size);
/* copy */
} }
} }
#ifdef USE_INSERT #ifdef USE_INSERT
@ -494,7 +474,7 @@ WalkProcedure(procedure)
C_ret(func_res_size); C_ret(func_res_size);
#ifdef USE_INSERT #ifdef USE_INSERT
C_beginpart(partno2); C_beginpart(partno2);
C_pro(procscope->sc_name, -procscope->sc_off); C_pro(procedure->prc_name, -procscope->sc_off);
#ifdef DBSYMTAB #ifdef DBSYMTAB
if (options['g']) { if (options['g']) {
C_ms_std((char *) 0, N_LBRAC, proclevel); C_ms_std((char *) 0, N_LBRAC, proclevel);
@ -749,11 +729,12 @@ WalkStat(nd, exit_label, end_reached)
loopid->nd_def->df_flags |= D_FORLOOP; loopid->nd_def->df_flags |= D_FORLOOP;
def_ilb(l1); def_ilb(l1);
if (! options['R']) { if (! options['R']) {
label x = ++text_label;
ForLoopVarExpr(loopid); ForLoopVarExpr(loopid);
C_stl(tmp2); C_stl(tmp2);
end_reached |= WalkNode(right->nd_RIGHT, exit_label, end_reached); }
end_reached |= WalkNode(right->nd_RIGHT, exit_label, end_reached);
if (! options['R']) {
label x = ++text_label;
C_lol(tmp2); C_lol(tmp2);
ForLoopVarExpr(loopid); ForLoopVarExpr(loopid);
C_beq(x); C_beq(x);
@ -761,7 +742,6 @@ WalkStat(nd, exit_label, end_reached)
C_trp(); C_trp();
def_ilb(x); def_ilb(x);
} }
else end_reached |= WalkNode(right->nd_RIGHT, exit_label, end_reached);
loopid->nd_def->df_flags &= ~D_FORLOOP; loopid->nd_def->df_flags &= ~D_FORLOOP;
FreeInt(tmp2); FreeInt(tmp2);
if (stepsize) { if (stepsize) {
@ -1103,13 +1083,6 @@ UseWarnings(df)
case D_VARPAR: case D_VARPAR:
df_warning(nd, df,"never used/assigned"); df_warning(nd, df,"never used/assigned");
break; break;
case D_USED|D_VARPAR:
#ifdef PASS_BIG_VAL_AS_VAR
if (df->df_type->tp_fund != T_EQUAL) {
df_warning(nd, df,"never assigned, could be value parameter");
}
#endif
break;
case D_USED: case D_USED:
df_warning(nd, df,"never assigned"); df_warning(nd, df,"never assigned");
break; break;