aboutsummaryrefslogtreecommitdiff
path: root/scripts/parse_kconfig/doutput.c
blob: 5b94842fd0def1a26f70a2e35f01201e0ae60a65 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "doutput.h"

void doutput_expr(struct expr *expr) {
#ifdef DEBUG
    if (verbose_level <= 3)
        return;
    switch (expr->type) {
    case E_OR:
        printf("  OR\n");
        doutput_expr(expr->left.expr);
        doutput_expr(expr->right.expr);
        break;
    case E_AND:
        printf("  AND\n");
        doutput_expr(expr->left.expr);
        doutput_expr(expr->right.expr);
        break;
    case E_NOT:
        printf("  NOT\n");
        doutput_expr(expr->left.expr);
        break;
    case E_EQUAL:
        printf("  = ");
        printf("%s ", expr->left.sym->name);
        if (!strcmp("y", expr->right.sym->name))
            printf("YES\n");
        else if (!strcmp("n", expr->right.sym->name))
            printf("NO\n");
        else if (!strcmp("m", expr->right.sym->name))
            printf("MODULE\n");
        else
            printf("%s\n", expr->left.sym->name);
        break;
    case E_UNEQUAL:
        printf("  != ");
        printf("%s ", expr->left.sym->name);
        if (!strcmp("y", expr->right.sym->name))
            printf("YES\n");
        else if (!strcmp("n", expr->right.sym->name))
            printf("NO\n");
        else
            printf("OTHER %s\n", expr->right.sym->name);
        break;
    case E_LIST:
        printf("  list\n");
        break;
    case E_SYMBOL:
        printf("  symbol");
        if (expr->left.sym->name != NULL)
            printf(": %s", expr->left.sym->name);
        printf("\n");
        break;
    case E_RANGE:
        printf("  range\n");
        break;
    case E_NONE:
        printf("  none\n");
        break;
    default:
        printf("  ERROR\n");
        break;
    }
#endif /* DEBUG */
}

void doutput_boolexpr(struct boolexpr *bl, struct symlist *sl) {
#ifdef DEBUG
    if (verbose_level <= 3)
        return;
    switch (bl->type) {
    case BT_TRUE:
        printf("  true\n");
        break;
    case BT_FALSE:
        printf("  false\n");
        break;
    case BT_SYM:
        printf("  CONFIG_%s\n", sl->array[bl->id - 1].name);
        break;
    case BT_OR:
        printf("  OR\n");
        doutput_boolexpr(bl->left, sl);
        doutput_boolexpr(bl->right, sl);
        break;
    case BT_AND:
        printf("  AND\n");
        doutput_boolexpr(bl->left, sl);
        doutput_boolexpr(bl->right, sl);
        break;
    case BT_NOT:
        if (bl->left->type == BT_SYM) {
            printf("  NOT CONFIG_%s\n", sl->array[bl->left->id - 1].name);
        } else {
            printf("  NOT\n");
            doutput_boolexpr(bl->left, sl);
        }
        break;
    }
#endif /* DEBUG */
}