too many changes: some cosmetic; some for 2/4; some for added options

This commit is contained in:
ceriel 1988-03-21 16:47:51 +00:00
parent 759f4738ca
commit bb51d7b0e2

View file

@ -178,16 +178,22 @@ CodeCoercion(t1, t2)
{ {
register int fund1, fund2; register int fund1, fund2;
arith sz1 = t1->tp_size; arith sz1 = t1->tp_size;
arith sz2;
t1 = BaseType(t1); t1 = BaseType(t1);
t2 = BaseType(t2); t2 = BaseType(t2);
sz2 = t2->tp_size;
switch(fund1 = t1->tp_fund) { switch(fund1 = t1->tp_fund) {
case T_WORD: case T_WORD:
fund1 = T_INTEGER; fund1 = T_INTEGER;
break; break;
case T_CHAR: case T_CHAR:
case T_EQUAL:
case T_ENUMERATION: case T_ENUMERATION:
case T_CARDINAL:
case T_INTORCARD:
if (sz1 < word_size) sz1 = word_size;
/* fall through */
case T_EQUAL:
case T_POINTER: case T_POINTER:
fund1 = T_CARDINAL; fund1 = T_CARDINAL;
break; break;
@ -197,8 +203,10 @@ CodeCoercion(t1, t2)
fund2 = T_INTEGER; fund2 = T_INTEGER;
break; break;
case T_CHAR: case T_CHAR:
case T_EQUAL:
case T_ENUMERATION: case T_ENUMERATION:
sz2 = word_size;
/* fall through */
case T_EQUAL:
case T_POINTER: case T_POINTER:
fund2 = T_CARDINAL; fund2 = T_CARDINAL;
break; break;
@ -210,101 +218,83 @@ CodeCoercion(t1, t2)
c_loc((int)sz1); c_loc((int)sz1);
c_loc((int) word_size); c_loc((int) word_size);
C_cii(); C_cii();
sz1 = word_size;
} }
switch(fund2) { if (fund2 == T_REAL) {
case T_INTEGER: c_loc((int)sz1);
#ifndef SQUEEZE c_loc((int)sz2);
if (t2->tp_size != t1->tp_size)
#endif
{
c_loc((int)(t1->tp_size));
c_loc((int)(t2->tp_size));
C_cii();
}
break;
case T_CARDINAL:
#ifndef SQUEEZE
if (t1->tp_size != word_size)
#endif
{
c_loc((int)(t1->tp_size));
c_loc((int) word_size);
C_ciu();
}
break;
case T_REAL:
c_loc((int)(t1->tp_size));
c_loc((int)(t2->tp_size));
C_cif(); C_cif();
break; break;
default: }
crash("Funny integer conversion"); if (sz2 != 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");
}
} }
break; break;
case T_CARDINAL: case T_CARDINAL:
case T_INTORCARD: case T_INTORCARD:
switch(fund2) { if (fund2 == T_REAL) {
case T_CARDINAL: c_loc((int)sz1);
case T_INTORCARD: c_loc((int)sz2);
if (t2->tp_size > word_size) {
c_loc((int) word_size);
c_loc((int)(t2->tp_size));
C_cuu();
}
break;
case T_INTEGER:
if (fund1 == T_CARDINAL
#ifndef SQUEEZE
|| t2->tp_size != word_size
#endif
) {
c_loc((int) word_size);
c_loc((int)(t2->tp_size));
C_cui();
}
break;
case T_REAL:
c_loc((int) word_size);
c_loc((int)(t2->tp_size));
C_cuf(); C_cuf();
break; break;
default: }
crash("Funny cardinal conversion"); if (sz1 != 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");
}
} }
break; break;
case T_REAL: case T_REAL:
switch(fund2) { switch(fund2) {
case T_REAL: case T_REAL:
#ifndef SQUEEZE if (sz1 != sz2) {
if (t2->tp_size != t1->tp_size) c_loc((int)sz1);
#endif c_loc((int)sz2);
{
c_loc((int)(t1->tp_size));
c_loc((int)(t2->tp_size));
C_cff(); C_cff();
} }
break; break;
case T_INTEGER: case T_INTEGER:
c_loc((int)(t1->tp_size)); c_loc((int)sz1);
c_loc((int)(t2->tp_size)); c_loc((int)sz2);
C_cfi(); C_cfi();
break; break;
case T_CARDINAL: case T_CARDINAL:
if (! options['R']) { if (! options['R']) {
label lb = ++text_label; label lb = ++text_label;
C_dup(t1->tp_size); C_dup(sz1);
C_zrf(t1->tp_size); C_zrf(sz1);
C_cmf(t1->tp_size); C_cmf(sz1);
C_zge(lb); C_zge(lb);
c_loc(ECONV); c_loc(ECONV);
C_trp(); C_trp();
def_ilb(lb); def_ilb(lb);
} }
c_loc((int)(t1->tp_size)); c_loc((int)sz1);
c_loc((int)(t2->tp_size)); c_loc((int)sz2);
C_cfu(); C_cfu();
break; break;
default: default:
@ -422,9 +412,7 @@ CodeParameters(param, arg)
C_loc(left_type->tp_size - 1); C_loc(left_type->tp_size - 1);
} }
else { else {
arith lb, ub; C_loc(left_type->arr_high - left_type->arr_low);
getbounds(IndexType(left_type), &lb, &ub);
C_loc(ub - lb);
} }
c_loc(0); c_loc(0);
if (left->nd_symb == STRING) { if (left->nd_symb == STRING) {
@ -696,6 +684,8 @@ CodeOper(expr, true_label, false_label)
break; break;
case T_POINTER: case T_POINTER:
case T_EQUAL: case T_EQUAL:
C_ads(rightop->nd_type->tp_size);
break;
case T_CARDINAL: case T_CARDINAL:
case T_INTORCARD: case T_INTORCARD:
addu(tp->tp_size); addu(tp->tp_size);
@ -716,9 +706,14 @@ CodeOper(expr, true_label, false_label)
case T_REAL: case T_REAL:
C_sbf(tp->tp_size); C_sbf(tp->tp_size);
break; break;
case T_CARDINAL:
if (rightop->nd_type == address_type) {
C_sbs(pointer_size);
break;
}
/* fall through */
case T_POINTER: case T_POINTER:
case T_EQUAL: case T_EQUAL:
case T_CARDINAL:
case T_INTORCARD: case T_INTORCARD:
subu(tp->tp_size); subu(tp->tp_size);
break; break;
@ -1101,7 +1096,8 @@ DoHIGH(df)
assert(IsConformantArray(df->df_type)); assert(IsConformantArray(df->df_type));
highoff = df->var_off /* base address and descriptor */ highoff = df->var_off /* base address and descriptor */
+ 2 * word_size; /* skip base and first field of + word_size + pointer_size;
/* skip base and first field of
descriptor descriptor
*/ */
if (df->df_scope->sc_level < proclevel) { if (df->df_scope->sc_level < proclevel) {