Removed switches on longs (portability) and added packed subranges
This commit is contained in:
parent
1ed0f8180f
commit
3e0c73690c
|
@ -116,10 +116,8 @@ CodeBeginBlock(df)
|
|||
|
||||
TmpOpen(df->prc_vis->sc_scope);
|
||||
|
||||
switch( df->df_kind ) {
|
||||
|
||||
case D_MODULE : break; /* nothing */
|
||||
case D_PROGRAM :
|
||||
if ( df->df_kind == D_MODULE) /* nothing */ ;
|
||||
else if (df->df_kind == D_PROGRAM ) {
|
||||
C_exp("m_a_i_n");
|
||||
C_pro_narg("m_a_i_n");
|
||||
C_ms_par((arith) 0);
|
||||
|
@ -133,11 +131,8 @@ CodeBeginBlock(df)
|
|||
C_loc((arith) (1 << EFUNFL));
|
||||
C_ior(int_size);
|
||||
C_sim();
|
||||
|
||||
break;
|
||||
|
||||
case D_PROCEDURE :
|
||||
case D_FUNCTION : {
|
||||
}
|
||||
else if (df->df_kind & (D_PROCEDURE | D_FUNCTION)) {
|
||||
struct type *tp;
|
||||
register struct paramlist *param;
|
||||
|
||||
|
@ -162,7 +157,7 @@ CodeBeginBlock(df)
|
|||
C_zer((arith) int_size);
|
||||
C_stl(df->prc_bool);
|
||||
}
|
||||
for( param = ParamList(df->df_type); param; param = param->next)
|
||||
for( param = ParamList(df->df_type); param; param = param->next) {
|
||||
if( !IsVarParam(param) ) {
|
||||
tp = TypeOfParam(param);
|
||||
|
||||
|
@ -213,10 +208,9 @@ CodeBeginBlock(df)
|
|||
C_stl(param->par_def->var_off);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
default :
|
||||
else {
|
||||
crash("(CodeBeginBlock)");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
@ -233,57 +227,51 @@ CodeEndBlock(df, StackAdjustment)
|
|||
register struct def *df;
|
||||
arith StackAdjustment;
|
||||
{
|
||||
switch( df->df_kind ) {
|
||||
case D_PROGRAM :
|
||||
C_loc((arith) 0);
|
||||
C_cal("_hlt");
|
||||
break;
|
||||
if( df->df_kind == D_PROGRAM) {
|
||||
C_loc((arith) 0);
|
||||
C_cal("_hlt");
|
||||
}
|
||||
else if (df->df_kind & (D_PROCEDURE | D_FUNCTION)) {
|
||||
struct type *tp;
|
||||
|
||||
case D_PROCEDURE :
|
||||
case D_FUNCTION : {
|
||||
struct type *tp;
|
||||
|
||||
if( StackAdjustment ) {
|
||||
/* remove copies of conformant arrays */
|
||||
C_lol(StackAdjustment);
|
||||
C_ass(word_size);
|
||||
FreeInt(StackAdjustment);
|
||||
}
|
||||
if( !options['n'] )
|
||||
RegisterMessages(df->prc_vis->sc_scope->sc_def);
|
||||
|
||||
if( options['t'] ) {
|
||||
C_lae_dlb(df->prc_label,(arith)0);
|
||||
C_cal("procexit");
|
||||
C_asp(pointer_size);
|
||||
}
|
||||
if( tp = ResultType(df->df_type) ) {
|
||||
if( !options['R'] ) {
|
||||
C_lin(LineNumber);
|
||||
C_lol(df->prc_bool);
|
||||
C_cal("_nfa");
|
||||
C_asp(word_size);
|
||||
}
|
||||
if( tp->tp_size == word_size )
|
||||
C_lol(-tp->tp_size);
|
||||
if( tp->tp_size == 2 * word_size )
|
||||
C_ldl(-tp->tp_size);
|
||||
else {
|
||||
C_lal(-tp->tp_size);
|
||||
C_loi(tp->tp_size);
|
||||
}
|
||||
|
||||
C_ret(tp->tp_size);
|
||||
}
|
||||
else
|
||||
C_ret((arith) 0);
|
||||
|
||||
break;
|
||||
if( StackAdjustment ) {
|
||||
/* remove copies of conformant arrays */
|
||||
C_lol(StackAdjustment);
|
||||
C_ass(word_size);
|
||||
FreeInt(StackAdjustment);
|
||||
}
|
||||
if( !options['n'] )
|
||||
RegisterMessages(df->prc_vis->sc_scope->sc_def);
|
||||
|
||||
default :
|
||||
crash("(CodeEndBlock)");
|
||||
/*NOTREACHED*/
|
||||
if( options['t'] ) {
|
||||
C_lae_dlb(df->prc_label,(arith)0);
|
||||
C_cal("procexit");
|
||||
C_asp(pointer_size);
|
||||
}
|
||||
if( tp = ResultType(df->df_type) ) {
|
||||
if( !options['R'] ) {
|
||||
C_lin(LineNumber);
|
||||
C_lol(df->prc_bool);
|
||||
C_cal("_nfa");
|
||||
C_asp(word_size);
|
||||
}
|
||||
if( tp->tp_size == word_size )
|
||||
C_lol(-tp->tp_size);
|
||||
if( tp->tp_size == 2 * word_size )
|
||||
C_ldl(-tp->tp_size);
|
||||
else {
|
||||
C_lal(-tp->tp_size);
|
||||
C_loi(tp->tp_size);
|
||||
}
|
||||
|
||||
C_ret(tp->tp_size);
|
||||
}
|
||||
else
|
||||
C_ret((arith) 0);
|
||||
}
|
||||
else {
|
||||
crash("(CodeEndBlock)");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
C_end(- df->prc_vis->sc_scope->sc_off);
|
||||
|
|
|
@ -53,14 +53,20 @@ define(id, scope, kind)
|
|||
register struct def *df;
|
||||
|
||||
if( df = lookup(id, scope, 0) ) {
|
||||
switch( df->df_kind ) {
|
||||
|
||||
case D_INUSE :
|
||||
if (df->df_kind == D_INUSE) {
|
||||
if( kind != D_INUSE ) {
|
||||
error("\"%s\" already used in this block",
|
||||
id->id_text);
|
||||
}
|
||||
return MkDef(id, scope, kind);
|
||||
}
|
||||
if (df->df_kind == D_ERROR ) {
|
||||
/* used in forward references */
|
||||
df->df_kind = kind;
|
||||
return df;
|
||||
}
|
||||
/* other cases fit in an int (assume at least 2 bytes) */
|
||||
switch((int) df->df_kind ) {
|
||||
|
||||
case D_LABEL :
|
||||
/* generate error message somewhere else */
|
||||
|
@ -96,10 +102,6 @@ define(id, scope, kind)
|
|||
id->id_text);
|
||||
return NULLDEF;
|
||||
|
||||
case D_ERROR :
|
||||
/* used in forward references */
|
||||
df->df_kind = kind;
|
||||
return df;
|
||||
}
|
||||
if( kind != D_ERROR )
|
||||
/* avoid spurious error messages */
|
||||
|
@ -129,22 +131,19 @@ DoDirective(directive, nd, tp, scl, function)
|
|||
return;
|
||||
}
|
||||
|
||||
switch( df->df_kind) {
|
||||
case D_FORWARD:
|
||||
kind = function ? D_FWFUNCTION : D_FWPROCEDURE;
|
||||
inp = (proclevel > 1);
|
||||
break;
|
||||
|
||||
case D_EXTERN:
|
||||
kind = function ? D_FUNCTION : D_PROCEDURE;
|
||||
inp = 0;
|
||||
ext = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
node_error(nd, "\"%s\" unknown directive",
|
||||
directive->id_text);
|
||||
return;
|
||||
if (df->df_kind == D_FORWARD) {
|
||||
kind = function ? D_FWFUNCTION : D_FWPROCEDURE;
|
||||
inp = (proclevel > 1);
|
||||
}
|
||||
else if (df->df_kind == D_EXTERN) {
|
||||
kind = function ? D_FUNCTION : D_PROCEDURE;
|
||||
inp = 0;
|
||||
ext = 1;
|
||||
}
|
||||
else {
|
||||
node_error(nd, "\"%s\" unknown directive",
|
||||
directive->id_text);
|
||||
return;
|
||||
}
|
||||
|
||||
if( df = define(nd->nd_IDF, CurrentScope, kind) ) {
|
||||
|
|
|
@ -161,7 +161,7 @@ CodeValue(ds, tp)
|
|||
|
||||
switch( ds->dsg_kind ) {
|
||||
case DSG_LOADED:
|
||||
break;
|
||||
return;
|
||||
|
||||
case DSG_FIXED:
|
||||
if( ds->dsg_offset % word_size == 0 ) {
|
||||
|
@ -199,6 +199,12 @@ CodeValue(ds, tp)
|
|||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
if (size < word_size && tp->tp_fund == T_SUBRANGE &&
|
||||
BaseType(tp)->tp_fund == T_INTEGER && tp->sub_lb < 0) {
|
||||
C_loc(size);
|
||||
C_loc(word_size);
|
||||
C_cii();
|
||||
}
|
||||
ds->dsg_kind = DSG_LOADED;
|
||||
}
|
||||
|
||||
|
@ -502,7 +508,7 @@ CodeDesig(nd, ds)
|
|||
case Def:
|
||||
df = nd->nd_def;
|
||||
|
||||
switch( df->df_kind ) {
|
||||
switch( (int) df->df_kind ) {
|
||||
case D_FIELD:
|
||||
CodeFieldDesig(df, ds);
|
||||
break;
|
||||
|
|
|
@ -306,7 +306,7 @@ stb_string(df, kind)
|
|||
N_LSYM,
|
||||
tp == void_type || tp->tp_size > 32767
|
||||
? 0
|
||||
: (int)tp->tp_size,
|
||||
: (IsPacked(tp) ? (int) tp->tp_psize : (int)tp->tp_size),
|
||||
(arith) 0);
|
||||
break;
|
||||
case D_CONST:
|
||||
|
|
|
@ -296,6 +296,26 @@ subr_type(lb, ub)
|
|||
res = construct_type(T_SUBRANGE, tp);
|
||||
res->sub_lb = lb->nd_INT;
|
||||
res->sub_ub = ub->nd_INT;
|
||||
if (res->sub_lb >= 0) {
|
||||
if (ufit(res->sub_ub, 1)) {
|
||||
res->tp_psize = 1;
|
||||
res->tp_palign = 1;
|
||||
}
|
||||
else if (ufit(res->sub_ub, 2)) {
|
||||
res->tp_psize = 2;
|
||||
res->tp_palign = 2 < word_align ? 2 : word_align;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (fit(res->sub_lb, 1) && fit(res->sub_ub, 1)) {
|
||||
res->tp_psize = 1;
|
||||
res->tp_palign = 1;
|
||||
}
|
||||
else if (fit(res->sub_lb, 2) && fit(res->sub_ub, 2)) {
|
||||
res->tp_psize = 2;
|
||||
res->tp_palign = 2 < word_align ? 2 : word_align;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue