Pristine Ack-5.5
[Ack-5.5.git] / lang / occam / comp / builtin.c
1 /* $Id: builtin.c,v 1.7 1994/06/24 12:26:40 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 #include "symtab.h"
7 #include "expr.h"
8 #include "sizes.h"
9
10 void init_builtins()
11 /* Insert all builtin names into the outermost symbol table (first statement
12  * is sym_down() ).  Note that this table is never destroy()ed, so static
13  * initializers may be used.
14  */
15 {
16         union type_info info;
17
18         static char file[]="file";
19
20         static struct par_list
21         open_list[] = {
22                 { &open_list[1], nil, T_VAR },          /* File descriptor */
23                 { &open_list[2], nil, T_VALUE|T_ARR },  /* File name */
24                 { nil,           nil, T_VALUE|T_ARR }   /* "r", "w", "a" */
25         },
26         close_list[]= {
27                 { nil,           nil, T_VALUE }         /* File descriptor */
28         },
29         exit_list[]= {
30                 { nil,           nil, T_VALUE }         /* Exit code */
31         };
32
33         sym_down();     /* Add level of symbols above all others */
34
35         /* CHAN file[20], input=file[0], output=file[1], error=file[2]: */
36
37         info.vc.st.builtin=file;
38         info.vc.offset=0;
39         insert(file, T_CHAN|T_ARR|T_BUILTIN, 20, &info);
40
41         info.vc.st.builtin=file;
42         info.vc.offset=0;
43         insert("input", T_CHAN|T_BUILTIN, 1, &info);
44
45         info.vc.st.builtin=file;
46         info.vc.offset=wz+vz;
47         insert("output", T_CHAN|T_BUILTIN, 1, &info);
48
49         info.vc.st.builtin=file;
50         info.vc.offset=2*(wz+vz);
51         insert("error", T_CHAN|T_BUILTIN, 1, &info);
52
53         /* DEF EOF= -1, TEXT= -2, RAW= -3: */
54
55         info.t_const=new_const(-1L);
56         insert("EOF", T_CONST|T_BUILTIN, 0, &info);
57
58         info.t_const=new_const(-2L);
59         insert("TEXT", T_CONST|T_BUILTIN, 0, &info);
60
61         info.t_const=new_const(-3L);
62         insert("RAW", T_CONST|T_BUILTIN, 0, &info);
63
64         /* PROC open(VAR fd, VALUE name[], mode[])= .... : */
65         info.proc.st.builtin="b_open";
66         info.proc.pars=open_list;
67         insert("open", T_PROC|T_BUILTIN, 0, &info);
68
69         /* PROC close(VALUE fd)= .... : */
70         info.proc.st.builtin="b_close";
71         info.proc.pars=close_list;
72         insert("close", T_PROC|T_BUILTIN, 0, &info);
73
74         /* PROC exit(VALUE code)= .... : */
75         info.proc.st.builtin="b_exit";
76         info.proc.pars=exit_list;
77         insert("exit", T_PROC|T_BUILTIN, 0, &info);
78 }