1
/* $Header: d:/cvsroot/tads/tads3/TCUNAS.H,v 1.3 1999/07/11 00:46:58 MJRoberts Exp $ */
4
* Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved.
6
* Please see the accompanying license file, LICENSE.TXT, for information
7
* on using and copying this software.
11
tcunas.h - TADS 3 Compiler Unassembler
17
05/10/99 MJRoberts - Creation
30
/* ------------------------------------------------------------------------ */
32
* byte-code source for unassembler
38
* read the next byte; returns zero on success, non-zero at the end
41
virtual int next_byte(char *ch) = 0;
43
/* get the current offset */
44
virtual ulong get_ofs() const = 0;
48
* code stream implementation of byte code source
50
class CTcUnasSrcCodeStr: public CTcUnasSrc
53
CTcUnasSrcCodeStr(CTcCodeStream *str)
55
/* remember our underlying code stream */
58
/* start at the first byte of the code stream */
62
/* read from the code stream */
63
int next_byte(char *ch)
65
/* if there's anything left, return the byte and bump the pointer */
66
if (ofs_ < str_->get_ofs())
68
*ch = str_->get_byte_at(ofs_);
73
/* indicate end of file */
77
/* get the current offset */
84
/* underlying code stream object */
87
/* current read offset in code stream */
91
/* ------------------------------------------------------------------------ */
93
* output stream for unassembler
98
virtual ~CTcUnasOut() { }
100
/* write a line of text to the output, printf-style */
101
virtual void print(const char *fmt, ...) = 0;
105
* stdio implementation of output stream - writes data to standard
108
class CTcUnasOutStdio: public CTcUnasOut
111
void print(const char *fmt, ...)
115
/* display the data on the standard output */
123
* Text file (osfildef) implementation of output stream. The file handle
124
* is managed by the caller.
126
class CTcUnasOutFile: public CTcUnasOut
129
CTcUnasOutFile(osfildef *fp) { fp_ = fp; }
131
void print(const char *fmt, ...)
136
/* format the text */
138
t3vsprintf(buf, sizeof(buf), fmt, va);
141
/* write the formatted text to the file */
142
os_fprintz(fp_, buf);
146
/* our file handle */
150
#endif /* TCUNAS_H */