No longer made with amake
authorceriel <none@none>
Fri, 13 Sep 1991 14:53:27 +0000 (14:53 +0000)
committerceriel <none@none>
Fri, 13 Sep 1991 14:53:27 +0000 (14:53 +0000)
util/grind/.distr [new file with mode: 0644]
util/grind/Makefile [new file with mode: 0644]
util/grind/db_symtab.g
util/grind/expr.c
util/grind/main.c
util/grind/proto.main [new file with mode: 0644]
util/grind/proto.make [new file with mode: 0644]
util/grind/symbol.c

diff --git a/util/grind/.distr b/util/grind/.distr
new file mode 100644 (file)
index 0000000..7ea0a14
--- /dev/null
@@ -0,0 +1,51 @@
+Makefile
+PROBLEMS
+READ_ME
+avl.cc
+avl.h
+c.c
+char.ct
+class.h
+commands.g
+db_symtab.g
+do_comm.c
+expr.c
+expr.h
+file.hh
+grind.1
+idf.c
+idf.h
+itemlist.cc
+langdep.cc
+langdep.h
+list.c
+main.c
+make.allocd
+make.next
+make.ops
+make.tokcase
+make.tokfile
+message.h
+modula-2.c
+operator.h
+operators.ot
+pascal.c
+position.c
+position.h
+print.c
+proto.main
+proto.make
+rd.c
+rd.h
+run.c
+scope.cc
+scope.h
+symbol.c
+symbol.hh
+token.h
+tokenname.c
+tokenname.h
+tree.c
+tree.hh
+type.c
+type.hh
diff --git a/util/grind/Makefile b/util/grind/Makefile
new file mode 100644 (file)
index 0000000..e90d34d
--- /dev/null
@@ -0,0 +1,2 @@
+distr:
+       make.ops < operators.ot
index 1221fad..b5ac12b 100644 (file)
@@ -745,7 +745,9 @@ DbRead(f)
   register struct outname *n;
   register struct outname *line_file = 0;
   long OffsetStrings;
-  int had_lbrac = 0;
+  int lbrac_required = 0;
+  int needs_newscope = 0;
+  int lbrac_level = 0;
 
   /* Open file, read header, and check magic word */
   if (! rd_open(f)) {
@@ -828,16 +830,14 @@ DbRead(f)
                            CurrentScope->sc_bp_opp = n->on_valu;
                            if (! CurrentScope->sc_start) {
                                CurrentScope->sc_start = n->on_valu;
-                               if (CurrentScope->sc_has_activation_record) {
-                                       add_scope_addr(CurrentScope);
-                               }
+                               add_scope_addr(CurrentScope);
                            }
                        }
                        saw_code = 1;
                        add_position_addr(line_file->on_mptr, n);
                        break;
                case N_LBRAC:   /* block, desc = nesting level */
-                       if (had_lbrac) {
+                       if (lbrac_level && ! lbrac_required) {
                                open_scope((p_symbol) 0, 0);
                                saw_code = 0;
                        }
@@ -846,10 +846,11 @@ DbRead(f)
                                        get_scope_from_addr(n->on_valu);
 
                                if (!sc || sc->sc_bp_opp) {
-                                       had_lbrac = 1;
                                }
                                else CurrentScope = sc;
                        }
+                       lbrac_level++;
+                       needs_newscope = 1;
                        break;
 #ifdef N_SCOPE
                case N_SCOPE:
@@ -859,8 +860,9 @@ DbRead(f)
                        break;
 #endif
                case N_RBRAC:   /* end block, desc = nesting level */
-                       had_lbrac = 0;
                        if (CurrentScope != FileScope) close_scope();
+                       needs_newscope = 1;
+                       if (--lbrac_level == 0) needs_newscope = 0;
                        saw_code = 0;
                        break;
                case N_FUN:     /* function, value = address */
@@ -871,10 +873,11 @@ DbRead(f)
                case N_SSYM:    /* struct/union el, value = offset */
                case N_PSYM:    /* parameter, value = offset from AP */
                case N_LSYM:    /* local sym, value = offset from FP */
-                       if (had_lbrac) {
+                       if (needs_newscope) {
                                open_scope((p_symbol) 0, 0);
                                saw_code = 0;
-                               had_lbrac = 0;
+                               needs_newscope = 0;
+                               lbrac_required = 1;
                        }
                        if (n->on_mptr && strindex(n->on_mptr, ':')) {
                                n = DbString(n);
index af56042..6240e58 100644 (file)
@@ -165,8 +165,9 @@ get_v(a, pbuf, size)
                return 0;
        }
        if (! get_bytes(size, a, *pbuf)) return 0;
+       return 1;
   }
-  return 1;
+  return 0;
 }
 
 /* static int  get_value(p_symbol sym; char **pbuf; long *psize);
index 9a08590..2ff63ef 100644 (file)
@@ -87,7 +87,6 @@ main(argc, argv)
   }
   AckObj = argv[1] ? argv[1] : "a.out";
   if (argc == 3) AObj = argv[2];
-  init_idf();
   init_types();
   init_scope();
   init_languages();
diff --git a/util/grind/proto.main b/util/grind/proto.main
new file mode 100644 (file)
index 0000000..2d57b53
--- /dev/null
@@ -0,0 +1,54 @@
+# $Header$
+
+# C compilation part. Not to be called directly.
+# Instead, it is to be called by the Makefile.
+# SRC_DIR, UTIL_HOME, TARGET_HOME, CC, COPTIONS, LINT, LINTOPTIONS, LDOPTIONS,
+# CC_AND_MKDEP, SUF, LIBSUF should be set here.
+
+#PARAMS                do not remove this line!
+
+MDIR =         $(TARGET_HOME)/modules
+LIBDIR =       $(MDIR)/lib
+LINTLIBDIR =   $(UTIL_HOME)/modules/lib
+
+MALLOC =       $(LIBDIR)/malloc.$(SUF)
+
+MODLIB = \
+               $(LIBDIR)/libassert.$(LIBSUF) \
+               $(LIBDIR)/liballoc.$(LIBSUF) \
+               $(MALLOC) \
+               $(LIBDIR)/libprint.$(LIBSUF) \
+               $(LIBDIR)/libstring.$(LIBSUF) \
+               $(LIBDIR)/libsystem.$(LIBSUF)
+
+LIBS =         $(MODLIB)
+
+LINTLIBS = \
+               $(LINTLIBDIR)/$(LINTPREF)assert.$(LINTSUF) \
+               $(LINTLIBDIR)/$(LINTPREF)alloc.$(LINTSUF) \
+               $(LINTLIBDIR)/$(LINTPREF)print.$(LINTSUF) \
+               $(LINTLIBDIR)/$(LINTPREF)string.$(LINTSUF) \
+               $(LINTLIBDIR)/$(LINTPREF)system.$(LINTSUF)
+
+PROFILE =
+INCLUDES =     -I. -I$(SRC_DIR) -I$(TARGET_HOME)/modules/h -I$(TARGET_HOME)/h -I$(TARGET_HOME)/modules/pkg
+CFLAGS =       $(PROFILE) $(INCLUDES) $(COPTIONS)
+LINTFLAGS =    $(INCLUDES) $(LINTOPTIONS)
+LDFLAGS =      $(PROFILE) $(LDOPTIONS)
+
+# C_SRC and OBJ should be set here.
+#LISTS         do not remove this line!
+
+all:           main
+
+clean:
+               rm -f *.$(SUF) main
+
+lint:
+               $(LINT) $(LINTFLAGS) $(C_SRC) $(LINTLIBS)
+
+main:          $(OBJ)
+               $(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o main
+
+# do not remove the next line; it is used for generating dependencies
+#DEPENDENCIES
diff --git a/util/grind/proto.make b/util/grind/proto.make
new file mode 100644 (file)
index 0000000..6b08c8d
--- /dev/null
@@ -0,0 +1,186 @@
+# $Header$
+
+#PARAMS                do not remove this line!
+
+SRC_DIR = $(SRC_HOME)/util/grind
+UTIL_BIN = $(UTIL_HOME)/bin
+TABGEN=        $(UTIL_BIN)/tabgen
+LLGEN =        $(UTIL_BIN)/LLgen
+LLGENOPTIONS = -v
+
+SRC_G1 =       $(SRC_DIR)/commands.g
+GEN_G1 =       tokenfile.g
+GFILES1=       $(GEN_G1) $(SRC_G1)
+
+SRC_G2 =       $(SRC_DIR)/db_symtab.g
+GEN_G2 =       
+GFILES2 =      $(GEN_G2) $(SRC_G2)
+
+SRC_C = \
+       $(SRC_DIR)/main.c \
+       $(SRC_DIR)/list.c \
+       $(SRC_DIR)/tree.c \
+       $(SRC_DIR)/expr.c \
+       $(SRC_DIR)/position.c \
+       $(SRC_DIR)/tokenname.c \
+       $(SRC_DIR)/idf.c \
+       $(SRC_DIR)/run.c \
+       $(SRC_DIR)/symbol.c \
+       $(SRC_DIR)/print.c \
+       $(SRC_DIR)/type.c \
+       $(SRC_DIR)/rd.c \
+       $(SRC_DIR)/do_comm.c \
+       $(SRC_DIR)/modula-2.c \
+       $(SRC_DIR)/pascal.c \
+       $(SRC_DIR)/c.c
+GEN_C = db_symtab.c commands.c Lpars.c DBSpars.c avl.c scope.c itemlist.c \
+       langdep.c ops.c chtab.c symbol2str.c
+CFILES=        $(SRC_C) $(GEN_C)
+
+SRC_H = \
+       $(SRC_DIR)/tokenname.h \
+       $(SRC_DIR)/operator.h \
+       $(SRC_DIR)/class.h \
+       $(SRC_DIR)/position.h \
+       $(SRC_DIR)/idf.h \
+       $(SRC_DIR)/message.h \
+       $(SRC_DIR)/avl.h \
+       $(SRC_DIR)/scope.h \
+       $(SRC_DIR)/langdep.h \
+       $(SRC_DIR)/sizes.h \
+       $(SRC_DIR)/token.h \
+       $(SRC_DIR)/expr.h \
+       $(SRC_DIR)/rd.h
+GEN_H = file.h type.h symbol.h tree.h Lpars.h DBSpars.h ops.h
+HFILES=        $(GEN_H) $(SRC_H)
+
+NEXTFILES =    $(SRC_DIR)/file.hh \
+               $(SRC_DIR)/type.hh \
+               $(SRC_DIR)/symbol.hh \
+               $(SRC_DIR)/tree.hh \
+               $(SRC_DIR)/avl.cc \
+               $(SRC_DIR)/scope.cc \
+               $(SRC_DIR)/itemlist.cc \
+               $(SRC_DIR)/langdep.cc
+
+all:           make.main
+               make -f make.main grind
+
+install:       all
+               cp grind $(TARGET_HOME)/bin/grind
+               cp $(SRC_DIR)/grind.1 $(TARGET_HOME)/man/grind.1
+
+cmp:           all
+               -cmp grind $(TARGET_HOME)/bin/grind
+               -cmp $(SRC_DIR)/grind.1 $(TARGET_HOME)/man/grind.1
+
+opr:
+               make pr | opr
+
+pr:
+               @pr $(SRC_DIR)/proto.make $(SRC_DIR)/proto.main \
+                       $(SRC_DIR)/char.ct operators.ot \
+                       $(SRC_G1) $(SRC_G2) \
+                       $(SRC_H) $(NEXTFILES) \
+                       $(SRC_C)
+
+lint:          make.main
+               make -f make.main lint
+
+Cfiles:                hfiles LLfiles $(GEN_C) $(GEN_H) Makefile
+               echo $(CFILES) | tr ' ' '\012' > Cfiles
+               echo $(HFILES) | tr ' ' '\012' >> Cfiles
+
+resolved:      Cfiles
+               CC="$(CC)" UTIL_HOME="$(UTIL_HOME)" do_resolve `cat Cfiles` > Cfiles.new
+               -if cmp -s Cfiles Cfiles.new ; then rm -f Cfiles.new ; else mv Cfiles.new Cfiles ; fi
+               touch resolved
+
+# there is no file called "dependencies"; we want dependencies checked 
+# every time. This means that make.main is made every time. Oh well ...
+# it does not take much time.
+dependencies:  resolved
+               do_deps `grep '.c$$' Cfiles`
+
+make.main:     dependencies make_macros lists $(SRC_DIR)/proto.main
+               sed -e '/^#DEPENDENCIES/,$$d' -e '/^#PARAMS/r make_macros' -e '/^#LISTS/r lists' $(SRC_DIR)/proto.main > make.main
+               echo '#DEPENDENCIES' >> make.main
+               cat *.dep >> make.main
+
+make_macros:   Makefile
+               echo 'SRC_DIR=$(SRC_DIR)' > make_macros
+               echo 'UTIL_HOME=$(UTIL_HOME)' >> make_macros
+               echo 'TARGET_HOME=$(TARGET_HOME)' >> make_macros
+               echo 'CC=$(CC)' >> make_macros
+               echo 'COPTIONS=$(COPTIONS)' >> make_macros
+               echo 'LDOPTIONS=$(LDOPTIONS)' >> make_macros
+               echo 'LINT=$(LINT)' >> make_macros
+               echo 'LINTOPTIONS=$(LINTOPTIONS)' >> make_macros
+               echo 'SUF=$(SUF)' >> make_macros
+               echo 'LIBSUF=$(LIBSUF)' >> make_macros
+               echo 'CC_AND_MKDEP=$(CC_AND_MKDEP)' >> make_macros
+
+lists:         Cfiles
+               echo "C_SRC = \\" > lists
+               echo $(CFILES) >> lists
+               echo "OBJ = \\" >> lists
+               echo $(CFILES) | sed -e 's#[^ ]*/##g' -e 's/\.c/.$$(SUF)/g' >> lists
+
+clean:
+               -make -f make.main clean
+               rm -f $(GEN_C) $(GEN_G) $(GEN_H) \
+                       hfiles LL1files LL2files Cfiles LL.output DBS.output
+               rm -f resolved *.dep lists make.main make_macros
+
+LLfiles:       LL1files LL2files
+
+LL1files:      $(GFILES1)
+               $(LLGEN) $(LLGENOPTIONS) $(GFILES1)
+               @touch LL1files
+
+LL2files:      $(GFILES2)
+               $(LLGEN) $(LLGENOPTIONS) $(GFILES2)
+               @touch LL2files
+
+hfiles:                Parameters $(SRC_DIR)/make.hfiles
+               $(SRC_DIR)/make.hfiles Parameters
+               touch hfiles
+
+tokenfile.g:   $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokfile
+               $(SRC_DIR)/make.tokfile <$(SRC_DIR)/tokenname.c >tokenfile.g
+
+symbol2str.c:  $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokcase
+               $(SRC_DIR)/make.tokcase <$(SRC_DIR)/tokenname.c >symbol2str.c
+
+file.h:                $(SRC_DIR)/file.hh $(SRC_DIR)/make.allocd
+               $(SRC_DIR)/make.allocd < $(SRC_DIR)/file.hh > file.h
+
+symbol.h:      $(SRC_DIR)/symbol.hh $(SRC_DIR)/make.allocd
+               $(SRC_DIR)/make.allocd < $(SRC_DIR)/symbol.hh > symbol.h
+
+tree.h:                $(SRC_DIR)/tree.hh $(SRC_DIR)/make.allocd
+               $(SRC_DIR)/make.allocd < $(SRC_DIR)/tree.hh > tree.h
+
+type.h:                $(SRC_DIR)/type.hh $(SRC_DIR)/make.allocd
+               $(SRC_DIR)/make.allocd < $(SRC_DIR)/type.hh > type.h
+
+avl.c:         $(SRC_DIR)/avl.cc $(SRC_DIR)/make.allocd
+               $(SRC_DIR)/make.allocd < $(SRC_DIR)/avl.cc > avl.c
+
+itemlist.c:    $(SRC_DIR)/itemlist.cc $(SRC_DIR)/make.allocd
+               $(SRC_DIR)/make.allocd < $(SRC_DIR)/itemlist.cc > itemlist.c
+
+langdep.c:     $(SRC_DIR)/langdep.cc $(SRC_DIR)/make.allocd
+               $(SRC_DIR)/make.allocd < $(SRC_DIR)/langdep.cc > langdep.c
+
+scope.c:       $(SRC_DIR)/scope.cc $(SRC_DIR)/make.allocd
+               $(SRC_DIR)/make.allocd < $(SRC_DIR)/scope.cc > scope.c
+
+next.c:                $(NEXTFILES) $(SRC_DIR)/make.next
+               $(SRC_DIR)/make.next $(NEXTFILES) > next.c
+
+chtab.c:       $(SRC_DIR)/char.ct
+               $(TABGEN) -f$(SRC_DIR)/char.ct >chtab.c
+
+ops.c ops.h:   $(SRC_DIR)/operators.ot $(SRC_DIR)/make.ops
+               $(SRC_DIR)/make.ops < $(SRC_DIR)/operators.ot
index ee14fab..031099f 100644 (file)
@@ -285,16 +285,14 @@ static
 pr_scopes(sc)
   p_scope      sc;
 {
-  while (sc && ! sc->sc_definedby) {
-       sc = sc->sc_static_encl;
-  }
-  if (sc) {
-       pr_scopes(sc->sc_static_encl);
-       if (sc->sc_definedby->sy_class == FILESYM &&
+  if (! sc) return;
+  pr_scopes(sc->sc_static_encl);
+  if (sc->sc_definedby) {
+       if (sc->sc_definedby->sy_class == FILESYM &&
            sc->sc_definedby->sy_file->f_base) {
                fprintf(db_out, "%s`", sc->sc_definedby->sy_file->f_base->sy_idf->id_text);
-       }
-       else fprintf(db_out, "%s`", sc->sc_definedby->sy_idf->id_text);
+       }
+       else fprintf(db_out, "%s`", sc->sc_definedby->sy_idf->id_text);
   }
 }