file reorg, pathnames.h, paths.h
[unix-history] / usr / src / old / dbx / c.c
index 95b82b2..1bfe08d 100644 (file)
@@ -5,10 +5,10 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)c.c        5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)c.c        5.8 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-static char rcsid[] = "$Header: c.c,v 1.5 84/12/26 10:38:23 linton Exp $";
+static char rcsid[] = "$Header: c.c,v 1.5 88/04/02 01:25:44 donn Exp $";
 
 /*
  * C-dependent symbol routines.
 
 /*
  * C-dependent symbol routines.
@@ -28,7 +28,7 @@ static char rcsid[] = "$Header: c.c,v 1.5 84/12/26 10:38:23 linton Exp $";
 #include "machine.h"
 
 #ifndef public
 #include "machine.h"
 
 #ifndef public
-# include "tree.h"
+#   include "tree.h"
 #endif
 
 #define isdouble(range) ( \
 #endif
 
 #define isdouble(range) ( \
@@ -38,6 +38,7 @@ static char rcsid[] = "$Header: c.c,v 1.5 84/12/26 10:38:23 linton Exp $";
 #define isrange(t, name) (t->class == RANGE and istypename(t->type, name))
 
 private Language langC;
 #define isrange(t, name) (t->class == RANGE and istypename(t->type, name))
 
 private Language langC;
+private Language langCplpl;
 
 /*
  * Initialize C language information.
 
 /*
  * Initialize C language information.
@@ -54,6 +55,16 @@ public c_init()
     language_setop(langC, L_MODINIT, c_modinit);
     language_setop(langC, L_HASMODULES, c_hasmodules);
     language_setop(langC, L_PASSADDR, c_passaddr);
     language_setop(langC, L_MODINIT, c_modinit);
     language_setop(langC, L_HASMODULES, c_hasmodules);
     language_setop(langC, L_PASSADDR, c_passaddr);
+
+    langCplpl = language_define("c++", "..c");
+    language_setop(langCplpl, L_PRINTDECL, c_printdecl);
+    language_setop(langCplpl, L_PRINTVAL, c_printval);
+    language_setop(langCplpl, L_TYPEMATCH, c_typematch);
+    language_setop(langCplpl, L_BUILDAREF, c_buildaref);
+    language_setop(langCplpl, L_EVALAREF, c_evalaref);
+    language_setop(langCplpl, L_MODINIT, c_modinit);
+    language_setop(langCplpl, L_HASMODULES, c_hasmodules);
+    language_setop(langCplpl, L_PASSADDR, c_passaddr);
 }
 
 /*
 }
 
 /*
@@ -80,7 +91,7 @@ Symbol type1, type2;
        }
        b = (Boolean) (
            (
        }
        b = (Boolean) (
            (
-               isrange(t1, "int") and
+               isrange(t1, "int") and !isdouble(t1) /* sigh */ and
                (t2 == t_int->type or t2 == t_char->type)
            ) or (
                isrange(t1, "char") and
                (t2 == t_int->type or t2 == t_char->type)
            ) or (
                isrange(t1, "char") and
@@ -92,7 +103,7 @@ Symbol type1, type2;
                t1->symvalue.rangev.lower == t2->symvalue.rangev.lower and
                t1->symvalue.rangev.upper == t2->symvalue.rangev.upper
            ) or (
                t1->symvalue.rangev.lower == t2->symvalue.rangev.lower and
                t1->symvalue.rangev.upper == t2->symvalue.rangev.upper
            ) or (
-               t1->type == t2->type and (
+               t1->class != RANGE and t1->type == t2->type and (
                    (t1->class == t2->class) or
                    (t1->class == SCAL and t2->class == CONST) or
                    (t1->class == CONST and t2->class == SCAL)
                    (t1->class == t2->class) or
                    (t1->class == SCAL and t2->class == CONST) or
                    (t1->class == CONST and t2->class == SCAL)
@@ -146,7 +157,7 @@ Integer indent;
 
        case TYPE:
        case VAR:
 
        case TYPE:
        case VAR:
-           if (s->class != TYPE and s->level < 0) {
+           if (s->class != TYPE and s->storage == INREG) {
                printf("register ");
            }
            if (s->type->class == ARRAY) {
                printf("register ");
            }
            if (s->type->class == ARRAY) {
@@ -299,7 +310,7 @@ Integer indent;
                    printf("%s ", p);
                }
            }
                    printf("%s ", p);
                }
            }
-           printf("{\n", t->class == RECORD ? "struct" : "union");
+           printf("{\n");
            for (i = t->chain; i != nil; i = i->chain) {
                assert(i->class == FIELD);
                printdecl(i, indent+4);
            for (i = t->chain; i != nil; i = i->chain) {
                assert(i->class == FIELD);
                printdecl(i, indent+4);
@@ -434,6 +445,7 @@ Symbol s;
     register Symbol t;
     register Address a;
     integer i, len;
     register Symbol t;
     register Address a;
     integer i, len;
+    register String str;
 
     switch (s->class) {
        case CONST:
 
     switch (s->class) {
        case CONST:
@@ -447,10 +459,7 @@ Symbol s;
 
        case FIELD:
            if (isbitfield(s)) {
 
        case FIELD:
            if (isbitfield(s)) {
-               i = 0;
-               popn(size(s), &i);
-               i >>= (s->symvalue.field.offset mod BITSPERBYTE);
-               i &= ((1 << s->symvalue.field.length) - 1);
+               i = extractField(s);
                t = rtype(s->type);
                if (t->class == SCAL) {
                    printEnum(i, t);
                t = rtype(s->type);
                if (t->class == SCAL) {
                    printEnum(i, t);
@@ -468,11 +477,18 @@ Symbol s;
                t == t_char->type
            ) {
                len = size(s);
                t == t_char->type
            ) {
                len = size(s);
-               sp -= len;
-               if (s->language == primlang) {
-                   printf("%.*s", len, sp);
-               } else {
-                   printf("\"%.*s\"", len, sp);
+               str = (String) (sp -= len);
+               if (s->language != primlang) {
+                   putchar('"');
+               }
+               while (--len > 0 and *str != '\0') {
+                   printchar(*str++);
+               }
+               if (*str != '\0') {     /* XXX - pitch trailing null */
+                   printchar(*str);
+               }
+               if (s->language != primlang) {
+                   putchar('"');
                }
            } else {
                printarray(s);
                }
            } else {
                printarray(s);
@@ -491,7 +507,7 @@ Symbol s;
            } else if (s == t_real->type or isdouble(s)) {
                switch (s->symvalue.rangev.lower) {
                    case sizeof(float):
            } else if (s == t_real->type or isdouble(s)) {
                switch (s->symvalue.rangev.lower) {
                    case sizeof(float):
-                       prtreal(pop(float));
+                       prtreal((double) (pop(float)));
                        break;
 
                    case sizeof(double):
                        break;
 
                    case sizeof(double):
@@ -676,7 +692,7 @@ long i;
     lb = s->symvalue.rangev.lower;
     ub = s->symvalue.rangev.upper;
     if (i < lb or i > ub) {
     lb = s->symvalue.rangev.lower;
     ub = s->symvalue.rangev.upper;
     if (i < lb or i > ub) {
-       error("subscript out of range");
+       warning("subscript out of range");
     }
     push(long, base + (i - lb) * size(t->type));
 }
     }
     push(long, base + (i - lb) * size(t->type));
 }