Fixes involving floating point constants and debugger support
authorceriel <none@none>
Fri, 1 Nov 1991 10:15:15 +0000 (10:15 +0000)
committerceriel <none@none>
Fri, 1 Nov 1991 10:15:15 +0000 (10:15 +0000)
lang/pc/comp/LLlex.c
lang/pc/comp/LLlex.h
lang/pc/comp/LLmessage.c
lang/pc/comp/code.c
lang/pc/comp/expression.g
lang/pc/comp/node.H
lang/pc/comp/stab.c

index 9648723..a28138d 100644 (file)
@@ -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;
index dfe8209..7aa6f54 100644 (file)
@@ -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;
index 101a649..1f7fe04 100644 (file)
@@ -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;
                }
index a80d6e7..b19db9d 100644 (file)
@@ -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 )
index 3ba7e1e..c219610 100644 (file)
@@ -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;
                                }
 ;
 
index fabf566..1f8c56d 100644 (file)
@@ -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 */
index 417f002..19fc45b 100644 (file)
@@ -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;