Added macro's for long selections

This commit is contained in:
ceriel 1991-03-06 10:52:34 +00:00
parent 24fd4e190e
commit 76d79cf17a
10 changed files with 38 additions and 34 deletions

View file

@ -617,12 +617,12 @@ lexwarning(W_ORDINARY, "overflow in constant");
tk->tk_data.tk_real = new_real(); tk->tk_data.tk_real = new_real();
if (np >= &buf[NUMSIZE]) { if (np >= &buf[NUMSIZE]) {
tk->TOK_REAL = Salloc("0.0", 4); tk->TOK_RSTR = Salloc("0.0", 4);
lexerror("real constant too long"); lexerror("real constant too long");
} }
else tk->TOK_REAL = Salloc(buf, (unsigned) (np - buf)); else tk->TOK_RSTR = Salloc(buf, (unsigned) (np - buf));
CheckForLet(); CheckForLet();
flt_str2flt(tk->TOK_REAL, &(tk->TOK_RVAL)); flt_str2flt(tk->TOK_RSTR, &(tk->TOK_RVAL));
if (flt_status == FLT_OVFL) { if (flt_status == FLT_OVFL) {
lexwarning(W_ORDINARY, "overflow in floating point constant"); lexwarning(W_ORDINARY, "overflow in floating point constant");
} }

View file

@ -30,17 +30,18 @@ struct token {
struct real *tk_real; /* REAL */ struct real *tk_real; /* REAL */
arith *tk_set; /* only used in parse tree node */ arith *tk_set; /* only used in parse tree node */
struct def *tk_def; /* only used in parse tree node */ struct def *tk_def; /* only used in parse tree node */
label tk_lab; /* only used in parse tree node */
} tk_data; } tk_data;
}; };
typedef struct token t_token; typedef struct token t_token;
#define TOK_IDF tk_data.tk_idf #define TOK_IDF tk_data.tk_idf
#define TOK_SSTR tk_data.tk_str
#define TOK_STR tk_data.tk_str->s_str #define TOK_STR tk_data.tk_str->s_str
#define TOK_SLE tk_data.tk_str->s_length #define TOK_SLE tk_data.tk_str->s_length
#define TOK_INT tk_data.tk_int #define TOK_INT tk_data.tk_int
#define TOK_REAL tk_data.tk_real->r_real #define TOK_REAL tk_data.tk_real
#define TOK_RSTR tk_data.tk_real->r_real
#define TOK_RVAL tk_data.tk_real->r_val #define TOK_RVAL tk_data.tk_real->r_val
extern t_token dot, aside; extern t_token dot, aside;

View file

@ -56,8 +56,8 @@ LLmessage(tk)
break; break;
case REAL: case REAL:
dotp->tk_data.tk_real = new_real(); dotp->tk_data.tk_real = new_real();
dotp->TOK_REAL = Salloc("0.0", 4); dotp->TOK_RSTR = Salloc("0.0", 4);
flt_str2flt(dotp->TOK_REAL, &dotp->TOK_RVAL); flt_str2flt(dotp->TOK_RSTR, &dotp->TOK_RVAL);
break; break;
} }
} }

View file

@ -76,6 +76,7 @@ compact(nr, low, up)
return (nr != 0 && diff >= 0 && fit(diff, (int) word_size) && return (nr != 0 && diff >= 0 && fit(diff, (int) word_size) &&
diff / nr <= (DENSITY - 1)); diff / nr <= (DENSITY - 1));
} }
#define nd_lab nd_symb
int int
CaseCode(nd, exitlabel, end_reached) CaseCode(nd, exitlabel, end_reached)
@ -110,11 +111,11 @@ CaseCode(nd, exitlabel, end_reached)
if (pnode->nd_left) { if (pnode->nd_left) {
/* non-empty case /* non-empty case
*/ */
pnode->nd_lab = ++text_label; pnode->nd_left->nd_lab = ++text_label;
AddCases(sh, /* to descriptor */ AddCases(sh, /* to descriptor */
pnode->nd_left->nd_left, pnode->nd_left->nd_left,
/* of case labels */ /* of case labels */
pnode->nd_lab (label) pnode->nd_left->nd_lab
/* and code label */ /* and code label */
); );
} }
@ -194,7 +195,7 @@ CaseCode(nd, exitlabel, end_reached)
while (pnode = pnode->nd_right) { while (pnode = pnode->nd_right) {
if (pnode->nd_class == Link && pnode->nd_symb == '|') { if (pnode->nd_class == Link && pnode->nd_symb == '|') {
if (pnode->nd_left) { if (pnode->nd_left) {
rval |= LblWalkNode(pnode->nd_lab, rval |= LblWalkNode((label) pnode->nd_left->nd_lab,
pnode->nd_left->nd_right, pnode->nd_left->nd_right,
exitlabel, end_reached); exitlabel, end_reached);
C_bra(sh->sh_break); C_bra(sh->sh_break);

View file

@ -102,8 +102,8 @@ MkCoercion(pnd, tp)
wmess = "conversion"; wmess = "conversion";
} }
if (!wmess || pass_1) { if (!wmess || pass_1) {
if (nd->nd_REAL) free(nd->nd_REAL); if (nd->nd_RSTR) free(nd->nd_RSTR);
free_real(nd->nd_token.tk_data.tk_real); free_real(nd->nd_REAL);
nd->nd_INT = op; nd->nd_INT = op;
nd->nd_symb = INTEGER; nd->nd_symb = INTEGER;
} }
@ -122,7 +122,7 @@ MkCoercion(pnd, tp)
default: default:
crash("MkCoercion"); crash("MkCoercion");
} }
nd->nd_token.tk_data.tk_real = p; nd->nd_REAL = p;
nd->nd_symb = REAL; nd->nd_symb = REAL;
} }
break; break;
@ -371,10 +371,10 @@ ChkExLinkOrName(expp)
} }
else expp->nd_class = Value; else expp->nd_class = Value;
if (df->df_type->tp_fund == T_REAL) { if (df->df_type->tp_fund == T_REAL) {
struct real *p = expp->nd_token.tk_data.tk_real; struct real *p = expp->nd_REAL;
expp->nd_token.tk_data.tk_real = new_real(); expp->nd_REAL = new_real();
*(expp->nd_token.tk_data.tk_real) = *p; *(expp->nd_REAL) = *p;
if (p->r_real) { if (p->r_real) {
p->r_real = Salloc(p->r_real, p->r_real = Salloc(p->r_real,
(unsigned)(strlen(p->r_real)+1)); (unsigned)(strlen(p->r_real)+1));
@ -1021,9 +1021,9 @@ ChkUnOper(expp)
if (right->nd_class == Value) { if (right->nd_class == Value) {
*expp = *right; *expp = *right;
flt_umin(&(expp->nd_RVAL)); flt_umin(&(expp->nd_RVAL));
if (expp->nd_REAL) { if (expp->nd_RSTR) {
free(expp->nd_REAL); free(expp->nd_RSTR);
expp->nd_REAL = 0; expp->nd_RSTR = 0;
} }
FreeNode(right); FreeNode(right);
} }
@ -1447,7 +1447,7 @@ TryToString(nd, tp)
if (tp->tp_fund == T_ARRAY && nd->nd_type == char_type) { if (tp->tp_fund == T_ARRAY && nd->nd_type == char_type) {
buf[0] = nd->nd_INT; buf[0] = nd->nd_INT;
nd->nd_type = standard_type(T_STRING, 1, (arith) 2); nd->nd_type = standard_type(T_STRING, 1, (arith) 2);
nd->nd_token.tk_data.tk_str = nd->nd_SSTR =
(struct string *) Malloc(sizeof(struct string)); (struct string *) Malloc(sizeof(struct string));
nd->nd_STR = Salloc(buf, 2); nd->nd_STR = Salloc(buf, 2);
nd->nd_SLE = 1; nd->nd_SLE = 1;

View file

@ -127,13 +127,13 @@ CodeExpr(nd, ds, true_label, false_label)
switch(nd->nd_symb) { switch(nd->nd_symb) {
case REAL: case REAL:
C_df_dlb(++data_label); C_df_dlb(++data_label);
if (! nd->nd_REAL) { if (! nd->nd_RSTR) {
static char buf[FLT_STRLEN]; static char buf[FLT_STRLEN];
flt_flt2str(&nd->nd_RVAL, buf, FLT_STRLEN); flt_flt2str(&nd->nd_RVAL, buf, FLT_STRLEN);
C_rom_fcon(buf, tp->tp_size); C_rom_fcon(buf, tp->tp_size);
} }
else C_rom_fcon(nd->nd_REAL, tp->tp_size); else C_rom_fcon(nd->nd_RSTR, tp->tp_size);
c_lae_dlb(data_label); c_lae_dlb(data_label);
C_loi(tp->tp_size); C_loi(tp->tp_size);
break; break;
@ -481,7 +481,7 @@ subu(sz)
arith sz; arith sz;
{ {
if (! options['R']) { if (! options['R']) {
CAL((int) sz == (int) word_size ? "subuchk" : "subulchk", (int) sz); C_cal((int) sz == (int) word_size ? "subuchk" : "subulchk");
} }
C_sbu(sz); C_sbu(sz);
} }
@ -491,7 +491,7 @@ addu(sz)
arith sz; arith sz;
{ {
if (! options['R']) { if (! options['R']) {
CAL((int) sz == (int) word_size ? "adduchk" : "addulchk", (int) sz); C_cal((int) sz == (int) word_size ? "adduchk" : "addulchk");
} }
C_adu(sz); C_adu(sz);
} }
@ -748,8 +748,9 @@ CodeOper(expr, true_label, false_label)
case T_CARDINAL: case T_CARDINAL:
case T_INTORCARD: case T_INTORCARD:
if (! options['R']) { if (! options['R']) {
CAL((int)(tp->tp_size) <= (int)word_size ? "muluchk" : "mululchk", C_cal((int)(tp->tp_size) <= (int)word_size ?
(int)(tp->tp_size)); "muluchk" :
"mululchk");
} }
C_mlu(tp->tp_size); C_mlu(tp->tp_size);
break; break;

View file

@ -269,7 +269,7 @@ cstfbin(expp)
expressions below it, and the result restored in expp. expressions below it, and the result restored in expp.
This version is for REAL expressions. This version is for REAL expressions.
*/ */
register struct real *p = expp->nd_left->nd_token.tk_data.tk_real; register struct real *p = expp->nd_left->nd_REAL;
register flt_arith *o1 = &p->r_val; register flt_arith *o1 = &p->r_val;
register flt_arith *o2 = &expp->nd_right->nd_RVAL; register flt_arith *o2 = &expp->nd_right->nd_RVAL;
int compar = 0; int compar = 0;
@ -312,8 +312,8 @@ cstfbin(expp)
case '=': cmpval = (cmpval == 0); break; case '=': cmpval = (cmpval == 0); break;
case '#': cmpval = (cmpval != 0); break; case '#': cmpval = (cmpval != 0); break;
} }
if (expp->nd_right->nd_REAL) free(expp->nd_right->nd_REAL); if (expp->nd_right->nd_RSTR) free(expp->nd_right->nd_RSTR);
free_real(expp->nd_right->nd_token.tk_data.tk_real); free_real(expp->nd_right->nd_REAL);
break; break;
default: default:
@ -343,7 +343,7 @@ cstfbin(expp)
expp->nd_INT = cmpval; expp->nd_INT = cmpval;
} }
else { else {
expp->nd_token.tk_data.tk_real = p; expp->nd_REAL = p;
} }
} }

View file

@ -144,7 +144,7 @@ LexScan()
break; break;
case REAL: case REAL:
print("%s\n", tkp->TOK_REAL); print("%s\n", tkp->TOK_RSTR);
break; break;
case STRING: case STRING:

View file

@ -33,14 +33,15 @@ struct node {
struct token nd_token; struct token nd_token;
#define nd_set nd_token.tk_data.tk_set #define nd_set nd_token.tk_data.tk_set
#define nd_def nd_token.tk_data.tk_def #define nd_def nd_token.tk_data.tk_def
#define nd_lab nd_token.tk_data.tk_lab
#define nd_symb nd_token.tk_symb #define nd_symb nd_token.tk_symb
#define nd_lineno nd_token.tk_lineno #define nd_lineno nd_token.tk_lineno
#define nd_IDF nd_token.TOK_IDF #define nd_IDF nd_token.TOK_IDF
#define nd_SSTR nd_token.TOK_SSTR
#define nd_STR nd_token.TOK_STR #define nd_STR nd_token.TOK_STR
#define nd_SLE nd_token.TOK_SLE #define nd_SLE nd_token.TOK_SLE
#define nd_INT nd_token.TOK_INT #define nd_INT nd_token.TOK_INT
#define nd_REAL nd_token.TOK_REAL #define nd_REAL nd_token.TOK_REAL
#define nd_RSTR nd_token.TOK_RSTR
#define nd_RVAL nd_token.TOK_RVAL #define nd_RVAL nd_token.TOK_RVAL
}; };

View file

@ -347,13 +347,13 @@ stb_string(df, kind)
break; break;
case T_REAL: case T_REAL:
addc_db_str('r'); addc_db_str('r');
if (! df->con_const.TOK_REAL) { if (! df->con_const.TOK_RSTR) {
char buf2[FLT_STRLEN]; char buf2[FLT_STRLEN];
flt_flt2str(&df->con_const.TOK_RVAL, buf2, FLT_STRLEN); flt_flt2str(&df->con_const.TOK_RVAL, buf2, FLT_STRLEN);
adds_db_str(buf2); adds_db_str(buf2);
} }
else adds_db_str(df->con_const.TOK_REAL); else adds_db_str(df->con_const.TOK_RSTR);
addc_db_str(';'); addc_db_str(';');
break; break;
case T_STRING: { case T_STRING: {