History

kconfig: explicitly introduce expression list

Rename E_CHOICE to E_LIST to explicitly add support for expression lists. Add a helper macro expr_list_for_each_sym to more easily iterate over the list.

Roman Zippel committed 18 years ago

Commit 7a962921 parent 0ffce8d5 files · +24 −20Browse files

Unified · Split

5 files
  1. scripts/kconfig/confdata.c +4 −4
  2. scripts/kconfig/expr.c +8 −8
  3. scripts/kconfig/expr.h +4 −1
  4. scripts/kconfig/menu.c +1 −1
  5. scripts/kconfig/symbol.c +7 −6
scripts/kconfig/confdata.c+4−4
@@ -312,7 +312,7 @@ load: · 311 unmodified lines
312 312
313int conf_read(const char *name)313int conf_read(const char *name)
314{314{
315 struct symbol *sym;315 struct symbol *sym, *choice_sym;
316 struct property *prop;316 struct property *prop;
317 struct expr *e;317 struct expr *e;
318 int i, flags;318 int i, flags;
@@ -353,9 +353,9 @@ int conf_read(const char *name) · 34 unmodified lines
353 */353 */
354 prop = sym_get_choice_prop(sym);354 prop = sym_get_choice_prop(sym);
355 flags = sym->flags;355 flags = sym->flags;
356 for (e = prop->expr; e; e = e->left.expr)356 expr_list_for_each_sym(prop->expr, e, choice_sym)
357 if (e->right.sym->visible != no)357 if (choice_sym->visible != no)
358 flags &= e->right.sym->flags;358 flags &= choice_sym->flags;
359 sym->flags &= flags | ~SYMBOL_DEF_USER;359 sym->flags &= flags | ~SYMBOL_DEF_USER;
360 }360 }
361 361
scripts/kconfig/expr.c+8−8
@@ -87,7 +87,7 @@ struct expr *expr_copy(struct expr *org) · 86 unmodified lines
87 break;87 break;
88 case E_AND:88 case E_AND:
89 case E_OR:89 case E_OR:
90 case E_CHOICE:90 case E_LIST:
91 e->left.expr = expr_copy(org->left.expr);91 e->left.expr = expr_copy(org->left.expr);
92 e->right.expr = expr_copy(org->right.expr);92 e->right.expr = expr_copy(org->right.expr);
93 break;93 break;
@@ -217,7 +217,7 @@ int expr_eq(struct expr *e1, struct expr *e2) · 123 unmodified lines
217 expr_free(e2);217 expr_free(e2);
218 trans_count = old_count;218 trans_count = old_count;
219 return res;219 return res;
220 case E_CHOICE:220 case E_LIST:
221 case E_RANGE:221 case E_RANGE:
222 case E_NONE:222 case E_NONE:
223 /* panic */;223 /* panic */;
@@ -648,7 +648,7 @@ struct expr *expr_transform(struct expr *e) · 424 unmodified lines
648 case E_EQUAL:648 case E_EQUAL:
649 case E_UNEQUAL:649 case E_UNEQUAL:
650 case E_SYMBOL:650 case E_SYMBOL:
651 case E_CHOICE:651 case E_LIST:
652 break;652 break;
653 default:653 default:
654 e->left.expr = expr_transform(e->left.expr);654 e->left.expr = expr_transform(e->left.expr);
@@ -932,7 +932,7 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb · 277 unmodified lines
932 break;932 break;
933 case E_SYMBOL:933 case E_SYMBOL:
934 return expr_alloc_comp(type, e->left.sym, sym);934 return expr_alloc_comp(type, e->left.sym, sym);
935 case E_CHOICE:935 case E_LIST:
936 case E_RANGE:936 case E_RANGE:
937 case E_NONE:937 case E_NONE:
938 /* panic */;938 /* panic */;
@@ -1000,9 +1000,9 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2) · 61 unmodified lines
1000 if (t2 == E_OR)1000 if (t2 == E_OR)
1001 return 1;1001 return 1;
1002 case E_OR:1002 case E_OR:
1003 if (t2 == E_CHOICE)1003 if (t2 == E_LIST)
1004 return 1;1004 return 1;
1005 case E_CHOICE:1005 case E_LIST:
1006 if (t2 == 0)1006 if (t2 == 0)
1007 return 1;1007 return 1;
1008 default:1008 default:
@@ -1053,11 +1053,11 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * · 44 unmodified lines
1053 fn(data, NULL, " && ");1053 fn(data, NULL, " && ");
1054 expr_print(e->right.expr, fn, data, E_AND);1054 expr_print(e->right.expr, fn, data, E_AND);
1055 break;1055 break;
1056 case E_CHOICE:1056 case E_LIST:
1057 fn(data, e->right.sym, e->right.sym->name);1057 fn(data, e->right.sym, e->right.sym->name);
1058 if (e->left.expr) {1058 if (e->left.expr) {
1059 fn(data, NULL, " ^ ");1059 fn(data, NULL, " ^ ");
1060 expr_print(e->left.expr, fn, data, E_CHOICE);1060 expr_print(e->left.expr, fn, data, E_LIST);
1061 }1061 }
1062 break;1062 break;
1063 case E_RANGE:1063 case E_RANGE:
scripts/kconfig/expr.h+4−1
@@ -31,7 +31,7 @@ typedef enum tristate { · 30 unmodified lines
31} tristate;31} tristate;
32 32
33enum expr_type {33enum expr_type {
34 E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL, E_RANGE34 E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LIST, E_SYMBOL, E_RANGE
35};35};
36 36
37union expr_data {37union expr_data {
@@ -48,6 +48,9 @@ struct expr { · 10 unmodified lines
48#define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2))48#define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2))
49#define EXPR_NOT(dep) (2-(dep))49#define EXPR_NOT(dep) (2-(dep))
50 50
51#define expr_list_for_each_sym(l, e, s) \
52 for (e = (l); e && (s = e->right.sym); e = e->left.expr)
53
51struct expr_value {54struct expr_value {
52 struct expr *expr;55 struct expr *expr;
53 tristate tri;56 tristate tri;
scripts/kconfig/menu.c+1−1
@@ -331,7 +331,7 @@ void menu_finalize(struct menu *parent) · 330 unmodified lines
331 prop = sym_get_choice_prop(sym);331 prop = sym_get_choice_prop(sym);
332 for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)332 for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)
333 ;333 ;
334 *ep = expr_alloc_one(E_CHOICE, NULL);334 *ep = expr_alloc_one(E_LIST, NULL);
335 (*ep)->right.sym = menu->sym;335 (*ep)->right.sym = menu->sym;
336 }336 }
337 if (menu->list && (!menu->prompt || !menu->prompt->text)) {337 if (menu->list && (!menu->prompt || !menu->prompt->text)) {
scripts/kconfig/symbol.c+7−6
@@ -247,8 +247,7 @@ static struct symbol *sym_calc_choice(struct symbol *sym) · 246 unmodified lines
247 247
248 /* just get the first visible value */248 /* just get the first visible value */
249 prop = sym_get_choice_prop(sym);249 prop = sym_get_choice_prop(sym);
250 for (e = prop->expr; e; e = e->left.expr) {250 expr_list_for_each_sym(prop->expr, e, def_sym) {
251 def_sym = e->right.sym;
252 sym_calc_visibility(def_sym);251 sym_calc_visibility(def_sym);
253 if (def_sym->visible != no)252 if (def_sym->visible != no)
254 return def_sym;253 return def_sym;
@@ -361,12 +360,14 @@ void sym_calc_value(struct symbol *sym) · 106 unmodified lines
361 }360 }
362 361
363 if (sym_is_choice(sym)) {362 if (sym_is_choice(sym)) {
363 struct symbol *choice_sym;
364 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);364 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
365
365 prop = sym_get_choice_prop(sym);366 prop = sym_get_choice_prop(sym);
366 for (e = prop->expr; e; e = e->left.expr) {367 expr_list_for_each_sym(prop->expr, e, choice_sym) {
367 e->right.sym->flags |= flags;368 choice_sym->flags |= flags;
368 if (flags & SYMBOL_CHANGED)369 if (flags & SYMBOL_CHANGED)
369 sym_set_changed(e->right.sym);370 sym_set_changed(choice_sym);
370 }371 }
371 }372 }
372}373}
@@ -849,7 +850,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym) · 476 unmodified lines
849struct symbol *prop_get_symbol(struct property *prop)850struct symbol *prop_get_symbol(struct property *prop)
850{851{
851 if (prop->expr && (prop->expr->type == E_SYMBOL ||852 if (prop->expr && (prop->expr->type == E_SYMBOL ||
852 prop->expr->type == E_CHOICE))853 prop->expr->type == E_LIST))
853 return prop->expr->left.sym;854 return prop->expr->left.sym;
854 return NULL;855 return NULL;
855}856}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t