1986-03-26 17:53:13 +00:00
|
|
|
/* H I G H L E V E L S Y M B O L E N T R Y A N D L O O K U P */
|
|
|
|
|
|
|
|
static char *RcsId = "$Header$";
|
|
|
|
|
1986-03-26 22:46:48 +00:00
|
|
|
#include <alloc.h>
|
1986-03-26 17:53:13 +00:00
|
|
|
#include <em_arith.h>
|
|
|
|
#include <em_label.h>
|
|
|
|
#include "idf.h"
|
|
|
|
#include "def.h"
|
|
|
|
#include "type.h"
|
|
|
|
#include "scope.h"
|
1986-03-26 22:46:48 +00:00
|
|
|
#include "misc.h"
|
1986-03-26 17:53:13 +00:00
|
|
|
|
1986-03-26 22:46:48 +00:00
|
|
|
struct def *
|
1986-03-26 17:53:13 +00:00
|
|
|
Enter(name, kind, type, pnam)
|
|
|
|
char *name;
|
|
|
|
struct type *type;
|
|
|
|
{
|
|
|
|
struct idf *id;
|
|
|
|
struct def *df;
|
|
|
|
|
|
|
|
id = str2idf(name, 0);
|
|
|
|
if (!id) fatal("Out of core");
|
|
|
|
df = define(id, CurrentScope, kind);
|
|
|
|
df->df_type = type;
|
|
|
|
if (kind == D_STDPROC || kind == D_STDFUNC) {
|
|
|
|
df->df_value.df_stdname = pnam;
|
|
|
|
}
|
1986-03-26 22:46:48 +00:00
|
|
|
return df;
|
|
|
|
}
|
|
|
|
|
1986-03-27 17:37:41 +00:00
|
|
|
EnterIdList(idlist, kind, flags, type, scope)
|
1986-03-26 22:46:48 +00:00
|
|
|
register struct id_list *idlist;
|
|
|
|
struct type *type;
|
1986-04-03 00:44:39 +00:00
|
|
|
struct scope *scope;
|
1986-03-26 22:46:48 +00:00
|
|
|
{
|
|
|
|
register struct def *df;
|
1986-03-27 17:37:41 +00:00
|
|
|
struct def *first = 0, *last = 0;
|
1986-03-26 22:46:48 +00:00
|
|
|
int assval = 0;
|
|
|
|
|
|
|
|
while (idlist) {
|
1986-03-27 17:37:41 +00:00
|
|
|
df = define(idlist->id_ptr, scope, kind);
|
1986-03-26 22:46:48 +00:00
|
|
|
df->df_type = type;
|
|
|
|
df->df_flags = flags;
|
|
|
|
if (kind == D_ENUM) {
|
1986-03-27 17:37:41 +00:00
|
|
|
if (!first) first = df;
|
1986-03-26 22:46:48 +00:00
|
|
|
df->df_value.df_enum.en_val = assval++;
|
|
|
|
if (last) last->df_value.df_enum.en_next = df;
|
|
|
|
last = df;
|
|
|
|
}
|
|
|
|
idlist = idlist->next;
|
|
|
|
}
|
1986-03-27 17:37:41 +00:00
|
|
|
if (last) {
|
|
|
|
/* Also meaning : enumeration */
|
|
|
|
last->df_value.df_enum.en_next = 0;
|
1986-03-29 01:04:49 +00:00
|
|
|
type->enm_enums = first;
|
|
|
|
type->enm_ncst = assval;
|
1986-03-27 17:37:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct def *
|
1986-04-02 17:34:21 +00:00
|
|
|
lookfor(id, scope, give_error)
|
1986-03-27 17:37:41 +00:00
|
|
|
struct idf *id;
|
1986-04-02 17:34:21 +00:00
|
|
|
struct scope *scope;
|
1986-03-27 17:37:41 +00:00
|
|
|
{
|
1986-04-02 17:34:21 +00:00
|
|
|
/* Look for an identifier in the visibility range started by
|
|
|
|
"scope".
|
|
|
|
If it is not defined, give an error message, and
|
|
|
|
create a dummy definition.
|
|
|
|
*/
|
1986-03-27 17:37:41 +00:00
|
|
|
struct def *df;
|
1986-04-02 17:34:21 +00:00
|
|
|
register struct scope *sc = scope;
|
1986-03-27 17:37:41 +00:00
|
|
|
|
|
|
|
while (sc) {
|
|
|
|
df = lookup(id, sc->sc_scope);
|
|
|
|
if (df) return df;
|
|
|
|
sc = nextvisible(sc);
|
|
|
|
}
|
1986-04-03 17:41:26 +00:00
|
|
|
if (give_error) id_not_declared(id);
|
1986-04-03 00:44:39 +00:00
|
|
|
return define(id, scope, D_ERROR);
|
1986-03-26 17:53:13 +00:00
|
|
|
}
|