Debian Codegraph @

terps/tads/tads2/lin.h

raw symbols SCIP
1 /*
2 $Header: d:/cvsroot/tads/TADS2/LIN.H,v 1.2 1999/05/17 02:52:12 MJRoberts Exp $
3 */
4
5 /*
6 * Copyright (c) 1991, 2002 Michael J. Roberts. All Rights Reserved.
7 *
8 * Please see the accompanying license file, LICENSE.TXT, for information
9 * on using and copying this software.
10 */
11 /*
12 Name
13 lin.h - line source definitions
14 Function
15 Definitions for the basic line source class
16 Notes
17 A line source is a mechanism for reading source text. The tokenizer
18 reads its input from a line source. This is the basic class
19 definition; individual line sources will define the functions and
20 class data needed.
21 Modified
22 08/14/91 MJRoberts - creation
23 */
24
25 #ifndef LIN_INCLUDED
26 #define LIN_INCLUDED
27
28 #ifndef LIB_INCLUDED
29 #include "lib.h"
30 #endif
31 #ifndef OS_INCLUDED
32 #include "os.h"
33 #endif
34 #ifndef OBJ_INCLUDED
35 #include "obj.h"
36 #endif
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42
43 /* line source superclass structure */
44 typedef struct lindef lindef;
45 struct lindef
46 {
47 int (*lingetp)(lindef *lin); /* get next line */
48 void (*linclsp)(lindef *lin); /* close line source */
49 void (*linppos)(lindef *lin, char *buf, uint buflen);
50 /* write printable rep of position to buf (for error reporting) */
51 void (*linglop)(lindef *lin, uchar *buf);
52 /* generate a line record for an OPCLINE instruction */
53 int (*linwrtp)(lindef *lin, osfildef *fp);
54 /* write line source information to binary file; TRUE ==> error */
55 void (*lincmpp)(lindef *lin, uchar *buf);
56 /* give location of compiled code for current line to line source */
57 void (*linactp)(lindef *lin); /* activate for dbg */
58 void (*lindisp)(lindef *lin); /* disactivate */
59 void (*lintellp)(lindef *lin, uchar *pos); /* get position */
60 void (*linseekp)(lindef *lin, uchar *pos); /* seek */
61 int (*linreadp)(lindef *lin, uchar *buf, uint siz); /* fread */
62 void (*linpaddp)(lindef *lin, uchar *pos, long delta);
63 /* add an offset to a position value */
64 int (*linqtopp)(lindef *lin, uchar *pos); /* at top? */
65 int (*lingetsp)(lindef *lin, uchar *buf, uint siz); /* get line */
66 void (*linnamp)(lindef *lin, char *buf); /* get source name */
67 void (*linfindp)(lindef *lin, char *buf, objnum *objp,
68 uint *ofsp); /* find nearest line record */
69 void (*lingotop)(lindef *lin, int where); /* seek global */
70 long (*linofsp)(lindef *lin); /* byte offset in line source */
71 void (*linrenp)(lindef *lin, objnum oldnum, objnum newnum);
72 /* renumber an object (for "modify") */
73 void (*lindelp)(lindef *lin, objnum objn);
74 /* delete an object (for "replace") */
75 ulong (*linlnump)(lindef *lin); /* get the current line number */
76 # define LINGOTOP OSFSK_SET /* go to top of line source */
77 # define LINGOEND OSFSK_END /* go to end of line source */
78 lindef *linpar; /* parent of current line source */
79 lindef *linnxt; /* next line in line source chain */
80 int linid; /* serial number of line source (for debugger) */
81 char *linbuf; /* pointer to current line */
82 ushort linflg; /* flags */
83 # define LINFEOF 0x01 /* line source is at end of file */
84 # define LINFMORE 0x02 /* there's more to the line than linlen */
85 # define LINFDBG 0x04 /* debug record already generated for line */
86 # define LINFNOINC 0x08 /* ignore # directives from this line source */
87 # define LINFCMODE 0x10 /* line source is parsed in C-mode */
88 ushort linlen; /* length of the line */
89 ushort linlln; /* length of line record generated by lingloc */
90 };
91
92 /*
93 * Maximum allowed value for linlln, in bytes. This allows subsystems
94 * that need to maintain local copies of seek locations to know how big
95 * an area to allocate for them.
96 */
97 #define LINLLNMAX 20
98
99 /* macros to cover calls to functions */
100 #define linget(lin) ((*((lindef *)(lin))->lingetp)((lindef *)(lin)))
101 #define lincls(lin) ((*((lindef *)(lin))->linclsp)((lindef *)(lin)))
102 #define linppos(lin, buf, buflen) \
103 ((*((lindef *)(lin))->linppos)((lindef *)(lin), buf, buflen))
104 #define linglop(lin, buf) ((*((lindef *)(lin))->linglop)(lin, buf))
105 #define linwrt(lin, fp) ((*((lindef *)(lin))->linwrtp)(lin, fp))
106 #define lincmpinf(lin, buf) ((*((lindef *)(lin))->lincmpp)(lin, buf))
107 #define linactiv(lin) ((*((lindef *)(lin))->linactp)(lin))
108 #define lindisact(lin) ((*((lindef *)(lin))->lindisp)(lin))
109 #define lintell(lin, pos) ((*((lindef *)(lin))->lintellp)(lin, pos))
110 #define linseek(lin, pos) ((*((lindef *)(lin))->linseekp)(lin, pos))
111 #define linread(lin, buf, siz) ((*((lindef *)(lin))->linreadp)(lin, buf, siz))
112 #define linpadd(lin, pos, delta) \
113 ((*((lindef *)(lin))->linpaddp)(lin, pos, delta))
114 #define linqtop(lin, pos) ((*((lindef *)(lin))->linqtopp)(lin, pos))
115 #define lingets(lin, buf, siz) ((*((lindef *)(lin))->lingetsp)(lin, buf, siz))
116 #define linnam(lin, buf) ((*((lindef *)(lin))->linnamp)(lin, buf))
117 #define linlnum(lin) ((*((lindef *)(lin))->linlnump)(lin))
118 #define linfind(lin, buf, objp, ofsp) \
119 ((*((lindef *)(lin))->linfindp)(lin, buf, objp, ofsp))
120 #define lingoto(lin, where) ((*((lindef *)(lin))->lingotop)(lin, where))
121 #define linofs(lin) ((*((lindef *)(lin))->linofsp)(lin))
122 #define linrenum(lin, oldnum, newnum) \
123 ((*((lindef *)(lin))->linrenp)(lin, oldnum, newnum))
124 #define lindelnum(lin, objn) ((*((lindef *)(lin))->lindelp)(lin, objn))
125
126
127 #ifdef __cplusplus
128 }
129 #endif
130
131 #endif /* LIN_INCLUDED */