ack/lang/m2/comp/defmodule.c

80 lines
1.5 KiB
C
Raw Normal View History

1986-04-03 00:44:39 +00:00
/* D E F I N I T I O N M O D U L E S */
1986-05-01 19:06:53 +00:00
#ifndef NORCSID
1986-04-04 13:47:04 +00:00
static char *RcsId = "$Header$";
1986-05-01 19:06:53 +00:00
#endif
#include "debug.h"
1986-04-04 13:47:04 +00:00
1986-04-03 00:44:39 +00:00
#include <assert.h>
#include <em_arith.h>
#include <em_label.h>
1986-04-21 17:27:06 +00:00
1986-04-03 00:44:39 +00:00
#include "idf.h"
#include "input.h"
#include "scope.h"
#include "def.h"
#include "LLlex.h"
#include "f_info.h"
1986-04-21 17:27:06 +00:00
#include "main.h"
1986-04-08 18:15:46 +00:00
#ifdef DEBUG
long sys_filesize();
#endif
1986-04-03 00:44:39 +00:00
GetFile(name)
char *name;
{
/* Try to find a file with basename "name" and extension ".def",
in the directories mentioned in "DEFPATH".
*/
char buf[256];
1986-04-08 23:34:10 +00:00
char *strcpy(), *strcat();
1986-04-03 00:44:39 +00:00
(void) strcpy(buf, name);
if (strlen(buf) > 10) {
(void) strcpy(&buf[10], ".def");
}
else (void) strcat(buf, ".def");
if (! InsertFile(buf, DEFPATH, &(FileName))) {
fatal("Could'nt find a DEFINITION MODULE for \"%s\"", name);
}
LineNumber = 1;
1986-04-08 18:15:46 +00:00
DO_DEBUG(1, debug("File %s : %ld characters", FileName, sys_filesize(FileName)));
1986-04-03 00:44:39 +00:00
}
struct def *
GetDefinitionModule(id)
struct idf *id;
{
/* Return a pointer to the "def" structure of the definition
module indicated by "id".
We may have to read the definition module itself.
*/
struct def *df;
1986-04-15 17:51:53 +00:00
df = lookup(id, GlobalScope);
1986-04-03 00:44:39 +00:00
if (!df) {
/* Read definition module. Make an exception for SYSTEM.
*/
if (!strcmp(id->id_text, "SYSTEM")) {
do_SYSTEM();
}
else {
GetFile(id->id_text);
DefModule();
}
1986-04-15 17:51:53 +00:00
df = lookup(id, GlobalScope);
1986-04-03 00:44:39 +00:00
}
assert(df != 0 && df->df_kind == D_MODULE);
return df;
}
AtEoIF()
{
/* Make the unstacking of input streams noticable by the
lexical analyzer
*/
return 1;
}