line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
#include /* for calloc, free */ |
3
|
|
|
|
|
|
|
#include "header.h" |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
|
|
|
extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size) |
6
|
|
|
|
|
|
|
{ |
7
|
2
|
|
|
|
|
|
struct SN_env * z = (struct SN_env *) calloc(1, sizeof(struct SN_env)); |
8
|
2
|
50
|
|
|
|
|
if (z == NULL) return NULL; |
9
|
2
|
|
|
|
|
|
z->p = create_s(); |
10
|
2
|
50
|
|
|
|
|
if (z->p == NULL) goto error; |
11
|
2
|
50
|
|
|
|
|
if (S_size) |
12
|
|
|
|
|
|
|
{ |
13
|
|
|
|
|
|
|
int i; |
14
|
0
|
|
|
|
|
|
z->S = (symbol * *) calloc(S_size, sizeof(symbol *)); |
15
|
0
|
0
|
|
|
|
|
if (z->S == NULL) goto error; |
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
|
for (i = 0; i < S_size; i++) |
18
|
|
|
|
|
|
|
{ |
19
|
0
|
|
|
|
|
|
z->S[i] = create_s(); |
20
|
0
|
0
|
|
|
|
|
if (z->S[i] == NULL) goto error; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
2
|
50
|
|
|
|
|
if (I_size) |
25
|
|
|
|
|
|
|
{ |
26
|
2
|
|
|
|
|
|
z->I = (int *) calloc(I_size, sizeof(int)); |
27
|
2
|
50
|
|
|
|
|
if (z->I == NULL) goto error; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
2
|
50
|
|
|
|
|
if (B_size) |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
|
|
|
|
|
z->B = (unsigned char *) calloc(B_size, sizeof(unsigned char)); |
33
|
0
|
0
|
|
|
|
|
if (z->B == NULL) goto error; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return z; |
37
|
|
|
|
|
|
|
error: |
38
|
0
|
|
|
|
|
|
SN_close_env(z, S_size); |
39
|
0
|
|
|
|
|
|
return NULL; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
|
extern void SN_close_env(struct SN_env * z, int S_size) |
43
|
|
|
|
|
|
|
{ |
44
|
2
|
50
|
|
|
|
|
if (z == NULL) return; |
45
|
2
|
50
|
|
|
|
|
if (S_size) |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
int i; |
48
|
0
|
0
|
|
|
|
|
for (i = 0; i < S_size; i++) |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
|
|
|
lose_s(z->S[i]); |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
free(z->S); |
53
|
|
|
|
|
|
|
} |
54
|
2
|
|
|
|
|
|
free(z->I); |
55
|
2
|
|
|
|
|
|
free(z->B); |
56
|
2
|
50
|
|
|
|
|
if (z->p) lose_s(z->p); |
57
|
2
|
|
|
|
|
|
free(z); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
16
|
|
|
|
|
|
extern int SN_set_current(struct SN_env * z, int size, const symbol * s) |
61
|
|
|
|
|
|
|
{ |
62
|
16
|
|
|
|
|
|
int err = replace_s(z, 0, z->l, size, s, NULL); |
63
|
16
|
|
|
|
|
|
z->c = 0; |
64
|
16
|
|
|
|
|
|
return err; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|