ack/lang/occam/comp/builtin.c

79 lines
2 KiB
C
Raw Normal View History

1987-03-10 11:49:39 +00:00
/* $Header$ */
1987-03-09 16:02:32 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
1987-02-24 17:05:53 +00:00
#include "symtab.h"
#include "expr.h"
#include "sizes.h"
void init_builtins()
/* Insert all builtin names into the outermost symbol table (first statement
* is sym_down() ). Note that this table is never destroy()ed, so static
* initializers may be used.
*/
{
union type_info info;
static char file[]="file";
static struct par_list
open_list[] = {
{ &open_list[1], nil, T_VAR }, /* File descriptor */
{ &open_list[2], nil, T_VALUE|T_ARR }, /* File name */
{ nil, nil, T_VALUE|T_ARR } /* "r", "w", "a" */
},
close_list[]= {
{ nil, nil, T_VALUE } /* File descriptor */
},
exit_list[]= {
{ nil, nil, T_VALUE } /* Exit code */
};
sym_down(); /* Add level of symbols above all others */
/* CHAN file[20], input=file[0], output=file[1], error=file[2]: */
info.vc.st.builtin=file;
info.vc.offset=0;
1987-02-25 16:56:31 +00:00
insert(file, T_CHAN|T_ARR|T_BUILTIN, 20, &info);
1987-02-24 17:05:53 +00:00
info.vc.st.builtin=file;
info.vc.offset=0;
1987-02-25 16:56:31 +00:00
insert("input", T_CHAN|T_BUILTIN, 1, &info);
1987-02-24 17:05:53 +00:00
info.vc.st.builtin=file;
info.vc.offset=wz+pz;
1987-02-25 16:56:31 +00:00
insert("output", T_CHAN|T_BUILTIN, 1, &info);
1987-02-24 17:05:53 +00:00
info.vc.st.builtin=file;
info.vc.offset=2*(wz+pz);
1987-02-25 16:56:31 +00:00
insert("error", T_CHAN|T_BUILTIN, 1, &info);
1987-02-24 17:05:53 +00:00
/* DEF EOF= -1, TEXT= -2, RAW= -3: */
info.const=new_const(-1L);
1987-02-25 16:56:31 +00:00
insert("EOF", T_CONST|T_BUILTIN, 0, &info);
1987-02-24 17:05:53 +00:00
info.const=new_const(-2L);
1987-02-25 16:56:31 +00:00
insert("TEXT", T_CONST|T_BUILTIN, 0, &info);
1987-02-24 17:05:53 +00:00
info.const=new_const(-3L);
1987-02-25 16:56:31 +00:00
insert("RAW", T_CONST|T_BUILTIN, 0, &info);
1987-02-24 17:05:53 +00:00
/* PROC open(VAR fd, VALUE name[], mode[])= .... : */
info.proc.st.builtin="b_open";
info.proc.pars=open_list;
1987-02-25 16:56:31 +00:00
insert("open", T_PROC|T_BUILTIN, 0, &info);
1987-02-24 17:05:53 +00:00
/* PROC close(VALUE fd)= .... : */
info.proc.st.builtin="b_close";
info.proc.pars=close_list;
1987-02-25 16:56:31 +00:00
insert("close", T_PROC|T_BUILTIN, 0, &info);
1987-02-24 17:05:53 +00:00
/* PROC exit(VALUE code)= .... : */
info.proc.st.builtin="b_exit";
info.proc.pars=exit_list;
1987-02-25 16:56:31 +00:00
insert("exit", T_PROC|T_BUILTIN, 0, &info);
1987-02-24 17:05:53 +00:00
}