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);
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;
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);
C_stl(param->par_def->var_off);
}
}
- break;
+ }
}
-
- default :
+ else {
crash("(CodeBeginBlock)");
/*NOTREACHED*/
}
register struct def *df;
arith StackAdjustment;
{
- switch( df->df_kind ) {
- case D_PROGRAM :
- C_loc((arith) 0);
- C_cal("_hlt");
- break;
-
- case D_PROCEDURE :
- case D_FUNCTION : {
- struct type *tp;
+ 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;
- 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( 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( 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 = 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);
+ 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);
}
- else
- C_ret((arith) 0);
- break;
+ C_ret(tp->tp_size);
}
-
- default :
- crash("(CodeEndBlock)");
- /*NOTREACHED*/
+ else
+ C_ret((arith) 0);
+ }
+ else {
+ crash("(CodeEndBlock)");
+ /*NOTREACHED*/
}
C_end(- df->prc_vis->sc_scope->sc_off);
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 */
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 */
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) ) {
switch( ds->dsg_kind ) {
case DSG_LOADED:
- break;
+ return;
case DSG_FIXED:
if( ds->dsg_offset % word_size == 0 ) {
/*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;
}
case Def:
df = nd->nd_def;
- switch( df->df_kind ) {
+ switch( (int) df->df_kind ) {
case D_FIELD:
CodeFieldDesig(df, ds);
break;
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:
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;
}