| 1 | #ifndef OPTVIEW_H
|
| 2 | #define OPTVIEW_H
|
| 3 |
|
| 4 | #include "_gen/frontend/option.asdl.h"
|
| 5 | #include "mycpp/runtime.h"
|
| 6 |
|
| 7 | namespace optview {
|
| 8 |
|
| 9 | using option_asdl::option_i;
|
| 10 |
|
| 11 | class _View {
|
| 12 | public:
|
| 13 | _View(List<bool>* opt0_array, List<List<bool>*>* opt_stacks)
|
| 14 | : opt0_array(opt0_array), opt_stacks(opt_stacks) {
|
| 15 | }
|
| 16 |
|
| 17 | bool _Get(int opt_num) {
|
| 18 | List<bool>* overlay = opt_stacks->at(opt_num);
|
| 19 | if ((overlay == nullptr) or len(overlay) == 0) {
|
| 20 | return opt0_array->at(opt_num);
|
| 21 | } else {
|
| 22 | return overlay->at(-1);
|
| 23 | }
|
| 24 | }
|
| 25 |
|
| 26 | static constexpr ObjHeader obj_header() {
|
| 27 | return ObjHeader::ClassFixed(field_mask(), sizeof(_View));
|
| 28 | }
|
| 29 |
|
| 30 | List<bool>* opt0_array;
|
| 31 | List<List<bool>*>* opt_stacks;
|
| 32 |
|
| 33 | static constexpr uint32_t field_mask() {
|
| 34 | return
|
| 35 | maskbit(offsetof(_View, opt0_array))
|
| 36 | | maskbit(offsetof(_View, opt_stacks));
|
| 37 | }
|
| 38 | };
|
| 39 |
|
| 40 | class Parse : public _View {
|
| 41 | public:
|
| 42 | Parse(List<bool>* opt0_array, List<List<bool>*>* opt_stacks)
|
| 43 | : _View(opt0_array, opt_stacks) {
|
| 44 | }
|
| 45 | bool strict_parse_slice() { return _Get(option_i::strict_parse_slice); }
|
| 46 | bool parse_at() { return _Get(option_i::parse_at); }
|
| 47 | bool parse_proc() { return _Get(option_i::parse_proc); }
|
| 48 | bool parse_func() { return _Get(option_i::parse_func); }
|
| 49 | bool parse_brace() { return _Get(option_i::parse_brace); }
|
| 50 | bool parse_bracket() { return _Get(option_i::parse_bracket); }
|
| 51 | bool parse_equals() { return _Get(option_i::parse_equals); }
|
| 52 | bool parse_paren() { return _Get(option_i::parse_paren); }
|
| 53 | bool parse_ysh_string() { return _Get(option_i::parse_ysh_string); }
|
| 54 | bool parse_triple_quote() { return _Get(option_i::parse_triple_quote); }
|
| 55 | bool parse_at_all() { return _Get(option_i::parse_at_all); }
|
| 56 | bool parse_backslash() { return _Get(option_i::parse_backslash); }
|
| 57 | bool parse_backticks() { return _Get(option_i::parse_backticks); }
|
| 58 | bool parse_dollar() { return _Get(option_i::parse_dollar); }
|
| 59 | bool parse_ignored() { return _Get(option_i::parse_ignored); }
|
| 60 | bool parse_sh_arith() { return _Get(option_i::parse_sh_arith); }
|
| 61 | bool parse_dparen() { return _Get(option_i::parse_dparen); }
|
| 62 | bool parse_dbracket() { return _Get(option_i::parse_dbracket); }
|
| 63 | bool parse_bare_word() { return _Get(option_i::parse_bare_word); }
|
| 64 | bool expand_aliases() { return _Get(option_i::expand_aliases); }
|
| 65 | };
|
| 66 |
|
| 67 | class Exec : public _View {
|
| 68 | public:
|
| 69 | Exec(List<bool>* opt0_array, List<List<bool>*>* opt_stacks)
|
| 70 | : _View(opt0_array, opt_stacks) {
|
| 71 | }
|
| 72 | bool errexit() { return _Get(option_i::errexit); }
|
| 73 | bool nounset() { return _Get(option_i::nounset); }
|
| 74 | bool pipefail() { return _Get(option_i::pipefail); }
|
| 75 | bool inherit_errexit() { return _Get(option_i::inherit_errexit); }
|
| 76 | bool nullglob() { return _Get(option_i::nullglob); }
|
| 77 | bool verbose_errexit() { return _Get(option_i::verbose_errexit); }
|
| 78 | bool noexec() { return _Get(option_i::noexec); }
|
| 79 | bool xtrace() { return _Get(option_i::xtrace); }
|
| 80 | bool verbose() { return _Get(option_i::verbose); }
|
| 81 | bool noglob() { return _Get(option_i::noglob); }
|
| 82 | bool noclobber() { return _Get(option_i::noclobber); }
|
| 83 | bool errtrace() { return _Get(option_i::errtrace); }
|
| 84 | bool posix() { return _Get(option_i::posix); }
|
| 85 | bool vi() { return _Get(option_i::vi); }
|
| 86 | bool emacs() { return _Get(option_i::emacs); }
|
| 87 | bool interactive() { return _Get(option_i::interactive); }
|
| 88 | bool hashall() { return _Get(option_i::hashall); }
|
| 89 | bool failglob() { return _Get(option_i::failglob); }
|
| 90 | bool extglob() { return _Get(option_i::extglob); }
|
| 91 | bool nocasematch() { return _Get(option_i::nocasematch); }
|
| 92 | bool no_copy_env() { return _Get(option_i::no_copy_env); }
|
| 93 | bool eval_unsafe_arith() { return _Get(option_i::eval_unsafe_arith); }
|
| 94 | bool ignore_flags_not_impl() { return _Get(option_i::ignore_flags_not_impl); }
|
| 95 | bool ignore_opts_not_impl() { return _Get(option_i::ignore_opts_not_impl); }
|
| 96 | bool _allow_command_sub() { return _Get(option_i::_allow_command_sub); }
|
| 97 | bool _allow_process_sub() { return _Get(option_i::_allow_process_sub); }
|
| 98 | bool dynamic_scope() { return _Get(option_i::dynamic_scope); }
|
| 99 | bool redefine_module() { return _Get(option_i::redefine_module); }
|
| 100 | bool _running_trap() { return _Get(option_i::_running_trap); }
|
| 101 | bool _running_hay() { return _Get(option_i::_running_hay); }
|
| 102 | bool _no_debug_trap() { return _Get(option_i::_no_debug_trap); }
|
| 103 | bool _no_err_trap() { return _Get(option_i::_no_err_trap); }
|
| 104 | bool strict_argv() { return _Get(option_i::strict_argv); }
|
| 105 | bool strict_arith() { return _Get(option_i::strict_arith); }
|
| 106 | bool strict_array() { return _Get(option_i::strict_array); }
|
| 107 | bool strict_control_flow() { return _Get(option_i::strict_control_flow); }
|
| 108 | bool strict_errexit() { return _Get(option_i::strict_errexit); }
|
| 109 | bool strict_nameref() { return _Get(option_i::strict_nameref); }
|
| 110 | bool strict_word_eval() { return _Get(option_i::strict_word_eval); }
|
| 111 | bool strict_tilde() { return _Get(option_i::strict_tilde); }
|
| 112 | bool strict_glob() { return _Get(option_i::strict_glob); }
|
| 113 | bool simple_word_eval() { return _Get(option_i::simple_word_eval); }
|
| 114 | bool dashglob() { return _Get(option_i::dashglob); }
|
| 115 | bool command_sub_errexit() { return _Get(option_i::command_sub_errexit); }
|
| 116 | bool process_sub_fail() { return _Get(option_i::process_sub_fail); }
|
| 117 | bool xtrace_rich() { return _Get(option_i::xtrace_rich); }
|
| 118 | bool xtrace_details() { return _Get(option_i::xtrace_details); }
|
| 119 | bool sigpipe_status_ok() { return _Get(option_i::sigpipe_status_ok); }
|
| 120 | bool redefine_proc_func() { return _Get(option_i::redefine_proc_func); }
|
| 121 | bool simple_echo() { return _Get(option_i::simple_echo); }
|
| 122 | bool simple_eval_builtin() { return _Get(option_i::simple_eval_builtin); }
|
| 123 | bool simple_test_builtin() { return _Get(option_i::simple_test_builtin); }
|
| 124 | };
|
| 125 |
|
| 126 | } // namespace optview
|
| 127 |
|
| 128 | #endif // OPTVIEW_H
|