Fixes involving floating point constants and debugger support
This commit is contained in:
parent
44cc075183
commit
ab6d563a7b
7 changed files with 19 additions and 22 deletions
|
@ -454,10 +454,11 @@ again:
|
||||||
#define REAL_MODE 1
|
#define REAL_MODE 1
|
||||||
|
|
||||||
char buf[NUMSIZE+2];
|
char buf[NUMSIZE+2];
|
||||||
register char *np = buf;
|
register char *np = &buf[1];
|
||||||
register int state = INT_MODE;
|
register int state = INT_MODE;
|
||||||
extern char *Salloc();
|
extern char *Salloc();
|
||||||
|
|
||||||
|
buf[0] = '-';
|
||||||
do {
|
do {
|
||||||
if( np <= &buf[NUMSIZE] )
|
if( np <= &buf[NUMSIZE] )
|
||||||
*np++ = ch;
|
*np++ = ch;
|
||||||
|
@ -526,7 +527,7 @@ again:
|
||||||
lexerror("constant too long");
|
lexerror("constant too long");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
np = buf;
|
np = &buf[1];
|
||||||
while (*np == '0') /* skip leading zeros */
|
while (*np == '0') /* skip leading zeros */
|
||||||
np++;
|
np++;
|
||||||
tk->TOK_INT = str2long(np, 10);
|
tk->TOK_INT = str2long(np, 10);
|
||||||
|
@ -545,16 +546,18 @@ again:
|
||||||
/* allocate struct for inverse */
|
/* allocate struct for inverse */
|
||||||
tk->TOK_RIV = (struct real *) Malloc(sizeof(struct real));
|
tk->TOK_RIV = (struct real *) Malloc(sizeof(struct real));
|
||||||
tk->TOK_RIV->r_inverse = tk->tk_data.tk_real;
|
tk->TOK_RIV->r_inverse = tk->tk_data.tk_real;
|
||||||
|
tk->TOK_RLA = 0;
|
||||||
/* sign */
|
tk->TOK_RIV->r_lab = 0;
|
||||||
tk->TOK_RSI = 0;
|
|
||||||
tk->TOK_RIV->r_sign = 1;
|
|
||||||
|
|
||||||
if( np > &buf[NUMSIZE+1] ) {
|
if( np > &buf[NUMSIZE+1] ) {
|
||||||
tk->TOK_REL = Salloc("0.0", 4);
|
tk->TOK_REL = Salloc("0.0", 4);
|
||||||
|
tk->TOK_RIV->r_real = tk->TOK_REL;
|
||||||
lexerror("floating constant too long");
|
lexerror("floating constant too long");
|
||||||
}
|
}
|
||||||
else tk->TOK_REL = Salloc(buf,(unsigned) (np - buf));
|
else {
|
||||||
|
tk->TOK_RIV->r_real = Salloc(buf,(unsigned) (np - buf));
|
||||||
|
tk->TOK_REL = tk->TOK_RIV->r_real + 1;
|
||||||
|
}
|
||||||
|
|
||||||
toktype = real_type;
|
toktype = real_type;
|
||||||
return tk->tk_symb = REAL;
|
return tk->tk_symb = REAL;
|
||||||
|
|
|
@ -14,7 +14,6 @@ struct real {
|
||||||
char *r_real; /* string representation of real */
|
char *r_real; /* string representation of real */
|
||||||
struct real *r_inverse; /* the inverse of this real */
|
struct real *r_inverse; /* the inverse of this real */
|
||||||
label r_lab; /* data label of real */
|
label r_lab; /* data label of real */
|
||||||
int r_sign; /* positive or negative */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Token structure. Keep it small, as it is part of a parse-tree node
|
/* Token structure. Keep it small, as it is part of a parse-tree node
|
||||||
|
@ -41,7 +40,6 @@ struct token {
|
||||||
#define TOK_REL tk_data.tk_real->r_real
|
#define TOK_REL tk_data.tk_real->r_real
|
||||||
#define TOK_RIV tk_data.tk_real->r_inverse
|
#define TOK_RIV tk_data.tk_real->r_inverse
|
||||||
#define TOK_RLA tk_data.tk_real->r_lab
|
#define TOK_RLA tk_data.tk_real->r_lab
|
||||||
#define TOK_RSI tk_data.tk_real->r_sign
|
|
||||||
|
|
||||||
extern struct token dot, aside;
|
extern struct token dot, aside;
|
||||||
extern struct type *toktype, *asidetype;
|
extern struct type *toktype, *asidetype;
|
||||||
|
|
|
@ -62,11 +62,8 @@ LLmessage(tk)
|
||||||
Malloc(sizeof(struct real));
|
Malloc(sizeof(struct real));
|
||||||
dotp->TOK_RIV->r_inverse = dotp->tk_data.tk_real;
|
dotp->TOK_RIV->r_inverse = dotp->tk_data.tk_real;
|
||||||
|
|
||||||
/* sign */
|
|
||||||
dotp->TOK_RSI = 0;
|
|
||||||
dotp->TOK_RIV->r_sign = 1;
|
|
||||||
|
|
||||||
dotp->TOK_REL = Salloc("0.0", 4);
|
dotp->TOK_REL = Salloc("0.0", 4);
|
||||||
|
dotp->TOK_RIV->r_real = dotp->TOK_REL;
|
||||||
toktype = real_type;
|
toktype = real_type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,11 @@ RomString(nd)
|
||||||
RomReal(nd)
|
RomReal(nd)
|
||||||
register struct node *nd;
|
register struct node *nd;
|
||||||
{
|
{
|
||||||
C_df_dlb(++data_label);
|
if (! nd->nd_RLA) {
|
||||||
C_rom_fcon(nd->nd_REL, nd->nd_type->tp_size);
|
C_df_dlb(++data_label);
|
||||||
nd->nd_RLA = nd->nd_RIV->r_lab = data_label;
|
nd->nd_RLA = data_label;
|
||||||
|
C_rom_fcon(nd->nd_REL, nd->nd_type->tp_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BssVar()
|
BssVar()
|
||||||
|
@ -291,10 +293,9 @@ CodeExpr(nd, ds, true_label)
|
||||||
C_loc(nd->nd_INT);
|
C_loc(nd->nd_INT);
|
||||||
break;
|
break;
|
||||||
case REAL:
|
case REAL:
|
||||||
|
RomReal(nd);
|
||||||
C_lae_dlb(nd->nd_RLA, (arith) 0);
|
C_lae_dlb(nd->nd_RLA, (arith) 0);
|
||||||
C_loi(tp->tp_size);
|
C_loi(tp->tp_size);
|
||||||
if( nd->nd_RSI )
|
|
||||||
C_ngf(tp->tp_size);
|
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
if( tp->tp_fund == T_CHAR )
|
if( tp->tp_fund == T_CHAR )
|
||||||
|
|
|
@ -45,8 +45,7 @@ Sign(register struct node **pnd;):
|
||||||
|
|
||||||
UnsignedNumber(register struct node **pnd;):
|
UnsignedNumber(register struct node **pnd;):
|
||||||
[INTEGER | REAL] { *pnd = MkLeaf(Value, &dot);
|
[INTEGER | REAL] { *pnd = MkLeaf(Value, &dot);
|
||||||
if( ((*pnd)->nd_type = toktype) == real_type )
|
(*pnd)->nd_type = toktype;
|
||||||
RomReal(*pnd);
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ struct node {
|
||||||
#define nd_REL nd_token.TOK_REL
|
#define nd_REL nd_token.TOK_REL
|
||||||
#define nd_RLA nd_token.TOK_RLA
|
#define nd_RLA nd_token.TOK_RLA
|
||||||
#define nd_RIV nd_token.TOK_RIV
|
#define nd_RIV nd_token.TOK_RIV
|
||||||
#define nd_RSI nd_token.TOK_RSI
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ALLOCDEF "node" 50 */
|
/* ALLOCDEF "node" 50 */
|
||||||
|
|
|
@ -352,7 +352,7 @@ stb_string(df, kind)
|
||||||
case T_ENUMERATION:
|
case T_ENUMERATION:
|
||||||
addc_db_str('e');
|
addc_db_str('e');
|
||||||
stb_type(tp, 0);
|
stb_type(tp, 0);
|
||||||
adds_db_str(sprint(buf, ",%ld;", (long) df->enm_val));
|
adds_db_str(sprint(buf, ",%ld;", (long) df->con_const->nd_INT));
|
||||||
break;
|
break;
|
||||||
case T_SET: {
|
case T_SET: {
|
||||||
register int i;
|
register int i;
|
||||||
|
|
Loading…
Reference in a new issue