-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlila_examine.c
75 lines (67 loc) · 1.74 KB
/
lila_examine.c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "lila.h"
static const struct implementation *
examine_implementation(const char *name)
{
const struct implementation **impls;
const struct implementation *impl;
if (vflags >= 1) {
fprintf(stderr, "%s: file lists implementation %s\n", progname, name);
}
for (impls = implementations; (impl = *impls); impls++) {
if (!strcmp(impl->name, name)) {
return impl;
}
}
return 0;
}
static void
examine_implementation_list(uint32_t list)
{
const struct implementation *impl;
for (; list; list = value_d(list)) {
if (value_type(value_a(list)) == TYPE_SYMBOL) {
impl = examine_implementation(bytes + value_a(value_a(list)));
if (impl && !implementation) {
implementation = impl;
if (vflags >= 1) {
fprintf(stderr, "%s: choosing that implementation\n",
progname);
}
}
}
}
}
static void
examine_declare_file_sublist(uint32_t list)
{
if (value_the_symbol_p(value_a(list), "implementations")) {
examine_implementation_list(value_d(list));
}
}
static void
examine_declare_file(uint32_t list)
{
for (; list; list = value_d(list)) {
if (value_type(value_a(list)) == TYPE_PAIR) {
examine_declare_file_sublist(value_a(list));
}
}
}
int
examine_toplevel_form(uint32_t index)
{
if (!(values[index] & TOPLEVEL)) {
return 0;
}
if (value_type(index) != TYPE_PAIR) {
return 0;
}
if (!value_the_symbol_p(value_a(index), "declare-file")) {
return 0;
}
examine_declare_file(value_d(index));
return 1;
}