return;
}
}
- *pnd = nd = MkNode(Uoper, NULLNODE, nd, &(nd->nd_token));
+ *pnd = nd;
+ nd = getnode(Uoper);
nd->nd_symb = COERCION;
nd->nd_type = tp;
+ nd->nd_LEFT = NULLNODE;
+ nd->nd_RIGHT = *pnd;
+ nd->nd_lineno = (*pnd)->nd_lineno;
+ *pnd = nd;
}
int
/* Check a call of a standard procedure or function
*/
register t_node *exp = *expp;
- t_node *arg = exp;
- register t_node *left;
+ t_node *arglink = exp;
+ register t_node *arg;
register t_def *edf = exp->nd_LEFT->nd_def;
int free_it = 0;
int isconstant = 0;
exp->nd_type = error_type;
switch(edf->df_value.df_stdname) {
case S_ABS:
- if (!(left = getarg(&arg, T_NUMERIC, 0, edf))) return 0;
- exp->nd_type = BaseType(left->nd_type);
- MkCoercion(&(arg->nd_LEFT), exp->nd_type);
- left = arg->nd_LEFT;
+ if (!(arg = getarg(&arglink, T_NUMERIC, 0, edf))) return 0;
+ exp->nd_type = BaseType(arg->nd_type);
+ MkCoercion(&(arglink->nd_LEFT), exp->nd_type);
+ arg = arglink->nd_LEFT;
if (! (exp->nd_type->tp_fund & (T_INTEGER|T_REAL))) {
free_it = 1;
}
- if (left->nd_class == Value) {
+ if (arg->nd_class == Value) {
switch(exp->nd_type->tp_fund) {
case T_REAL:
- left->nd_RVAL.flt_sign = 0;
+ arg->nd_RVAL.flt_sign = 0;
free_it = 1;
break;
case T_INTEGER:
case S_CAP:
exp->nd_type = char_type;
- if (!(left = getarg(&arg, T_CHAR, 0, edf))) return 0;
- if (left->nd_class == Value) isconstant = 1;
+ if (!(arg = getarg(&arglink, T_CHAR, 0, edf))) return 0;
+ if (arg->nd_class == Value) isconstant = 1;
break;
case S_FLOATD:
case S_FLOAT:
- if (! getarg(&arg, T_INTORCARD, 0, edf)) return 0;
+ if (! getarg(&arglink, T_INTORCARD, 0, edf)) return 0;
+ arg = arglink;
if (edf->df_value.df_stdname == S_FLOAT) {
MkCoercion(&(arg->nd_LEFT), card_type);
}
t_type *tp;
t_type *s1, *s2, *d1, *d2;
- if (!(left = getarg(&arg, 0, 0, edf))) {
+ if (!(arg = getarg(&arglink, 0, 0, edf))) {
return 0;
}
- tp = BaseType(left->nd_type);
+ tp = BaseType(arg->nd_type);
if (edf->df_value.df_stdname == S_SHORT) {
s1 = longint_type;
}
if (tp == s1) {
- MkCoercion(&(arg->nd_LEFT), d1);
+ MkCoercion(&(arglink->nd_LEFT), d1);
}
else if (tp == s2) {
- MkCoercion(&(arg->nd_LEFT), d2);
+ MkCoercion(&(arglink->nd_LEFT), d2);
}
else {
- df_error(left, "unexpected parameter type", edf);
+ df_error(arg, "unexpected parameter type", edf);
break;
}
free_it = 1;
}
case S_HIGH:
- if (!(left = getarg(&arg, T_ARRAY|T_STRING|T_CHAR, 0, edf))) {
+ if (!(arg = getarg(&arglink, T_ARRAY|T_STRING|T_CHAR, 0, edf))) {
return 0;
}
- if (left->nd_type->tp_fund == T_ARRAY) {
- exp->nd_type = IndexType(left->nd_type);
- if (! IsConformantArray(left->nd_type)) {
- left->nd_type = exp->nd_type;
+ if (arg->nd_type->tp_fund == T_ARRAY) {
+ exp->nd_type = IndexType(arg->nd_type);
+ if (! IsConformantArray(arg->nd_type)) {
+ arg->nd_type = exp->nd_type;
isconstant = 1;
}
break;
}
- if (left->nd_symb != STRING) {
- df_error(left,"array parameter expected", edf);
+ if (arg->nd_symb != STRING) {
+ df_error(arg,"array parameter expected", edf);
return 0;
}
exp = getnode(Value);
exp->nd_type = card_type;
/* Notice that we could disallow HIGH("") here by checking
- that left->nd_type->tp_fund != T_CHAR || left->nd_INT != 0.
+ that arg->nd_type->tp_fund != T_CHAR || arg->nd_INT != 0.
??? For the time being, we don't. !!!
Maybe the empty string should not be allowed at all.
*/
- exp->nd_INT = left->nd_type->tp_fund == T_CHAR ? 0 :
- left->nd_SLE - 1;
+ exp->nd_INT = arg->nd_type->tp_fund == T_CHAR ? 0 :
+ arg->nd_SLE - 1;
exp->nd_symb = INTEGER;
exp->nd_lineno = (*expp)->nd_lineno;
(*expp)->nd_RIGHT = 0;
case S_MAX:
case S_MIN:
- if (!(left = getname(&arg, D_ISTYPE, T_DISCRETE, edf))) {
+ if (!(arg = getname(&arglink, D_ISTYPE, T_DISCRETE, edf))) {
return 0;
}
- exp->nd_type = left->nd_type;
+ exp->nd_type = arg->nd_type;
isconstant = 1;
break;
case S_ODD:
- if (! (left = getarg(&arg, T_INTORCARD, 0, edf))) return 0;
- MkCoercion(&(arg->nd_LEFT), BaseType(left->nd_type));
+ if (! (arg = getarg(&arglink, T_INTORCARD, 0, edf))) return 0;
+ MkCoercion(&(arglink->nd_LEFT), BaseType(arg->nd_type));
exp->nd_type = bool_type;
- if (arg->nd_LEFT->nd_class == Value) isconstant = 1;
+ if (arglink->nd_LEFT->nd_class == Value) isconstant = 1;
break;
case S_ORD:
- if (! (left = getarg(&arg, T_NOSUB, 0, edf))) return 0;
+ if (! (arg = getarg(&arglink, T_NOSUB, 0, edf))) return 0;
exp->nd_type = card_type;
- if (left->nd_class == Value) {
- left->nd_type = card_type;
+ if (arg->nd_class == Value) {
+ arg->nd_type = card_type;
free_it = 1;
}
break;
node_error(exp, "NEW and DISPOSE are obsolete");
}
}
- left = getvariable(&arg, edf, D_USED|D_DEFINED);
exp->nd_type = 0;
- if (! left) return 0;
- if (! (left->nd_type->tp_fund == T_POINTER)) {
- df_error(left, "pointer variable expected", edf);
+ arg = getvariable(&arglink, edf, D_USED|D_DEFINED);
+ if (! arg) return 0;
+ if (! (arg->nd_type->tp_fund == T_POINTER)) {
+ df_error(arg, "pointer variable expected", edf);
return 0;
}
/* Now, make it look like a call to ALLOCATE or DEALLOCATE */
- {
- left = getnode(Value);
-
- left->nd_INT = PointedtoType(arg->nd_LEFT->nd_type)->tp_size;
- left->nd_symb = INTEGER;
- left->nd_lineno = exp->nd_lineno;
- left->nd_type = card_type;
- arg->nd_RIGHT = MkNode(Link, left, NULLNODE, &(left->nd_token));
- arg->nd_RIGHT->nd_symb = ',';
- /* Ignore other arguments to NEW and/or DISPOSE ??? */
-
- FreeNode(exp->nd_LEFT);
- exp->nd_LEFT = left = getnode(Name);
- left->nd_symb = IDENT;
- left->nd_lineno = exp->nd_lineno;
- left->nd_IDF = str2idf(edf->df_value.df_stdname==S_NEW ?
- "ALLOCATE" : "DEALLOCATE", 0);
- }
+ arglink->nd_RIGHT = arg = getnode(Link);
+ arg->nd_lineno = exp->nd_lineno;
+ arg->nd_symb = ',';
+ arg->nd_LEFT = getnode(Value);
+ arg = arg->nd_LEFT;
+ arg->nd_INT = PointedtoType(arglink->nd_LEFT->nd_type)->tp_size;
+ arg->nd_symb = INTEGER;
+ arg->nd_lineno = exp->nd_lineno;
+ arg->nd_type = card_type;
+ /* Ignore other arguments to NEW and/or DISPOSE ??? */
+
+ FreeNode(exp->nd_LEFT);
+ exp->nd_LEFT = arg = getnode(Name);
+ arg->nd_symb = IDENT;
+ arg->nd_lineno = exp->nd_lineno;
+ arg->nd_IDF = str2idf(edf->df_value.df_stdname==S_NEW ?
+ "ALLOCATE" : "DEALLOCATE", 0);
return ChkCall(expp);
#endif
case S_TSIZE: /* ??? */
case S_SIZE:
exp->nd_type = intorcard_type;
- if (!(left = getname(&arg,D_FIELD|D_VARIABLE|D_ISTYPE,0,edf))) {
+ if (!(arg = getname(&arglink,D_FIELD|D_VARIABLE|D_ISTYPE,0,edf))) {
return 0;
}
- if (! IsConformantArray(left->nd_type)) isconstant = 1;
+ if (! IsConformantArray(arg->nd_type)) isconstant = 1;
#ifndef NOSTRICT
else node_warning(exp,
W_STRICT,
"%s on conformant array",
- exp->nd_LEFT->nd_def->df_idf->id_text);
+ edf->df_idf->id_text);
#endif
#ifndef STRICT_3RD_ED
if (! options['3'] && edf->df_value.df_stdname == S_TSIZE) {
- if (left = arg->nd_RIGHT) {
- node_warning(left,
+ if (arg = arglink->nd_RIGHT) {
+ node_warning(arg,
W_OLDFASHIONED,
"TSIZE with multiple parameters, only first parameter used");
- FreeNode(left);
- arg->nd_RIGHT = 0;
+ FreeNode(arg);
+ arglink->nd_RIGHT = 0;
}
}
#endif
case S_TRUNCD:
case S_TRUNC:
- if (! getarg(&arg, T_REAL, 0, edf)) return 0;
- MkCoercion(&(arg->nd_LEFT),
+ if (! getarg(&arglink, T_REAL, 0, edf)) return 0;
+ MkCoercion(&(arglink->nd_LEFT),
edf->df_value.df_stdname == S_TRUNCD ?
longint_type : card_type);
free_it = 1;
break;
case S_VAL:
- if (!(left = getname(&arg, D_ISTYPE, T_NOSUB, edf))) {
+ if (!(arg = getname(&arglink, D_ISTYPE, T_NOSUB, edf))) {
return 0;
}
- exp->nd_type = left->nd_def->df_type;
- exp->nd_RIGHT = arg->nd_RIGHT;
- arg->nd_RIGHT = 0;
- FreeNode(arg);
- arg = exp;
+ exp->nd_type = arg->nd_def->df_type;
+ exp->nd_RIGHT = arglink->nd_RIGHT;
+ arglink->nd_RIGHT = 0;
+ FreeNode(arglink);
+ arglink = exp;
/* fall through */
case S_CHR:
- if (! getarg(&arg, T_CARDINAL, 0, edf)) return 0;
+ if (! getarg(&arglink, T_CARDINAL, 0, edf)) return 0;
if (edf->df_value.df_stdname == S_CHR) {
exp->nd_type = char_type;
}
if (exp->nd_type != int_type) {
- MkCoercion(&(arg->nd_LEFT), exp->nd_type);
+ MkCoercion(&(arglink->nd_LEFT), exp->nd_type);
free_it = 1;
}
break;
case S_ADR:
exp->nd_type = address_type;
- if (! getarg(&arg, 0, 1, edf)) return 0;
+ if (! getarg(&arglink, 0, 1, edf)) return 0;
break;
case S_DEC:
case S_INC:
exp->nd_type = 0;
- if (! (left = getvariable(&arg, edf, D_USED|D_DEFINED))) return 0;
- if (! (left->nd_type->tp_fund & T_DISCRETE)) {
- df_error(left,"illegal parameter type", edf);
+ if (! (arg = getvariable(&arglink, edf, D_USED|D_DEFINED))) return 0;
+ if (! (arg->nd_type->tp_fund & T_DISCRETE)) {
+ df_error(arg,"illegal parameter type", edf);
return 0;
}
- if (arg->nd_RIGHT) {
- if (! getarg(&arg, T_INTORCARD, 0, edf)) return 0;
+ if (arglink->nd_RIGHT) {
+ if (! getarg(&arglink, T_INTORCARD, 0, edf)) return 0;
}
break;
t_node *dummy;
exp->nd_type = 0;
- if (!(left = getvariable(&arg, edf, D_USED|D_DEFINED))) return 0;
- tp = left->nd_type;
+ if (!(arg = getvariable(&arglink, edf, D_USED|D_DEFINED))) return 0;
+ tp = arg->nd_type;
if (tp->tp_fund != T_SET) {
df_error(arg, "SET parameter expected", edf);
return 0;
}
- if (!(dummy = getarg(&arg, 0, 0, edf))) return 0;
+ if (!(dummy = getarg(&arglink, 0, 0, edf))) return 0;
if (!ChkAssCompat(&dummy, ElementType(tp), "EXCL/INCL")) {
/* What type of compatibility do we want here?
apparently assignment compatibility! ??? ???
*/
return 0;
}
- MkCoercion(&(arg->nd_LEFT), word_type);
+ MkCoercion(&(arglink->nd_LEFT), word_type);
break;
}
crash("(ChkStandard)");
}
+ arg = arglink;
+
if (arg->nd_RIGHT) {
df_error(arg->nd_RIGHT, "too many parameters supplied", edf);
return 0;
#include "walk.h"
#include "bigresult.h"
-extern char *long2str();
-extern char *symbol2str();
extern int proclevel;
extern char options[];
extern t_desig null_desig;
}
else {
crash("(CodeConst)");
-/*
- C_df_dlb(++data_label);
- C_rom_icon(long2str((long) cst), (arith) size);
- c_lae_dlb(data_label);
- C_loi((arith) size);
-*/
}
}
}
CodeCoercion(t1, t2)
- register t_type *t1, *t2;
+ t_type *t1, *t2;
{
- register int fund1, fund2;
- arith sz1 = t1->tp_size;
- arith sz2;
+ int fund1, fund2;
+ int sz1 = t1->tp_size;
+ int sz2;
t1 = BaseType(t1);
t2 = BaseType(t2);
case T_ENUMERATION:
case T_CARDINAL:
case T_INTORCARD:
- if ((int) sz1 < (int) word_size) sz1 = word_size;
+ if (sz1 < (int) word_size) sz1 = word_size;
/* fall through */
case T_EQUAL:
case T_POINTER:
switch(fund1) {
case T_INTEGER:
- if ((int) sz1 < (int) word_size) {
- c_loc((int)sz1);
+ if (sz1 < (int) word_size) {
+ c_loc(sz1);
c_loc((int) word_size);
C_cii();
sz1 = word_size;
}
- if (fund2 == T_REAL) {
- c_loc((int)sz1);
- c_loc((int)sz2);
+ c_loc(sz1);
+ c_loc(sz2);
+ switch(fund2) {
+ case T_REAL:
C_cif();
break;
- }
- if ((int) sz2 != (int) sz1) {
- c_loc((int)sz1);
- c_loc((int)sz2);
- switch(fund2) {
- case T_INTEGER:
- C_cii();
- break;
- case T_CARDINAL:
- C_ciu();
- break;
- default:
- crash("Funny integer conversion");
- }
+ case T_INTEGER:
+ C_cii();
+ break;
+ case T_CARDINAL:
+ C_ciu();
+ break;
+ default:
+ crash("Funny integer conversion");
}
break;
case T_CARDINAL:
case T_INTORCARD:
- if (fund2 == T_REAL) {
- c_loc((int)sz1);
- c_loc((int)sz2);
+ c_loc(sz1);
+ c_loc(sz2);
+ switch(fund2) {
+ case T_REAL:
C_cuf();
break;
- }
- if ((int) sz1 != (int) sz2) {
- c_loc((int)sz1);
- c_loc((int)sz2);
- switch(fund2) {
- case T_CARDINAL:
- case T_INTORCARD:
- C_cuu();
- break;
- case T_INTEGER:
- C_cui();
- break;
- default:
- crash("Funny cardinal conversion");
- }
+ case T_CARDINAL:
+ case T_INTORCARD:
+ C_cuu();
+ break;
+ case T_INTEGER:
+ C_cui();
+ break;
+ default:
+ crash("Funny cardinal conversion");
}
break;
case T_REAL:
switch(fund2) {
case T_REAL:
- if ((int) sz1 != (int) sz2) {
- c_loc((int)sz1);
- c_loc((int)sz2);
- C_cff();
- }
+ c_loc(sz1);
+ c_loc(sz2);
+ C_cff();
break;
case T_INTEGER:
- c_loc((int)sz1);
- c_loc((int)sz2);
+ c_loc(sz1);
+ c_loc(sz2);
C_cfi();
break;
case T_CARDINAL:
if (! options['R']) {
label lb = ++text_label;
+ arith asz1 = sz1;
- C_dup(sz1);
- C_zrf(sz1);
- C_cmf(sz1);
+ C_dup(asz1);
+ C_zrf(asz1);
+ C_cmf(asz1);
C_zge(lb);
c_loc(ECONV);
C_trp();
def_ilb(lb);
}
- c_loc((int)sz1);
- c_loc((int)sz2);
+ c_loc(sz1);
+ c_loc(sz2);
C_cfu();
break;
default:
register t_def *df = left->nd_def;
if (df->df_kind == D_CONST) {
+ /* a procedure address */
df = df->con_const.tk_data.tk_def;
}
if (df->df_kind & (D_PROCEDURE|D_PROCHEAD)) {
ARRAY OF (WORD|BYTE)
*/
C_loc(arg_type->arr_elem->tp_size);
- C_mli(word_size);
+ C_mlu(word_size);
if (elem == word_type) {
c_loc((int) word_size - 1);
- C_adi(word_size);
- c_loc((int) word_size);
- C_dvi(word_size);
+ C_adu(word_size);
+ c_loc((int) word_size - 1);
+ C_and(word_size);
}
else {
assert(elem == byte_type);
break;
default:{
arith tmp, TmpSpace();
+ arith sz = WA(arg->nd_type->tp_size);
CodePExpr(arg);
- tmp = TmpSpace(arg->nd_type->tp_size, arg->nd_type->tp_align);
- STL(tmp, WA(arg->nd_type->tp_size));
+ tmp = TmpSpace(sz, arg->nd_type->tp_align);
+ STL(tmp, sz);
C_lal(tmp);
}
break;
case S_ODD:
CodePExpr(left);
- if (tp->tp_size == word_size) {
+ if ((int) tp->tp_size == (int) word_size) {
c_loc(1);
C_and(word_size);
}
{
register t_node *leftop = expr->nd_LEFT;
register t_node *rightop = expr->nd_RIGHT;
- register t_type *tp = expr->nd_type;
+ int fund = expr->nd_type->tp_fund;
+ arith size = expr->nd_type->tp_size;
switch (expr->nd_symb) {
case '+':
Operands(expr);
- switch (tp->tp_fund) {
+ switch (fund) {
case T_INTEGER:
- C_adi(tp->tp_size);
+ C_adi(size);
break;
case T_REAL:
- C_adf(tp->tp_size);
+ C_adf(size);
break;
case T_POINTER:
case T_EQUAL:
break;
case T_CARDINAL:
case T_INTORCARD:
- addu((int) tp->tp_size);
+ addu((int) size);
break;
case T_SET:
- C_ior(tp->tp_size);
+ C_ior(size);
break;
default:
crash("bad type +");
break;
case '-':
Operands(expr);
- switch (tp->tp_fund) {
+ switch (fund) {
case T_INTEGER:
- C_sbi(tp->tp_size);
+ C_sbi(size);
break;
case T_REAL:
- C_sbf(tp->tp_size);
+ C_sbf(size);
break;
case T_POINTER:
case T_EQUAL:
if (rightop->nd_type == address_type) {
- C_sbs(tp->tp_size);
+ C_sbs(size);
break;
}
C_ngi(rightop->nd_type->tp_size);
break;
case T_INTORCARD:
case T_CARDINAL:
- subu((int) tp->tp_size);
+ subu((int) size);
break;
case T_SET:
- C_com(tp->tp_size);
- C_and(tp->tp_size);
+ C_com(size);
+ C_and(size);
break;
default:
crash("bad type -");
break;
case '*':
Operands(expr);
- switch (tp->tp_fund) {
+ switch (fund) {
case T_INTEGER:
- C_mli(tp->tp_size);
+ C_mli(size);
break;
case T_POINTER:
case T_EQUAL:
case T_CARDINAL:
case T_INTORCARD:
if (! options['R']) {
- C_cal((int)(tp->tp_size) <= (int)word_size ?
+ C_cal((int)(size) <= (int)word_size ?
"muluchk" :
"mululchk");
}
- C_mlu(tp->tp_size);
+ C_mlu(size);
break;
case T_REAL:
- C_mlf(tp->tp_size);
+ C_mlf(size);
break;
case T_SET:
- C_and(tp->tp_size);
+ C_and(size);
break;
default:
crash("bad type *");
break;
case '/':
Operands(expr);
- switch (tp->tp_fund) {
+ switch (fund) {
case T_REAL:
- C_dvf(tp->tp_size);
+ C_dvf(size);
break;
case T_SET:
- C_xor(tp->tp_size);
+ C_xor(size);
break;
default:
crash("bad type /");
break;
case DIV:
Operands(expr);
- switch(tp->tp_fund) {
+ switch(fund) {
case T_INTEGER:
- C_cal((int)(tp->tp_size) == (int)word_size
+ C_cal((int)(size) == (int)word_size
? "dvi"
: "dvil");
- C_asp(2*tp->tp_size);
- C_lfr(tp->tp_size);
+ C_asp(2*size);
+ C_lfr(size);
break;
case T_POINTER:
case T_EQUAL:
case T_CARDINAL:
case T_INTORCARD:
- C_dvu(tp->tp_size);
+ C_dvu(size);
break;
default:
crash("bad type DIV");
break;
case MOD:
Operands(expr);
- switch(tp->tp_fund) {
+ switch(fund) {
case T_INTEGER:
- C_cal((int)(tp->tp_size) == (int)word_size
+ C_cal((int)(size) == (int)word_size
? "rmi"
: "rmil");
- C_asp(2*tp->tp_size);
- C_lfr(tp->tp_size);
+ C_asp(2*size);
+ C_lfr(size);
break;
case T_POINTER:
case T_EQUAL:
case T_CARDINAL:
case T_INTORCARD:
- C_rmu(tp->tp_size);
+ C_rmu(size);
break;
default:
crash("bad type MOD");
case '>':
case GREATEREQUAL:
case '=':
- case '#':
+ case '#': {
+ t_type *tp;
+
Operands(expr);
tp = BaseType(leftop->nd_type);
if (tp == intorcard_type) tp = BaseType(rightop->nd_type);
+ size = tp->tp_size;
switch (tp->tp_fund) {
case T_INTEGER:
- C_cmi(tp->tp_size);
+ C_cmi(size);
break;
case T_POINTER:
case T_HIDDEN:
break;
case T_CARDINAL:
case T_INTORCARD:
- C_cmu(tp->tp_size);
+ C_cmu(size);
break;
case T_ENUMERATION:
case T_CHAR:
C_cmu(word_size);
break;
case T_REAL:
- C_cmf(tp->tp_size);
+ C_cmf(size);
break;
case T_SET:
if (expr->nd_symb == GREATEREQUAL) {
/* A >= B is the same as A equals A + B
*/
- C_dup(tp->tp_size << 1);
- C_asp(tp->tp_size);
- C_ior(tp->tp_size);
+ C_dup(size << 1);
+ C_asp(size);
+ C_ior(size);
expr->nd_symb = '=';
}
else if (expr->nd_symb == LESSEQUAL) {
/* A <= B is the same as A - B = {}
*/
- C_com(tp->tp_size);
- C_and(tp->tp_size);
- C_zer(tp->tp_size);
+ C_com(size);
+ C_and(size);
+ C_zer(size);
expr->nd_symb = '=';
}
- C_cms(tp->tp_size);
+ C_cms(size);
break;
default:
crash("bad type COMPARE");
}
truthvalue(expr->nd_symb);
break;
+ }
case IN:
/* In this case, evaluate right hand side first! The
break;
}
default:
- crash("(CodeOper) Bad operator %s\n",symbol2str(expr->nd_symb));
+ crash("(CodeOper) Bad operator");
}
}