Added macro's for long selections
This commit is contained in:
parent
24fd4e190e
commit
76d79cf17a
|
@ -617,12 +617,12 @@ lexwarning(W_ORDINARY, "overflow in constant");
|
|||
|
||||
tk->tk_data.tk_real = new_real();
|
||||
if (np >= &buf[NUMSIZE]) {
|
||||
tk->TOK_REAL = Salloc("0.0", 4);
|
||||
tk->TOK_RSTR = Salloc("0.0", 4);
|
||||
lexerror("real constant too long");
|
||||
}
|
||||
else tk->TOK_REAL = Salloc(buf, (unsigned) (np - buf));
|
||||
else tk->TOK_RSTR = Salloc(buf, (unsigned) (np - buf));
|
||||
CheckForLet();
|
||||
flt_str2flt(tk->TOK_REAL, &(tk->TOK_RVAL));
|
||||
flt_str2flt(tk->TOK_RSTR, &(tk->TOK_RVAL));
|
||||
if (flt_status == FLT_OVFL) {
|
||||
lexwarning(W_ORDINARY, "overflow in floating point constant");
|
||||
}
|
||||
|
|
|
@ -30,17 +30,18 @@ struct token {
|
|||
struct real *tk_real; /* REAL */
|
||||
arith *tk_set; /* 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;
|
||||
};
|
||||
|
||||
typedef struct token t_token;
|
||||
|
||||
#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_SLE tk_data.tk_str->s_length
|
||||
#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
|
||||
|
||||
extern t_token dot, aside;
|
||||
|
|
|
@ -56,8 +56,8 @@ LLmessage(tk)
|
|||
break;
|
||||
case REAL:
|
||||
dotp->tk_data.tk_real = new_real();
|
||||
dotp->TOK_REAL = Salloc("0.0", 4);
|
||||
flt_str2flt(dotp->TOK_REAL, &dotp->TOK_RVAL);
|
||||
dotp->TOK_RSTR = Salloc("0.0", 4);
|
||||
flt_str2flt(dotp->TOK_RSTR, &dotp->TOK_RVAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ compact(nr, low, up)
|
|||
return (nr != 0 && diff >= 0 && fit(diff, (int) word_size) &&
|
||||
diff / nr <= (DENSITY - 1));
|
||||
}
|
||||
#define nd_lab nd_symb
|
||||
|
||||
int
|
||||
CaseCode(nd, exitlabel, end_reached)
|
||||
|
@ -110,11 +111,11 @@ CaseCode(nd, exitlabel, end_reached)
|
|||
if (pnode->nd_left) {
|
||||
/* non-empty case
|
||||
*/
|
||||
pnode->nd_lab = ++text_label;
|
||||
pnode->nd_left->nd_lab = ++text_label;
|
||||
AddCases(sh, /* to descriptor */
|
||||
pnode->nd_left->nd_left,
|
||||
/* of case labels */
|
||||
pnode->nd_lab
|
||||
(label) pnode->nd_left->nd_lab
|
||||
/* and code label */
|
||||
);
|
||||
}
|
||||
|
@ -194,7 +195,7 @@ CaseCode(nd, exitlabel, end_reached)
|
|||
while (pnode = pnode->nd_right) {
|
||||
if (pnode->nd_class == Link && pnode->nd_symb == '|') {
|
||||
if (pnode->nd_left) {
|
||||
rval |= LblWalkNode(pnode->nd_lab,
|
||||
rval |= LblWalkNode((label) pnode->nd_left->nd_lab,
|
||||
pnode->nd_left->nd_right,
|
||||
exitlabel, end_reached);
|
||||
C_bra(sh->sh_break);
|
||||
|
|
|
@ -102,8 +102,8 @@ MkCoercion(pnd, tp)
|
|||
wmess = "conversion";
|
||||
}
|
||||
if (!wmess || pass_1) {
|
||||
if (nd->nd_REAL) free(nd->nd_REAL);
|
||||
free_real(nd->nd_token.tk_data.tk_real);
|
||||
if (nd->nd_RSTR) free(nd->nd_RSTR);
|
||||
free_real(nd->nd_REAL);
|
||||
nd->nd_INT = op;
|
||||
nd->nd_symb = INTEGER;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ MkCoercion(pnd, tp)
|
|||
default:
|
||||
crash("MkCoercion");
|
||||
}
|
||||
nd->nd_token.tk_data.tk_real = p;
|
||||
nd->nd_REAL = p;
|
||||
nd->nd_symb = REAL;
|
||||
}
|
||||
break;
|
||||
|
@ -371,10 +371,10 @@ ChkExLinkOrName(expp)
|
|||
}
|
||||
else expp->nd_class = Value;
|
||||
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_token.tk_data.tk_real) = *p;
|
||||
expp->nd_REAL = new_real();
|
||||
*(expp->nd_REAL) = *p;
|
||||
if (p->r_real) {
|
||||
p->r_real = Salloc(p->r_real,
|
||||
(unsigned)(strlen(p->r_real)+1));
|
||||
|
@ -1021,9 +1021,9 @@ ChkUnOper(expp)
|
|||
if (right->nd_class == Value) {
|
||||
*expp = *right;
|
||||
flt_umin(&(expp->nd_RVAL));
|
||||
if (expp->nd_REAL) {
|
||||
free(expp->nd_REAL);
|
||||
expp->nd_REAL = 0;
|
||||
if (expp->nd_RSTR) {
|
||||
free(expp->nd_RSTR);
|
||||
expp->nd_RSTR = 0;
|
||||
}
|
||||
FreeNode(right);
|
||||
}
|
||||
|
@ -1447,7 +1447,7 @@ TryToString(nd, tp)
|
|||
if (tp->tp_fund == T_ARRAY && nd->nd_type == char_type) {
|
||||
buf[0] = nd->nd_INT;
|
||||
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));
|
||||
nd->nd_STR = Salloc(buf, 2);
|
||||
nd->nd_SLE = 1;
|
||||
|
|
|
@ -127,13 +127,13 @@ CodeExpr(nd, ds, true_label, false_label)
|
|||
switch(nd->nd_symb) {
|
||||
case REAL:
|
||||
C_df_dlb(++data_label);
|
||||
if (! nd->nd_REAL) {
|
||||
if (! nd->nd_RSTR) {
|
||||
static char buf[FLT_STRLEN];
|
||||
|
||||
flt_flt2str(&nd->nd_RVAL, buf, FLT_STRLEN);
|
||||
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_loi(tp->tp_size);
|
||||
break;
|
||||
|
@ -481,7 +481,7 @@ subu(sz)
|
|||
arith sz;
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ addu(sz)
|
|||
arith sz;
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -748,8 +748,9 @@ CodeOper(expr, true_label, false_label)
|
|||
case T_CARDINAL:
|
||||
case T_INTORCARD:
|
||||
if (! options['R']) {
|
||||
CAL((int)(tp->tp_size) <= (int)word_size ? "muluchk" : "mululchk",
|
||||
(int)(tp->tp_size));
|
||||
C_cal((int)(tp->tp_size) <= (int)word_size ?
|
||||
"muluchk" :
|
||||
"mululchk");
|
||||
}
|
||||
C_mlu(tp->tp_size);
|
||||
break;
|
||||
|
|
|
@ -269,7 +269,7 @@ cstfbin(expp)
|
|||
expressions below it, and the result restored in expp.
|
||||
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 *o2 = &expp->nd_right->nd_RVAL;
|
||||
int compar = 0;
|
||||
|
@ -312,8 +312,8 @@ cstfbin(expp)
|
|||
case '=': cmpval = (cmpval == 0); break;
|
||||
case '#': cmpval = (cmpval != 0); break;
|
||||
}
|
||||
if (expp->nd_right->nd_REAL) free(expp->nd_right->nd_REAL);
|
||||
free_real(expp->nd_right->nd_token.tk_data.tk_real);
|
||||
if (expp->nd_right->nd_RSTR) free(expp->nd_right->nd_RSTR);
|
||||
free_real(expp->nd_right->nd_REAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -343,7 +343,7 @@ cstfbin(expp)
|
|||
expp->nd_INT = cmpval;
|
||||
}
|
||||
else {
|
||||
expp->nd_token.tk_data.tk_real = p;
|
||||
expp->nd_REAL = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ LexScan()
|
|||
break;
|
||||
|
||||
case REAL:
|
||||
print("%s\n", tkp->TOK_REAL);
|
||||
print("%s\n", tkp->TOK_RSTR);
|
||||
break;
|
||||
|
||||
case STRING:
|
||||
|
|
|
@ -33,14 +33,15 @@ struct node {
|
|||
struct token nd_token;
|
||||
#define nd_set nd_token.tk_data.tk_set
|
||||
#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_lineno nd_token.tk_lineno
|
||||
#define nd_IDF nd_token.TOK_IDF
|
||||
#define nd_SSTR nd_token.TOK_SSTR
|
||||
#define nd_STR nd_token.TOK_STR
|
||||
#define nd_SLE nd_token.TOK_SLE
|
||||
#define nd_INT nd_token.TOK_INT
|
||||
#define nd_REAL nd_token.TOK_REAL
|
||||
#define nd_RSTR nd_token.TOK_RSTR
|
||||
#define nd_RVAL nd_token.TOK_RVAL
|
||||
};
|
||||
|
||||
|
|
|
@ -347,13 +347,13 @@ stb_string(df, kind)
|
|||
break;
|
||||
case T_REAL:
|
||||
addc_db_str('r');
|
||||
if (! df->con_const.TOK_REAL) {
|
||||
if (! df->con_const.TOK_RSTR) {
|
||||
char buf2[FLT_STRLEN];
|
||||
|
||||
flt_flt2str(&df->con_const.TOK_RVAL, buf2, FLT_STRLEN);
|
||||
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(';');
|
||||
break;
|
||||
case T_STRING: {
|
||||
|
|
Loading…
Reference in a new issue