| 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 parse_at() { return _Get(option_i::parse_at); }
 | 
| 46 |   bool parse_proc() { return _Get(option_i::parse_proc); }
 | 
| 47 |   bool parse_func() { return _Get(option_i::parse_func); }
 | 
| 48 |   bool parse_brace() { return _Get(option_i::parse_brace); }
 | 
| 49 |   bool parse_bracket() { return _Get(option_i::parse_bracket); }
 | 
| 50 |   bool parse_equals() { return _Get(option_i::parse_equals); }
 | 
| 51 |   bool parse_paren() { return _Get(option_i::parse_paren); }
 | 
| 52 |   bool parse_ysh_string() { return _Get(option_i::parse_ysh_string); }
 | 
| 53 |   bool parse_triple_quote() { return _Get(option_i::parse_triple_quote); }
 | 
| 54 |   bool parse_at_all() { return _Get(option_i::parse_at_all); }
 | 
| 55 |   bool parse_backslash() { return _Get(option_i::parse_backslash); }
 | 
| 56 |   bool parse_backticks() { return _Get(option_i::parse_backticks); }
 | 
| 57 |   bool parse_dollar() { return _Get(option_i::parse_dollar); }
 | 
| 58 |   bool parse_ignored() { return _Get(option_i::parse_ignored); }
 | 
| 59 |   bool parse_sh_arith() { return _Get(option_i::parse_sh_arith); }
 | 
| 60 |   bool parse_dparen() { return _Get(option_i::parse_dparen); }
 | 
| 61 |   bool parse_dbracket() { return _Get(option_i::parse_dbracket); }
 | 
| 62 |   bool parse_bare_word() { return _Get(option_i::parse_bare_word); }
 | 
| 63 |   bool expand_aliases() { return _Get(option_i::expand_aliases); }
 | 
| 64 | };
 | 
| 65 | 
 | 
| 66 | class Exec : public _View {
 | 
| 67 |  public:
 | 
| 68 |   Exec(List<bool>* opt0_array, List<List<bool>*>* opt_stacks)
 | 
| 69 |       : _View(opt0_array, opt_stacks) {
 | 
| 70 |   }
 | 
| 71 |   bool errexit() { return _Get(option_i::errexit); }
 | 
| 72 |   bool nounset() { return _Get(option_i::nounset); }
 | 
| 73 |   bool pipefail() { return _Get(option_i::pipefail); }
 | 
| 74 |   bool inherit_errexit() { return _Get(option_i::inherit_errexit); }
 | 
| 75 |   bool nullglob() { return _Get(option_i::nullglob); }
 | 
| 76 |   bool verbose_errexit() { return _Get(option_i::verbose_errexit); }
 | 
| 77 |   bool noexec() { return _Get(option_i::noexec); }
 | 
| 78 |   bool xtrace() { return _Get(option_i::xtrace); }
 | 
| 79 |   bool verbose() { return _Get(option_i::verbose); }
 | 
| 80 |   bool noglob() { return _Get(option_i::noglob); }
 | 
| 81 |   bool noclobber() { return _Get(option_i::noclobber); }
 | 
| 82 |   bool errtrace() { return _Get(option_i::errtrace); }
 | 
| 83 |   bool posix() { return _Get(option_i::posix); }
 | 
| 84 |   bool vi() { return _Get(option_i::vi); }
 | 
| 85 |   bool emacs() { return _Get(option_i::emacs); }
 | 
| 86 |   bool interactive() { return _Get(option_i::interactive); }
 | 
| 87 |   bool hashall() { return _Get(option_i::hashall); }
 | 
| 88 |   bool failglob() { return _Get(option_i::failglob); }
 | 
| 89 |   bool extglob() { return _Get(option_i::extglob); }
 | 
| 90 |   bool nocasematch() { return _Get(option_i::nocasematch); }
 | 
| 91 |   bool eval_unsafe_arith() { return _Get(option_i::eval_unsafe_arith); }
 | 
| 92 |   bool _allow_command_sub() { return _Get(option_i::_allow_command_sub); }
 | 
| 93 |   bool _allow_process_sub() { return _Get(option_i::_allow_process_sub); }
 | 
| 94 |   bool dynamic_scope() { return _Get(option_i::dynamic_scope); }
 | 
| 95 |   bool redefine_module() { return _Get(option_i::redefine_module); }
 | 
| 96 |   bool _running_trap() { return _Get(option_i::_running_trap); }
 | 
| 97 |   bool _running_hay() { return _Get(option_i::_running_hay); }
 | 
| 98 |   bool _no_debug_trap() { return _Get(option_i::_no_debug_trap); }
 | 
| 99 |   bool _no_err_trap() { return _Get(option_i::_no_err_trap); }
 | 
| 100 |   bool strict_argv() { return _Get(option_i::strict_argv); }
 | 
| 101 |   bool strict_arith() { return _Get(option_i::strict_arith); }
 | 
| 102 |   bool strict_array() { return _Get(option_i::strict_array); }
 | 
| 103 |   bool strict_control_flow() { return _Get(option_i::strict_control_flow); }
 | 
| 104 |   bool strict_errexit() { return _Get(option_i::strict_errexit); }
 | 
| 105 |   bool strict_nameref() { return _Get(option_i::strict_nameref); }
 | 
| 106 |   bool strict_word_eval() { return _Get(option_i::strict_word_eval); }
 | 
| 107 |   bool strict_tilde() { return _Get(option_i::strict_tilde); }
 | 
| 108 |   bool strict_glob() { return _Get(option_i::strict_glob); }
 | 
| 109 |   bool simple_word_eval() { return _Get(option_i::simple_word_eval); }
 | 
| 110 |   bool dashglob() { return _Get(option_i::dashglob); }
 | 
| 111 |   bool command_sub_errexit() { return _Get(option_i::command_sub_errexit); }
 | 
| 112 |   bool process_sub_fail() { return _Get(option_i::process_sub_fail); }
 | 
| 113 |   bool xtrace_rich() { return _Get(option_i::xtrace_rich); }
 | 
| 114 |   bool xtrace_details() { return _Get(option_i::xtrace_details); }
 | 
| 115 |   bool sigpipe_status_ok() { return _Get(option_i::sigpipe_status_ok); }
 | 
| 116 |   bool redefine_proc_func() { return _Get(option_i::redefine_proc_func); }
 | 
| 117 |   bool simple_echo() { return _Get(option_i::simple_echo); }
 | 
| 118 |   bool simple_eval_builtin() { return _Get(option_i::simple_eval_builtin); }
 | 
| 119 |   bool simple_test_builtin() { return _Get(option_i::simple_test_builtin); }
 | 
| 120 | };
 | 
| 121 | 
 | 
| 122 | }  // namespace optview
 | 
| 123 | 
 | 
| 124 | #endif  // OPTVIEW_H
 |