STFE(3) RISC/os Reference Manual STFE(3)
NAME
stfe - routines that provide a high-level interface to basic
functions needed to access and add to the symbol table
SYNOPSIS
#include <syms.h>
long stfilebegin (filename, lang, merge, glevel)
char *filename;
long lang;
long merge;
long glevel;
long stendallfiles ()
long stfileend (idn)
long idn;
long stblockbegin(iss, value, sc)
long iss;
long value;
long sc;
long sttextblock()
long stblockend(size)
long size;
long stprocend(idn)
long idn
long stprocbegin (idn)
long idn;
char *ststridn (idn)
long idn;
char *stsymidn (idn, value, sc, st, index)
long idn;
long *value;
long *sc;
long *st;
long *index;
long stabsifdindex (ifd, index)
long ifd;
long index;
long stfglobalidn (idn)
long idn;
Printed 11/19/92 Page 1
STFE(3) RISC/os Reference Manual STFE(3)
pSYMR stpsymidnoffset (idn, offset)
long idn;
long offset;
long stpdaddidn (idn)
long idn;
DESCRIPTION
The stfe routines provide a high-level interface to the sym-
bol table based on common needs of the compiler front-ends.
st_filebegin
should be called upon encountering each cpp direc-
tive in the front end. It calls st_fileadd to add
symbols and will find the appropriate open file or
start a new file. It takes a filename, language
constant (see symconst.h), a merge flag (0 or 1) and
the -g level constant (see symconst.h). It returns a
dense number pointing to the file symbol to be used
in line number directives.
st_fileend
Requires the dense number from the corresponding
st_filebegin call for the file in question. It then
generates an end symbol and patches the references
so that the index field of the begin file points to
that of one beyond the end file. The end file points
to the begin file.
st_endallfiles
Is called at the end of execution to close off all
files that haven't been ended by previous calls to
st_filebegin. CPP directives might not reflect the
return to the original source file; therefore, this
routine can possibly close many files.
st_blockbegin
Supports both language blocks (for example, C's left
curly brace blocks), beginning of structures, and
unions. If the storage class is scText, it is the
former; if it is scInfo, it is one of the latter.
The iss (index into string space) specifies the name
of the structure/etc, if any.
If the storage class is scText, we must check the result of
st_blockbegin. It returns a dense number for outer blocks
and a zero for nested blocks. The non-zero block number
should be used in the BGNB ucode. Users of languages
without nested blocks that provide variable declarations can
ignore the rest of this paragraph. Nested blocks are two-
staged: one stage happens when we detect the language block
and the other stage happens when we know the block has
Page 2 Printed 11/19/92
STFE(3) RISC/os Reference Manual STFE(3)
content. If the block has content (for example, local vari-
ables), the front-end must call st_textblock to get a non-
zero dense number for the block's BGNB ucode. If the block
has no content and st_textblock is not called, the block's
st_blockbegin and st_blockend do not produce block and end
symbols.
If the storage class is scInfo, st_blockbegin creates a
begin block symbol in the symbol table and returns a dense
number referencing it. The dense number is necessary to
build the auxiliary required to reference the structure/etc.
It goes in the aux after the TIR along with a file index.
This dense number is also noted in a stack of blocks used by
st_blockend.
st_blockbegin should not be called for language blocks when
the front-end is not producing debugging symbols.
st_blockend requires that blocks occur in a nested fashion.
It retrieves the dense number for the most recently started
block and creates a corresponding end symbol. As in fileend,
both the begin and end symbol index fields point at the
other end's symbol. If the symbol ends a structure/etc., as
determined by the storage class of the begin symbol, the
size parameter is assigned to the begin symbol's value
field. It's usually the size of the structure or max value
of a enum. We only know it at this point. The dense number
of the end symbol is returned so that the ucode ENDB can be
use it. If it is an ignored text block, the dense number is
zero and no ENDB should be generated.
In general, defined external procedures or functions appear
in the symbols table and the externals table. The external
table definition must occur first through the use of a
st_extadd. After that definition, st_procbegin can be
called with a dense number referring to the external symbol
for that procedure. It checks to be sure we have a defined
procedure (by checking the storage class). It adds a pro-
cedure symbol to the symbol table. The external's index
should point at its auxiliary data type information (or if
debugging is off, indexNil). This index is copied into the
regular symbol's index field or a copy of its type is gen-
erated (if the external is in a different file than the reg-
ular symbol). Next, we put the index to symbol in the
external's index field. The external's dense number is used
as a block number in ucodes referencing it and is used to
add a procedure when in the st_pdadd_idn.
st_procend
Creates an end symbol and fixes the indices as in
blockend and fileend, except that the end procedure
reference is kept in the begin procedure's aux
Printed 11/19/92 Page 3
STFE(3) RISC/os Reference Manual STFE(3)
rather than in the index field (because the begin
procedure has a type as well as an end reference).
This must be called with the dense number of the
procedure's external symbol as an argument and
returns the dense number of the end symbol to be
used in the END ucode.
st_str_idn
Returns the string associated with symbol or exter-
nal referenced by the dense number argument. If the
symbol was anonymous (for example, there was no sym-
bol) a (char *), -1 is returned.
st_sym_idn
Returns the same result as st_str_idn, except that
the rest of the fields of the symbol specified by
the idn are returned in the arguments.
st_fglobal_idn
Returns a 1 if the symbol associated with the speci-
fied idn is non-static; otherwise, a 0 is returned.
st_abs_ifd_index
Returns the absolute offset for a dense number. If
the symbol is global, the global's index is
returned. If the symbol occurred in a file, the sum
of all symbols in files occurring before that file
and the symbol's index within the file is returned.
st_pdadd_idn
Adds an entry to the procedure table for the st_proc
entry generated by procbegin. This should be called
when the front-end generates code for the procedure
in question.
AUTHOR
Mark I. Himelstein
SEE ALSO
stcu(3), stfd(3).
Page 4 Printed 11/19/92