C:/Users/Dennis/src/lang/russell.orig/src/vr.c

Go to the documentation of this file.
00001 /*
00002  *  ROUTINE TO CONVERT VIRTUAL LINE NUMBERS IN SYNTAX TREE TO REAL
00003  *             LINE NUMBERS AND FILE NAMES 
00004  */
00005 
00006 /*
00007  *    To accomplish the conversion the following sequence of calls
00008  * must be used:
00009  *      1) findvl(virtual_line_number);
00010  *      2) getfn()  and/or  getrl()  can then be used to obtain the
00011  *         corresponding file name and/or real line number.
00012  */
00013  
00014 # include "parm.h"
00015 # include <stdio.h>
00016 
00017 # define NIL 0
00018 # define DEBUG DEBUG
00019 
00020 /*
00021  * Declarations for table of virtual line numbers versus real line
00022  * numbers and filenames. The table is created by the scanner and
00023  * then used by later passes to convert a virtual line number
00024  * stored in the syntax tree to the real line number printed in
00025  * an error message.
00026  */
00027 typedef struct VrLine{
00028     int vr_vline,            /* virtual line number at which file */
00029                              /* change or line number jump occurred */
00030         vr_rline,            /* corresponding real line number */
00031         vr_fname;            /* string table index of filename */
00032     struct VrLine * vr_next; /* pointer to next record */  } vrline;
00033 
00034 extern vrline * vrtable;  /* pointer to first table entry */
00035 
00036 static vrline * vrptr = NIL; /* set by findvl to point to the last record */
00037                              /* in vrtable with vr_vline < its agrument   */
00038 static int lastvl; /* last argument to findvl */
00039 
00040 findvl(vln)   
00041 register int vln;
00042 {
00043     register vrline *p,   /* pointer to current record  */
00044                     *q;   /* pointer to previous record */
00045     lastvl = vln;
00046     p = vrtable;
00047     q = NIL;
00048     while ( p != NIL && ((p -> vr_vline) <= vln) ) {
00049         q = p;
00050         p = p -> vr_next;
00051     }
00052     vrptr = q;
00053 #   ifdef DEBUG
00054         if ( q == NIL ) {
00055             dbgmsg("findvl: no vrline entry for vline: %d\n", vln);
00056             abort();
00057         }
00058 #   endif
00059 }
00060 
00061 char *
00062 getfn()
00063 {
00064 #   ifdef DEBUG
00065         if ( vrptr == NIL ) {
00066             dbgmsg("getfn: ommitted call to findvl\n");
00067             abort();
00068         }
00069 #   endif
00070     return( vrptr -> vr_fname );
00071 }
00072 
00073 getrl()
00074 {
00075 #   ifdef DEBUG
00076         if ( vrptr == NIL ) {
00077             dbgmsg("getrl: ommitted call to findvl\n");
00078             abort();
00079         }
00080 #   endif
00081 
00082     return( (vrptr -> vr_rline) + (lastvl - (vrptr -> vr_vline)) );
00083 }
00084 
00085 

Generated on Fri Jan 25 10:39:48 2008 for russell by  doxygen 1.5.4