From: ceriel Date: Fri, 1 Nov 1991 10:15:15 +0000 (+0000) Subject: Fixes involving floating point constants and debugger support X-Git-Tag: release-5-5~668 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ab6d563a7b74f9c68b6a6871025d8e44516db375;p=ack.git Fixes involving floating point constants and debugger support --- diff --git a/lang/pc/comp/LLlex.c b/lang/pc/comp/LLlex.c index 96487236e..a28138dee 100644 --- a/lang/pc/comp/LLlex.c +++ b/lang/pc/comp/LLlex.c @@ -454,10 +454,11 @@ again: #define REAL_MODE 1 char buf[NUMSIZE+2]; - register char *np = buf; + register char *np = &buf[1]; register int state = INT_MODE; extern char *Salloc(); + buf[0] = '-'; do { if( np <= &buf[NUMSIZE] ) *np++ = ch; @@ -526,7 +527,7 @@ again: lexerror("constant too long"); } else { - np = buf; + np = &buf[1]; while (*np == '0') /* skip leading zeros */ np++; tk->TOK_INT = str2long(np, 10); @@ -545,16 +546,18 @@ again: /* allocate struct for inverse */ tk->TOK_RIV = (struct real *) Malloc(sizeof(struct real)); tk->TOK_RIV->r_inverse = tk->tk_data.tk_real; - - /* sign */ - tk->TOK_RSI = 0; - tk->TOK_RIV->r_sign = 1; + tk->TOK_RLA = 0; + tk->TOK_RIV->r_lab = 0; if( np > &buf[NUMSIZE+1] ) { tk->TOK_REL = Salloc("0.0", 4); + tk->TOK_RIV->r_real = tk->TOK_REL; 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; return tk->tk_symb = REAL; diff --git a/lang/pc/comp/LLlex.h b/lang/pc/comp/LLlex.h index dfe82097b..7aa6f5420 100644 --- a/lang/pc/comp/LLlex.h +++ b/lang/pc/comp/LLlex.h @@ -14,7 +14,6 @@ struct real { char *r_real; /* string representation of real */ struct real *r_inverse; /* the inverse of this 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 @@ -41,7 +40,6 @@ struct token { #define TOK_REL tk_data.tk_real->r_real #define TOK_RIV tk_data.tk_real->r_inverse #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 type *toktype, *asidetype; diff --git a/lang/pc/comp/LLmessage.c b/lang/pc/comp/LLmessage.c index 101a649c5..1f7fe0487 100644 --- a/lang/pc/comp/LLmessage.c +++ b/lang/pc/comp/LLmessage.c @@ -62,11 +62,8 @@ LLmessage(tk) Malloc(sizeof(struct 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_RIV->r_real = dotp->TOK_REL; toktype = real_type; break; } diff --git a/lang/pc/comp/code.c b/lang/pc/comp/code.c index a80d6e718..b19db9d72 100644 --- a/lang/pc/comp/code.c +++ b/lang/pc/comp/code.c @@ -52,9 +52,11 @@ RomString(nd) RomReal(nd) register struct node *nd; { - C_df_dlb(++data_label); - C_rom_fcon(nd->nd_REL, nd->nd_type->tp_size); - nd->nd_RLA = nd->nd_RIV->r_lab = data_label; + if (! nd->nd_RLA) { + C_df_dlb(++data_label); + nd->nd_RLA = data_label; + C_rom_fcon(nd->nd_REL, nd->nd_type->tp_size); + } } BssVar() @@ -291,10 +293,9 @@ CodeExpr(nd, ds, true_label) C_loc(nd->nd_INT); break; case REAL: + RomReal(nd); C_lae_dlb(nd->nd_RLA, (arith) 0); C_loi(tp->tp_size); - if( nd->nd_RSI ) - C_ngf(tp->tp_size); break; case STRING: if( tp->tp_fund == T_CHAR ) diff --git a/lang/pc/comp/expression.g b/lang/pc/comp/expression.g index 3ba7e1e35..c21961006 100644 --- a/lang/pc/comp/expression.g +++ b/lang/pc/comp/expression.g @@ -45,8 +45,7 @@ Sign(register struct node **pnd;): UnsignedNumber(register struct node **pnd;): [INTEGER | REAL] { *pnd = MkLeaf(Value, &dot); - if( ((*pnd)->nd_type = toktype) == real_type ) - RomReal(*pnd); + (*pnd)->nd_type = toktype; } ; diff --git a/lang/pc/comp/node.H b/lang/pc/comp/node.H index fabf56633..1f8c56d3e 100644 --- a/lang/pc/comp/node.H +++ b/lang/pc/comp/node.H @@ -37,7 +37,6 @@ struct node { #define nd_REL nd_token.TOK_REL #define nd_RLA nd_token.TOK_RLA #define nd_RIV nd_token.TOK_RIV -#define nd_RSI nd_token.TOK_RSI }; /* ALLOCDEF "node" 50 */ diff --git a/lang/pc/comp/stab.c b/lang/pc/comp/stab.c index 417f00203..19fc45b0c 100644 --- a/lang/pc/comp/stab.c +++ b/lang/pc/comp/stab.c @@ -352,7 +352,7 @@ stb_string(df, kind) case T_ENUMERATION: addc_db_str('e'); 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; case T_SET: { register int i;