some more Minix squeezing

This commit is contained in:
ceriel 1989-10-20 16:16:06 +00:00
parent 64b7d49c0a
commit 352c5c581b
6 changed files with 22 additions and 32 deletions

View file

@ -334,9 +334,9 @@ int2float(expp, tp)
exp->ex_type = tp; exp->ex_type = tp;
exp->ex_class = Float; exp->ex_class = Float;
exp->FL_VALUE = 0 /* Salloc(buf, (unsigned)strlen(buf)+1) */ ; /* exp->FL_VALUE = 0 /* Salloc(buf, (unsigned)strlen(buf)+1) */ ;
flt_arith2flt(exp->VL_VALUE, &(exp->FL_ARITH)); flt_arith2flt(exp->VL_VALUE, &(exp->FL_ARITH));
exp->FL_DATLAB = 0; /* exp->FL_DATLAB = 0; */
} }
else *expp = arith2arith(tp, INT2FLOAT, *expp); else *expp = arith2arith(tp, INT2FLOAT, *expp);
} }

View file

@ -209,11 +209,11 @@ string2expr(expp, str, len)
ex->ex_type = string_type; ex->ex_type = string_type;
/* ex->ex_type = qualifier_type(ex->ex_type, TQ_CONST); */ /* ex->ex_type = qualifier_type(ex->ex_type, TQ_CONST); */
ex->ex_flags |= EX_READONLY; ex->ex_flags |= EX_READONLY;
ex->ex_lvalue = 0; /* ex->ex_lvalue = 0; */
ex->ex_class = String; ex->ex_class = String;
ex->SG_VALUE = str; ex->SG_VALUE = str;
ex->SG_LEN = len; ex->SG_LEN = len;
ex->SG_DATLAB = 0; /* ex->SG_DATLAB = 0; */
} }
int2expr(expr) int2expr(expr)

View file

@ -90,7 +90,7 @@ idf_hashed(tg, size, hc)
*hook = notch; /* hooked in */ *hook = notch; /* hooked in */
notch->id_text = Salloc(tg, (unsigned) size); notch->id_text = Salloc(tg, (unsigned) size);
#ifndef NOPP #ifndef NOPP
notch->id_resmac = 0; /* notch->id_resmac = 0; */
#endif NOPP #endif NOPP
return notch; return notch;
} }
@ -346,7 +346,7 @@ declare_idf(ds, dc, lvl)
newdef->df_line = idf->id_line; newdef->df_line = idf->id_line;
#ifdef LINT #ifdef LINT
newdef->df_set = (type->tp_fund == ARRAY); newdef->df_set = (type->tp_fund == ARRAY);
newdef->df_firstbrace = 0; /* newdef->df_firstbrace = 0; */
#endif LINT #endif LINT
/* link it into the name list in the proper place */ /* link it into the name list in the proper place */

View file

@ -119,7 +119,7 @@ add_proto(pl, ds, dc, level)
newdef->df_line = idf->id_line; newdef->df_line = idf->id_line;
#ifdef LINT #ifdef LINT
newdef->df_set = (type->tp_fund == ARRAY); newdef->df_set = (type->tp_fund == ARRAY);
newdef->df_firstbrace = 0; /* newdef->df_firstbrace = 0; */
#endif #endif
/* We can't put the idf onto the stack, since these kinds /* We can't put the idf onto the stack, since these kinds
of declaration may occurs at any level, and the idf of declaration may occurs at any level, and the idf

View file

@ -103,7 +103,7 @@ add_sel(stp, tp, idf, sdefpp, szp, fd) /* this is horrible */
check_selector(idf, stp); check_selector(idf, stp);
newsdef = new_sdef(); newsdef = new_sdef();
newsdef->sd_sdef = (struct sdef *) 0; /* newsdef->sd_sdef = (struct sdef *) 0; */
/* link into selector descriptor list of this id /* link into selector descriptor list of this id
*/ */

View file

@ -42,7 +42,6 @@ static struct switch_hdr *switch_stack = 0;
- the expression E in "switch(E)" shall have integral type (3.6.4.2) - the expression E in "switch(E)" shall have integral type (3.6.4.2)
- the expression E in "case E:" is converted to the promoted type - the expression E in "case E:" is converted to the promoted type
of the controlling expression of the controlling expression
- the values in the CSA/CSB tables are words (EM 7.4) (??? JvE)
For simplicity, we suppose int_size == word_size. For simplicity, we suppose int_size == word_size.
*/ */
@ -59,18 +58,6 @@ code_startswitch(expp)
/* INT, LONG, FLOAT, DOUBLE or LNGDBL */ /* INT, LONG, FLOAT, DOUBLE or LNGDBL */
switch (fund) { switch (fund) {
case LONG:
/* switches on longs should work. Unfortunately, no backend
* has simplemented switches with sizes other than the
* word_size. Furthermore, building the rom should then be
* done using C_rom_icon().
* Just cast the expression to int and give a warning when
* this means truncation.
*/
if (long_size > int_size)
warning("can't switch on longs (cast to int)");
int2int(expp, int_type); /* for now ??? */
break;
case FLOAT: case FLOAT:
case DOUBLE: case DOUBLE:
case LNGDBL: case LNGDBL:
@ -80,23 +67,25 @@ code_startswitch(expp)
} }
stack_stmt(l_break, NO_LABEL); stack_stmt(l_break, NO_LABEL);
sh->sh_break = l_break; sh->sh_break = l_break;
sh->sh_default = 0; /* sh->sh_default = 0; */
sh->sh_table = l_table; sh->sh_table = l_table;
sh->sh_nrofentries = 0; /* sh->sh_nrofentries = 0; */
sh->sh_type = (*expp)->ex_type; /* the expression switched */ sh->sh_type = (*expp)->ex_type; /* the expression switched */
sh->sh_lowerbd = sh->sh_upperbd = (arith)0; /* immaterial ??? */ /* sh->sh_entries = (struct case_entry *) 0; /* case-entry list */
sh->sh_entries = (struct case_entry *) 0; /* case-entry list */
sh->sh_expr = *expp; sh->sh_expr = *expp;
sh->next = switch_stack; /* push onto switch-stack */ sh->next = switch_stack; /* push onto switch-stack */
switch_stack = sh; switch_stack = sh;
C_bra(l_table); /* goto start of switch_table */ C_bra(l_table); /* goto start of switch_table */
} }
extern char *long2str();
code_endswitch() code_endswitch()
{ {
register struct switch_hdr *sh = switch_stack; register struct switch_hdr *sh = switch_stack;
register label tablabel; register label tablabel;
register struct case_entry *ce; register struct case_entry *ce;
arith size = sh->sh_type->tp_size;
if (sh->sh_default == 0) /* no default occurred yet */ if (sh->sh_default == 0) /* no default occurred yet */
sh->sh_default = sh->sh_break; sh->sh_default = sh->sh_break;
@ -111,8 +100,9 @@ code_endswitch()
/* CSA */ /* CSA */
register arith val; register arith val;
C_rom_cst(sh->sh_lowerbd); C_rom_icon(long2str((long)sh->sh_lowerbd,10), size);
C_rom_cst(sh->sh_upperbd - sh->sh_lowerbd); C_rom_icon(long2str((long)(sh->sh_upperbd - sh->sh_lowerbd),10),
size);
ce = sh->sh_entries; ce = sh->sh_entries;
if (sh->sh_nrofentries) if (sh->sh_nrofentries)
for (val = sh->sh_lowerbd; val <= sh->sh_upperbd; val++) { for (val = sh->sh_lowerbd; val <= sh->sh_upperbd; val++) {
@ -125,17 +115,17 @@ code_endswitch()
C_rom_ilb(sh->sh_default); C_rom_ilb(sh->sh_default);
} }
C_lae_dlb(tablabel, (arith)0); /* perform the switch */ C_lae_dlb(tablabel, (arith)0); /* perform the switch */
C_csa(sh->sh_type->tp_size); C_csa(size);
} }
else { /* CSB */ else { /* CSB */
C_rom_cst((arith)sh->sh_nrofentries); C_rom_icon(long2str((long)sh->sh_nrofentries,10),size);
for (ce = sh->sh_entries; ce; ce = ce->next) { for (ce = sh->sh_entries; ce; ce = ce->next) {
/* generate the entries: value + prog.label */ /* generate the entries: value + prog.label */
C_rom_cst(ce->ce_value); C_rom_icon(long2str((long)ce->ce_value,10),size);
C_rom_ilb(ce->ce_label); C_rom_ilb(ce->ce_label);
} }
C_lae_dlb(tablabel, (arith)0); /* perform the switch */ C_lae_dlb(tablabel, (arith)0); /* perform the switch */
C_csb(sh->sh_type->tp_size); C_csb(size);
} }
C_df_ilb(sh->sh_break); C_df_ilb(sh->sh_break);
switch_stack = sh->next; /* unstack the switch descriptor */ switch_stack = sh->next; /* unstack the switch descriptor */
@ -168,7 +158,7 @@ code_case(expr)
C_df_ilb(ce->ce_label = text_label()); C_df_ilb(ce->ce_label = text_label());
ce->ce_value = val = expr->VL_VALUE; ce->ce_value = val = expr->VL_VALUE;
if (sh->sh_entries == 0) { /* first case entry */ if (sh->sh_entries == 0) { /* first case entry */
ce->next = (struct case_entry *) 0; /* ce->next = (struct case_entry *) 0; */
sh->sh_entries = ce; sh->sh_entries = ce;
sh->sh_lowerbd = sh->sh_upperbd = val; sh->sh_lowerbd = sh->sh_upperbd = val;
sh->sh_nrofentries = 1; sh->sh_nrofentries = 1;