some more squeezing for Minix
This commit is contained in:
parent
e4857c2446
commit
3d5569183e
7 changed files with 47 additions and 49 deletions
|
|
@ -547,18 +547,19 @@ ch3asgn(expp, oper, expr)
|
||||||
int fund = exp->ex_type->tp_fund;
|
int fund = exp->ex_type->tp_fund;
|
||||||
int vol = 0;
|
int vol = 0;
|
||||||
struct type *tp;
|
struct type *tp;
|
||||||
|
char *oper_string = symbol2str(oper);
|
||||||
|
|
||||||
/* We expect an lvalue */
|
/* We expect an lvalue */
|
||||||
if (!exp->ex_lvalue) {
|
if (!exp->ex_lvalue) {
|
||||||
expr_error(exp, "no lvalue in operand of %s", symbol2str(oper));
|
expr_error(exp, "no lvalue in operand of %s", oper_string);
|
||||||
} else if (exp->ex_flags & EX_ILVALUE) {
|
} else if (exp->ex_flags & EX_ILVALUE) {
|
||||||
strict("incorrect lvalue in operand of %s", symbol2str(oper));
|
strict("incorrect lvalue in operand of %s", oper_string);
|
||||||
} else if (exp->ex_flags & EX_READONLY) {
|
} else if (exp->ex_flags & EX_READONLY) {
|
||||||
expr_error(exp, "operand of %s is read-only", symbol2str(oper));
|
expr_error(exp, "operand of %s is read-only", oper_string);
|
||||||
} else if (fund == STRUCT || fund == UNION) {
|
} else if (fund == STRUCT || fund == UNION) {
|
||||||
if (recurconst(exp->ex_type))
|
if (recurconst(exp->ex_type))
|
||||||
expr_error(expr,"operand of %s contains a const-qualified member",
|
expr_error(expr,"operand of %s contains a const-qualified member",
|
||||||
symbol2str(oper));
|
oper_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Preserve volatile markers across the tree.
|
/* Preserve volatile markers across the tree.
|
||||||
|
|
@ -596,10 +597,8 @@ ch3asgn(expp, oper, expr)
|
||||||
expr = extmp;
|
expr = extmp;
|
||||||
}
|
}
|
||||||
#ifndef NOBITFIELD
|
#ifndef NOBITFIELD
|
||||||
if (fund == FIELD)
|
exp = new_oper(fund == FIELD ? exp->ex_type->tp_up : exp->ex_type,
|
||||||
exp = new_oper(exp->ex_type->tp_up, exp, oper, expr);
|
exp, oper, expr);
|
||||||
else
|
|
||||||
exp = new_oper(exp->ex_type, exp, oper, expr);
|
|
||||||
#else NOBITFIELD
|
#else NOBITFIELD
|
||||||
exp = new_oper(exp->ex_type, exp, oper, expr);
|
exp = new_oper(exp->ex_type, exp, oper, expr);
|
||||||
#endif NOBITFIELD
|
#endif NOBITFIELD
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ struct def { /* for ordinary tags */
|
||||||
char df_initialized; /* an initialization has been generated */
|
char df_initialized; /* an initialization has been generated */
|
||||||
char df_alloc; /* 0, ALLOC_SEEN or ALLOC_DONE */
|
char df_alloc; /* 0, ALLOC_SEEN or ALLOC_DONE */
|
||||||
char df_used; /* set if idf is used */
|
char df_used; /* set if idf is used */
|
||||||
|
char df_formal_array; /* to warn if sizeof is taken */
|
||||||
char *df_file; /* file containing the definition */
|
char *df_file; /* file containing the definition */
|
||||||
unsigned int df_line; /* line number of the definition */
|
unsigned int df_line; /* line number of the definition */
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
|
|
@ -27,7 +28,6 @@ struct def { /* for ordinary tags */
|
||||||
int df_firstbrace; /* brace number of its first occurrence */
|
int df_firstbrace; /* brace number of its first occurrence */
|
||||||
int df_minlevel; /* the lowest level needed for this def */
|
int df_minlevel; /* the lowest level needed for this def */
|
||||||
#endif LINT
|
#endif LINT
|
||||||
char df_formal_array; /* to warn if sizeof is taken */
|
|
||||||
arith df_address;
|
arith df_address;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ struct e_stack {
|
||||||
arith s_cnt1, s_cnt2;
|
arith s_cnt1, s_cnt2;
|
||||||
struct sdef *s_def;
|
struct sdef *s_def;
|
||||||
struct type **s_tpp;
|
struct type **s_tpp;
|
||||||
char s_nested;
|
short s_nested;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ALLOCDEF "e_stack" 5 */
|
/* ALLOCDEF "e_stack" 5 */
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ struct expr {
|
||||||
char *ex_file; /* the file it (probably) comes from */
|
char *ex_file; /* the file it (probably) comes from */
|
||||||
unsigned int ex_line; /* the line it (probably) comes from */
|
unsigned int ex_line; /* the line it (probably) comes from */
|
||||||
struct type *ex_type;
|
struct type *ex_type;
|
||||||
char ex_lvalue;
|
short ex_lvalue;
|
||||||
short ex_flags;
|
short ex_flags;
|
||||||
int ex_class;
|
int ex_class;
|
||||||
int ex_depth;
|
int ex_depth;
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,9 @@ eval_field(expr, code)
|
||||||
struct type *tp = leftop->ex_type->tp_up;
|
struct type *tp = leftop->ex_type->tp_up;
|
||||||
arith tmpvar;
|
arith tmpvar;
|
||||||
struct type *atype = tp->tp_unsigned ? uword_type : word_type;
|
struct type *atype = tp->tp_unsigned ? uword_type : word_type;
|
||||||
arith asize = atype->tp_size;
|
|
||||||
|
|
||||||
/* First some assertions to be sure that the rest is legal */
|
/* First some assertions to be sure that the rest is legal */
|
||||||
ASSERT(asize == word_size); /* make sure that C_loc() is legal */
|
ASSERT(atype->tp_size == word_size); /* make sure that C_loc() is legal */
|
||||||
ASSERT(leftop->ex_type->tp_fund == FIELD);
|
ASSERT(leftop->ex_type->tp_fund == FIELD);
|
||||||
leftop->ex_type = atype; /* this is cheating but it works... */
|
leftop->ex_type = atype; /* this is cheating but it works... */
|
||||||
if (op == '=') {
|
if (op == '=') {
|
||||||
|
|
@ -66,19 +65,19 @@ eval_field(expr, code)
|
||||||
EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
conversion(tp, atype);
|
conversion(tp, atype);
|
||||||
C_loc(fd->fd_mask);
|
C_loc(fd->fd_mask);
|
||||||
C_and(asize);
|
C_and(word_size);
|
||||||
if (code == TRUE)
|
if (code == TRUE)
|
||||||
C_dup(asize);
|
C_dup(word_size);
|
||||||
C_loc((arith)fd->fd_shift);
|
C_loc((arith)fd->fd_shift);
|
||||||
if (atype->tp_unsigned)
|
if (atype->tp_unsigned)
|
||||||
C_slu(asize);
|
C_slu(word_size);
|
||||||
else
|
else
|
||||||
C_sli(asize);
|
C_sli(word_size);
|
||||||
C_loc(~((fd->fd_mask << fd->fd_shift) | ~full_mask[asize]));
|
C_loc(~((fd->fd_mask << fd->fd_shift) | ~full_mask[(int)word_size]));
|
||||||
if (leftop->ex_depth == 0) { /* simple case */
|
if (leftop->ex_depth == 0) { /* simple case */
|
||||||
load_val(leftop, RVAL);
|
load_val(leftop, RVAL);
|
||||||
C_and(asize);
|
C_and(word_size);
|
||||||
C_ior(asize);
|
C_ior(word_size);
|
||||||
store_val(&(leftop->EX_VALUE), atype);
|
store_val(&(leftop->EX_VALUE), atype);
|
||||||
}
|
}
|
||||||
else { /* complex case */
|
else { /* complex case */
|
||||||
|
|
@ -87,11 +86,11 @@ eval_field(expr, code)
|
||||||
EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL);
|
EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
C_dup(pointer_size);
|
C_dup(pointer_size);
|
||||||
StoreLocal(tmpvar, pointer_size);
|
StoreLocal(tmpvar, pointer_size);
|
||||||
C_loi(asize);
|
C_loi(word_size);
|
||||||
C_and(asize);
|
C_and(word_size);
|
||||||
C_ior(asize);
|
C_ior(word_size);
|
||||||
LoadLocal(tmpvar, pointer_size);
|
LoadLocal(tmpvar, pointer_size);
|
||||||
C_sti(asize);
|
C_sti(word_size);
|
||||||
FreeLocal(tmpvar);
|
FreeLocal(tmpvar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -107,23 +106,23 @@ eval_field(expr, code)
|
||||||
EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL);
|
EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
C_dup(pointer_size);
|
C_dup(pointer_size);
|
||||||
StoreLocal(tmpvar, pointer_size);
|
StoreLocal(tmpvar, pointer_size);
|
||||||
C_loi(asize);
|
C_loi(word_size);
|
||||||
}
|
}
|
||||||
if (atype->tp_unsigned) {
|
if (atype->tp_unsigned) {
|
||||||
C_loc((arith)fd->fd_shift);
|
C_loc((arith)fd->fd_shift);
|
||||||
C_sru(asize);
|
C_sru(word_size);
|
||||||
C_loc(fd->fd_mask);
|
C_loc(fd->fd_mask);
|
||||||
C_and(asize);
|
C_and(word_size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arith bits_in_type = asize * 8;
|
arith bits_in_type = word_size * 8;
|
||||||
C_loc(bits_in_type - (fd->fd_width + fd->fd_shift));
|
C_loc(bits_in_type - (fd->fd_width + fd->fd_shift));
|
||||||
C_sli(asize);
|
C_sli(word_size);
|
||||||
C_loc(bits_in_type - fd->fd_width);
|
C_loc(bits_in_type - fd->fd_width);
|
||||||
C_sri(asize);
|
C_sri(word_size);
|
||||||
}
|
}
|
||||||
if (code == TRUE && (op == POSTINCR || op == POSTDECR))
|
if (code == TRUE && (op == POSTINCR || op == POSTDECR))
|
||||||
C_dup(asize);
|
C_dup(word_size);
|
||||||
conversion(atype, rightop->ex_type);
|
conversion(atype, rightop->ex_type);
|
||||||
EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
/* the 'op' operation: */
|
/* the 'op' operation: */
|
||||||
|
|
@ -136,28 +135,28 @@ eval_field(expr, code)
|
||||||
assop(rightop->ex_type, op);
|
assop(rightop->ex_type, op);
|
||||||
conversion(rightop->ex_type, atype);
|
conversion(rightop->ex_type, atype);
|
||||||
C_loc(fd->fd_mask);
|
C_loc(fd->fd_mask);
|
||||||
C_and(asize);
|
C_and(word_size);
|
||||||
if (code == TRUE && op != POSTINCR && op != POSTDECR)
|
if (code == TRUE && op != POSTINCR && op != POSTDECR)
|
||||||
C_dup(asize);
|
C_dup(word_size);
|
||||||
C_loc((arith)fd->fd_shift);
|
C_loc((arith)fd->fd_shift);
|
||||||
if (atype->tp_unsigned)
|
if (atype->tp_unsigned)
|
||||||
C_slu(asize);
|
C_slu(word_size);
|
||||||
else
|
else
|
||||||
C_sli(asize);
|
C_sli(word_size);
|
||||||
C_loc(~((fd->fd_mask << fd->fd_shift) | ~full_mask[asize]));
|
C_loc(~((fd->fd_mask << fd->fd_shift) | ~full_mask[(int)word_size]));
|
||||||
if (leftop->ex_depth == 0) {
|
if (leftop->ex_depth == 0) {
|
||||||
load_val(leftop, RVAL);
|
load_val(leftop, RVAL);
|
||||||
C_and(asize);
|
C_and(word_size);
|
||||||
C_ior(asize);
|
C_ior(word_size);
|
||||||
store_val(&(leftop->EX_VALUE), atype);
|
store_val(&(leftop->EX_VALUE), atype);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LoadLocal(tmpvar, pointer_size);
|
LoadLocal(tmpvar, pointer_size);
|
||||||
C_loi(asize);
|
C_loi(word_size);
|
||||||
C_and(asize);
|
C_and(word_size);
|
||||||
C_ior(asize);
|
C_ior(word_size);
|
||||||
LoadLocal(tmpvar, pointer_size);
|
LoadLocal(tmpvar, pointer_size);
|
||||||
C_sti(asize);
|
C_sti(word_size);
|
||||||
FreeLocal(tmpvar);
|
FreeLocal(tmpvar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -167,12 +166,12 @@ eval_field(expr, code)
|
||||||
retrieval) is on top of stack.
|
retrieval) is on top of stack.
|
||||||
*/
|
*/
|
||||||
if (atype->tp_unsigned == 0) { /* sign extension */
|
if (atype->tp_unsigned == 0) { /* sign extension */
|
||||||
register arith shift = asize * 8 - fd->fd_width;
|
register arith shift = word_size * 8 - fd->fd_width;
|
||||||
|
|
||||||
C_loc(shift);
|
C_loc(shift);
|
||||||
C_sli(asize);
|
C_sli(word_size);
|
||||||
C_loc(shift);
|
C_loc(shift);
|
||||||
C_sri(asize);
|
C_sri(word_size);
|
||||||
}
|
}
|
||||||
conversion(atype, expr->ex_type);
|
conversion(atype, expr->ex_type);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ promoted_type(tp)
|
||||||
struct type *tp;
|
struct type *tp;
|
||||||
{
|
{
|
||||||
if (tp->tp_fund == CHAR || tp->tp_fund == SHORT) {
|
if (tp->tp_fund == CHAR || tp->tp_fund == SHORT) {
|
||||||
if (tp->tp_unsigned && tp->tp_size == int_size)
|
if (tp->tp_unsigned && (int) tp->tp_size == (int) int_size)
|
||||||
return uint_type;
|
return uint_type;
|
||||||
else return int_type;
|
else return int_type;
|
||||||
} else if (tp->tp_fund == FLOAT)
|
} else if (tp->tp_fund == FLOAT)
|
||||||
|
|
@ -127,7 +127,7 @@ construct_type(fund, tp, qual, count, pl)
|
||||||
struct type *
|
struct type *
|
||||||
function_of(tp, pl, qual)
|
function_of(tp, pl, qual)
|
||||||
register struct type *tp;
|
register struct type *tp;
|
||||||
register struct proto *pl;
|
struct proto *pl;
|
||||||
int qual;
|
int qual;
|
||||||
{
|
{
|
||||||
register struct type *dtp = tp->tp_function;
|
register struct type *dtp = tp->tp_function;
|
||||||
|
|
@ -233,7 +233,7 @@ size_of_type(tp, nm)
|
||||||
|
|
||||||
if (sz < 0) {
|
if (sz < 0) {
|
||||||
error("size of %s unknown", nm);
|
error("size of %s unknown", nm);
|
||||||
return (arith)1;
|
sz = (arith)1;
|
||||||
}
|
}
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
struct type {
|
struct type {
|
||||||
struct type *next; /* used only with ARRAY */
|
struct type *next; /* used only with ARRAY */
|
||||||
short tp_fund; /* fundamental type */
|
short tp_fund; /* fundamental type */
|
||||||
char tp_unsigned;
|
short tp_unsigned;
|
||||||
int tp_align;
|
int tp_align;
|
||||||
int tp_typequal; /* type qualifier */
|
int tp_typequal; /* type qualifier */
|
||||||
arith tp_size; /* -1 if declared but not defined */
|
arith tp_size; /* -1 if declared but not defined */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue