-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathls9-startup.nw
54 lines (49 loc) · 1.14 KB
/
ls9-startup.nw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Startup and initialization
<<ls9 impl>>=
void init(void) {
int i;
for (i=2; i<NPORTS; i++) Ports[i] = NULL;
Ports[0] = stdin; Port_flags[0] = LOCK_TAG;
Ports[1] = stdout; Port_flags[1] = LOCK_TAG;
Ports[2] = stderr; Port_flags[2] = LOCK_TAG;
alloc_nodepool();
alloc_vecpool();
gcv();
initrts();
clrtrace();
Nullvec = newvec(T_VECTOR, 0);
Nullstr = newvec(T_STRING, 1);
Blank = mkchar(' ');
Zero = mkfix(0);
One = mkfix(1);
Ten = mkfix(10);
Symbols = mkvec(CHUNKSIZE);
Symhash = mkht(CHUNKSIZE);
Obhash = mkht(CHUNKSIZE);
Obarray = mkvec(CHUNKSIZE);
Obmap = mkstr("", CHUNKSIZE);
memset(string(Obmap), OBFREE, CHUNKSIZE);
symref("?");
I_a = symref("a");
I_e = symref("e");
I_arg = symref("%arg");
I_closure = symref("%closure");
I_ref = symref("%ref");
<<ls9 init>>
bindnew(S_errtag, NIL);
bindnew(S_errval, NIL);
bindnew(S_imagefile, NIL);
bindnew(S_quiet, NIL);
bindnew(S_starstar, NIL);
bindnew(S_start, NIL);
}
void start(void) {
full n;
if (setjmp(Restart)) return;
if (!Quiet) signal(SIGINT, kbdintr);
n = assq(S_start, Glob);
if (NIL == n || closurep(cadr(n)) == 0) return;
n = cons(cadr(n), NIL);
eval(n, 0);
}
@