Lines Matching refs:sym
44 enum symbol_type sym_get_type(struct symbol *sym) in sym_get_type() argument
46 enum symbol_type type = sym->type; in sym_get_type()
49 if (sym_is_choice_value(sym) && sym->visible == yes) in sym_get_type()
76 struct property *sym_get_choice_prop(struct symbol *sym) in sym_get_choice_prop() argument
80 for_all_choices(sym, prop) in sym_get_choice_prop()
85 static struct property *sym_get_default_prop(struct symbol *sym) in sym_get_default_prop() argument
89 for_all_defaults(sym, prop) { in sym_get_default_prop()
97 struct property *sym_get_range_prop(struct symbol *sym) in sym_get_range_prop() argument
101 for_all_properties(sym, prop, P_RANGE) { in sym_get_range_prop()
109 static long long sym_get_range_val(struct symbol *sym, int base) in sym_get_range_val() argument
111 sym_calc_value(sym); in sym_get_range_val()
112 switch (sym->type) { in sym_get_range_val()
122 return strtoll(sym->curr.val, NULL, base); in sym_get_range_val()
125 static void sym_validate_range(struct symbol *sym) in sym_validate_range() argument
132 switch (sym->type) { in sym_validate_range()
142 prop = sym_get_range_prop(sym); in sym_validate_range()
145 val = strtoll(sym->curr.val, NULL, base); in sym_validate_range()
146 range_sym = prop->expr->left.sym; in sym_validate_range()
149 range_sym = prop->expr->right.sym; in sym_validate_range()
154 sym->curr.val = range_sym->curr.val; in sym_validate_range()
157 static void sym_set_changed(struct symbol *sym) in sym_set_changed() argument
161 sym->flags |= SYMBOL_CHANGED; in sym_set_changed()
162 for (prop = sym->prop; prop; prop = prop->next) { in sym_set_changed()
170 struct symbol *sym; in sym_set_all_changed() local
173 for_all_symbols(i, sym) in sym_set_all_changed()
174 sym_set_changed(sym); in sym_set_all_changed()
177 static void sym_calc_visibility(struct symbol *sym) in sym_calc_visibility() argument
186 if (sym_is_choice_value(sym)) in sym_calc_visibility()
187 choice_sym = prop_get_symbol(sym_get_choice_prop(sym)); in sym_calc_visibility()
189 for_all_prompts(sym, prop) { in sym_calc_visibility()
196 if (choice_sym && sym->type == S_TRISTATE && in sym_calc_visibility()
202 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) in sym_calc_visibility()
204 if (sym->visible != tri) { in sym_calc_visibility()
205 sym->visible = tri; in sym_calc_visibility()
206 sym_set_changed(sym); in sym_calc_visibility()
208 if (sym_is_choice_value(sym)) in sym_calc_visibility()
212 if (sym->dir_dep.expr) in sym_calc_visibility()
213 tri = expr_calc_value(sym->dir_dep.expr); in sym_calc_visibility()
214 if (tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_visibility()
216 if (sym->dir_dep.tri != tri) { in sym_calc_visibility()
217 sym->dir_dep.tri = tri; in sym_calc_visibility()
218 sym_set_changed(sym); in sym_calc_visibility()
221 if (sym->rev_dep.expr) in sym_calc_visibility()
222 tri = expr_calc_value(sym->rev_dep.expr); in sym_calc_visibility()
223 if (tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_visibility()
225 if (sym->rev_dep.tri != tri) { in sym_calc_visibility()
226 sym->rev_dep.tri = tri; in sym_calc_visibility()
227 sym_set_changed(sym); in sym_calc_visibility()
230 if (sym->implied.expr) in sym_calc_visibility()
231 tri = expr_calc_value(sym->implied.expr); in sym_calc_visibility()
232 if (tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_visibility()
234 if (sym->implied.tri != tri) { in sym_calc_visibility()
235 sym->implied.tri = tri; in sym_calc_visibility()
236 sym_set_changed(sym); in sym_calc_visibility()
246 struct symbol *sym_choice_default(struct symbol *sym) in sym_choice_default() argument
253 for_all_defaults(sym, prop) { in sym_choice_default()
263 prop = sym_get_choice_prop(sym); in sym_choice_default()
272 static struct symbol *sym_calc_choice(struct symbol *sym) in sym_calc_choice() argument
280 flags = sym->flags; in sym_calc_choice()
281 prop = sym_get_choice_prop(sym); in sym_calc_choice()
288 sym->flags &= flags | ~SYMBOL_DEF_USER; in sym_calc_choice()
291 def_sym = sym->def[S_DEF_USER].val; in sym_calc_choice()
295 def_sym = sym_choice_default(sym); in sym_calc_choice()
299 sym->curr.tri = no; in sym_calc_choice()
304 static void sym_warn_unmet_dep(struct symbol *sym) in sym_warn_unmet_dep() argument
310 sym->name); in sym_warn_unmet_dep()
313 sym->dir_dep.tri == mod ? 'm' : 'n'); in sym_warn_unmet_dep()
314 expr_gstr_print(sym->dir_dep.expr, &gs); in sym_warn_unmet_dep()
317 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes, in sym_warn_unmet_dep()
319 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod, in sym_warn_unmet_dep()
325 void sym_calc_value(struct symbol *sym) in sym_calc_value() argument
331 if (!sym) in sym_calc_value()
334 if (sym->flags & SYMBOL_VALID) in sym_calc_value()
337 if (sym_is_choice_value(sym) && in sym_calc_value()
338 sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) { in sym_calc_value()
339 sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES; in sym_calc_value()
340 prop = sym_get_choice_prop(sym); in sym_calc_value()
344 sym->flags |= SYMBOL_VALID; in sym_calc_value()
346 oldval = sym->curr; in sym_calc_value()
348 switch (sym->type) { in sym_calc_value()
359 sym->curr.val = sym->name; in sym_calc_value()
360 sym->curr.tri = no; in sym_calc_value()
363 sym->flags &= ~SYMBOL_WRITE; in sym_calc_value()
365 sym_calc_visibility(sym); in sym_calc_value()
367 if (sym->visible != no) in sym_calc_value()
368 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
371 sym->curr = newval; in sym_calc_value()
373 switch (sym_get_type(sym)) { in sym_calc_value()
376 if (sym_is_choice_value(sym) && sym->visible == yes) { in sym_calc_value()
377 prop = sym_get_choice_prop(sym); in sym_calc_value()
378 newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; in sym_calc_value()
380 if (sym->visible != no) { in sym_calc_value()
384 if (sym_has_value(sym)) { in sym_calc_value()
385 newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, in sym_calc_value()
386 sym->visible); in sym_calc_value()
390 if (sym->rev_dep.tri != no) in sym_calc_value()
391 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
392 if (!sym_is_choice(sym)) { in sym_calc_value()
393 prop = sym_get_default_prop(sym); in sym_calc_value()
398 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
400 if (sym->implied.tri != no) { in sym_calc_value()
401 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
402 newval.tri = EXPR_OR(newval.tri, sym->implied.tri); in sym_calc_value()
404 sym->dir_dep.tri); in sym_calc_value()
408 if (sym->dir_dep.tri < sym->rev_dep.tri) in sym_calc_value()
409 sym_warn_unmet_dep(sym); in sym_calc_value()
410 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); in sym_calc_value()
412 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_value()
418 if (sym->visible != no && sym_has_value(sym)) { in sym_calc_value()
419 newval.val = sym->def[S_DEF_USER].val; in sym_calc_value()
422 prop = sym_get_default_prop(sym); in sym_calc_value()
426 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
436 sym->curr = newval; in sym_calc_value()
437 if (sym_is_choice(sym) && newval.tri == yes) in sym_calc_value()
438 sym->curr.val = sym_calc_choice(sym); in sym_calc_value()
439 sym_validate_range(sym); in sym_calc_value()
441 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) { in sym_calc_value()
442 sym_set_changed(sym); in sym_calc_value()
443 if (modules_sym == sym) { in sym_calc_value()
449 if (sym_is_choice(sym)) { in sym_calc_value()
452 prop = sym_get_choice_prop(sym); in sym_calc_value()
454 if ((sym->flags & SYMBOL_WRITE) && in sym_calc_value()
457 if (sym->flags & SYMBOL_CHANGED) in sym_calc_value()
462 if (sym->flags & SYMBOL_NO_WRITE) in sym_calc_value()
463 sym->flags &= ~SYMBOL_WRITE; in sym_calc_value()
465 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) in sym_calc_value()
466 set_all_choice_values(sym); in sym_calc_value()
471 struct symbol *sym; in sym_clear_all_valid() local
474 for_all_symbols(i, sym) in sym_clear_all_valid()
475 sym->flags &= ~SYMBOL_VALID; in sym_clear_all_valid()
480 bool sym_tristate_within_range(struct symbol *sym, tristate val) in sym_tristate_within_range() argument
482 int type = sym_get_type(sym); in sym_tristate_within_range()
484 if (sym->visible == no) in sym_tristate_within_range()
492 if (sym->visible <= sym->rev_dep.tri) in sym_tristate_within_range()
494 if (sym_is_choice_value(sym) && sym->visible == yes) in sym_tristate_within_range()
496 return val >= sym->rev_dep.tri && val <= sym->visible; in sym_tristate_within_range()
499 bool sym_set_tristate_value(struct symbol *sym, tristate val) in sym_set_tristate_value() argument
501 tristate oldval = sym_get_tristate_value(sym); in sym_set_tristate_value()
503 if (oldval != val && !sym_tristate_within_range(sym, val)) in sym_set_tristate_value()
506 if (!(sym->flags & SYMBOL_DEF_USER)) { in sym_set_tristate_value()
507 sym->flags |= SYMBOL_DEF_USER; in sym_set_tristate_value()
508 sym_set_changed(sym); in sym_set_tristate_value()
514 if (sym_is_choice_value(sym) && val == yes) { in sym_set_tristate_value()
515 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); in sym_set_tristate_value()
519 cs->def[S_DEF_USER].val = sym; in sym_set_tristate_value()
523 if (e->right.sym->visible != no) in sym_set_tristate_value()
524 e->right.sym->flags |= SYMBOL_DEF_USER; in sym_set_tristate_value()
528 sym->def[S_DEF_USER].tri = val; in sym_set_tristate_value()
535 tristate sym_toggle_tristate_value(struct symbol *sym) in sym_toggle_tristate_value() argument
539 oldval = newval = sym_get_tristate_value(sym); in sym_toggle_tristate_value()
552 if (sym_set_tristate_value(sym, newval)) in sym_toggle_tristate_value()
558 bool sym_string_valid(struct symbol *sym, const char *str) in sym_string_valid() argument
562 switch (sym->type) { in sym_string_valid()
601 bool sym_string_within_range(struct symbol *sym, const char *str) in sym_string_within_range() argument
606 switch (sym->type) { in sym_string_within_range()
608 return sym_string_valid(sym, str); in sym_string_within_range()
610 if (!sym_string_valid(sym, str)) in sym_string_within_range()
612 prop = sym_get_range_prop(sym); in sym_string_within_range()
616 return val >= sym_get_range_val(prop->expr->left.sym, 10) && in sym_string_within_range()
617 val <= sym_get_range_val(prop->expr->right.sym, 10); in sym_string_within_range()
619 if (!sym_string_valid(sym, str)) in sym_string_within_range()
621 prop = sym_get_range_prop(sym); in sym_string_within_range()
625 return val >= sym_get_range_val(prop->expr->left.sym, 16) && in sym_string_within_range()
626 val <= sym_get_range_val(prop->expr->right.sym, 16); in sym_string_within_range()
631 return sym_tristate_within_range(sym, yes); in sym_string_within_range()
633 return sym_tristate_within_range(sym, mod); in sym_string_within_range()
635 return sym_tristate_within_range(sym, no); in sym_string_within_range()
643 bool sym_set_string_value(struct symbol *sym, const char *newval) in sym_set_string_value() argument
649 switch (sym->type) { in sym_set_string_value()
654 return sym_set_tristate_value(sym, yes); in sym_set_string_value()
656 return sym_set_tristate_value(sym, mod); in sym_set_string_value()
658 return sym_set_tristate_value(sym, no); in sym_set_string_value()
665 if (!sym_string_within_range(sym, newval)) in sym_set_string_value()
668 if (!(sym->flags & SYMBOL_DEF_USER)) { in sym_set_string_value()
669 sym->flags |= SYMBOL_DEF_USER; in sym_set_string_value()
670 sym_set_changed(sym); in sym_set_string_value()
673 oldval = sym->def[S_DEF_USER].val; in sym_set_string_value()
675 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { in sym_set_string_value()
677 sym->def[S_DEF_USER].val = val = xmalloc(size); in sym_set_string_value()
681 sym->def[S_DEF_USER].val = val = xmalloc(size); in sym_set_string_value()
699 const char *sym_get_string_default(struct symbol *sym) in sym_get_string_default() argument
706 sym_calc_visibility(sym); in sym_get_string_default()
712 prop = sym_get_default_prop(sym); in sym_get_string_default()
714 switch (sym->type) { in sym_get_string_default()
735 val = EXPR_OR(val, sym->rev_dep.tri); in sym_get_string_default()
739 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no) in sym_get_string_default()
743 if (sym->type == S_BOOLEAN && val == mod) in sym_get_string_default()
747 if (val < sym->implied.tri) in sym_get_string_default()
748 val = sym->implied.tri; in sym_get_string_default()
750 switch (sym->type) { in sym_get_string_default()
769 const char *sym_get_string_value(struct symbol *sym) in sym_get_string_value() argument
773 switch (sym->type) { in sym_get_string_value()
776 val = sym_get_tristate_value(sym); in sym_get_string_value()
789 return (const char *)sym->curr.val; in sym_get_string_value()
792 bool sym_is_changeable(struct symbol *sym) in sym_is_changeable() argument
794 return sym->visible > sym->rev_dep.tri; in sym_is_changeable()
875 struct symbol *sym; member
898 exact1 = (s1->eo - s1->so) == strlen(s1->sym->name); in sym_rel_comp()
899 exact2 = (s2->eo - s2->so) == strlen(s2->sym->name); in sym_rel_comp()
906 return strcmp(s1->sym->name, s2->sym->name); in sym_rel_comp()
911 struct symbol *sym, **sym_arr = NULL; in sym_re_search() local
924 for_all_symbols(i, sym) { in sym_re_search()
925 if (sym->flags & SYMBOL_CONST || !sym->name) in sym_re_search()
927 if (regexec(&re, sym->name, 1, match, 0)) in sym_re_search()
937 sym_calc_value(sym); in sym_re_search()
943 sym_match_arr[cnt++].sym = sym; in sym_re_search()
951 sym_arr[i] = sym_match_arr[i].sym; in sym_re_search()
970 struct symbol *sym; member
975 static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym) in dep_stack_insert() argument
981 stack->sym = sym; in dep_stack_insert()
1000 struct symbol *sym, *next_sym; in sym_check_print_recursive() local
1011 if (stack->sym == last_sym) in sym_check_print_recursive()
1019 sym = stack->sym; in sym_check_print_recursive()
1020 next_sym = stack->next ? stack->next->sym : last_sym; in sym_check_print_recursive()
1023 prop = stack->sym->prop; in sym_check_print_recursive()
1026 if (sym_is_choice(sym) || sym_is_choice_value(sym)) { in sym_check_print_recursive()
1027 for (prop = sym->prop; prop; prop = prop->next) { in sym_check_print_recursive()
1033 if (stack->sym == last_sym) in sym_check_print_recursive()
1037 if (sym_is_choice(sym)) { in sym_check_print_recursive()
1040 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1042 } else if (sym_is_choice_value(sym)) { in sym_check_print_recursive()
1045 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1047 } else if (stack->expr == &sym->dir_dep.expr) { in sym_check_print_recursive()
1050 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1052 } else if (stack->expr == &sym->rev_dep.expr) { in sym_check_print_recursive()
1055 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1057 } else if (stack->expr == &sym->implied.expr) { in sym_check_print_recursive()
1060 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1065 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1071 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1088 struct symbol *sym; in sym_check_expr_deps() local
1095 sym = sym_check_expr_deps(e->left.expr); in sym_check_expr_deps()
1096 if (sym) in sym_check_expr_deps()
1097 return sym; in sym_check_expr_deps()
1107 sym = sym_check_deps(e->left.sym); in sym_check_expr_deps()
1108 if (sym) in sym_check_expr_deps()
1109 return sym; in sym_check_expr_deps()
1110 return sym_check_deps(e->right.sym); in sym_check_expr_deps()
1112 return sym_check_deps(e->left.sym); in sym_check_expr_deps()
1121 static struct symbol *sym_check_sym_deps(struct symbol *sym) in sym_check_sym_deps() argument
1127 dep_stack_insert(&stack, sym); in sym_check_sym_deps()
1129 stack.expr = &sym->dir_dep.expr; in sym_check_sym_deps()
1130 sym2 = sym_check_expr_deps(sym->dir_dep.expr); in sym_check_sym_deps()
1134 stack.expr = &sym->rev_dep.expr; in sym_check_sym_deps()
1135 sym2 = sym_check_expr_deps(sym->rev_dep.expr); in sym_check_sym_deps()
1139 stack.expr = &sym->implied.expr; in sym_check_sym_deps()
1140 sym2 = sym_check_expr_deps(sym->implied.expr); in sym_check_sym_deps()
1146 for (prop = sym->prop; prop; prop = prop->next) { in sym_check_sym_deps()
1154 if (prop->type != P_DEFAULT || sym_is_choice(sym)) in sym_check_sym_deps()
1171 struct symbol *sym, *sym2; in sym_check_choice_deps() local
1179 expr_list_for_each_sym(prop->expr, e, sym) in sym_check_choice_deps()
1180 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); in sym_check_choice_deps()
1188 expr_list_for_each_sym(prop->expr, e, sym) { in sym_check_choice_deps()
1189 sym2 = sym_check_sym_deps(sym); in sym_check_choice_deps()
1194 expr_list_for_each_sym(prop->expr, e, sym) in sym_check_choice_deps()
1195 sym->flags &= ~SYMBOL_CHECK; in sym_check_choice_deps()
1206 struct symbol *sym_check_deps(struct symbol *sym) in sym_check_deps() argument
1211 if (sym->flags & SYMBOL_CHECK) { in sym_check_deps()
1212 sym_check_print_recursive(sym); in sym_check_deps()
1213 return sym; in sym_check_deps()
1215 if (sym->flags & SYMBOL_CHECKED) in sym_check_deps()
1218 if (sym_is_choice_value(sym)) { in sym_check_deps()
1222 dep_stack_insert(&stack, sym); in sym_check_deps()
1223 prop = sym_get_choice_prop(sym); in sym_check_deps()
1226 } else if (sym_is_choice(sym)) { in sym_check_deps()
1227 sym2 = sym_check_choice_deps(sym); in sym_check_deps()
1229 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); in sym_check_deps()
1230 sym2 = sym_check_sym_deps(sym); in sym_check_deps()
1231 sym->flags &= ~SYMBOL_CHECK; in sym_check_deps()
1241 return prop->expr->left.sym; in prop_get_symbol()