| 1 | // prebuilt/core/error.mycpp.h: GENERATED by mycpp
|
| 2 |
|
| 3 | #ifndef CORE_ERROR_MYCPP_H
|
| 4 | #define CORE_ERROR_MYCPP_H
|
| 5 |
|
| 6 | #include "_gen/asdl/hnode.asdl.h"
|
| 7 | #include "_gen/display/pretty.asdl.h"
|
| 8 | #include "cpp/data_lang.h"
|
| 9 | #include "mycpp/runtime.h"
|
| 10 |
|
| 11 | #include "_gen/core/runtime.asdl.h"
|
| 12 | #include "_gen/core/value.asdl.h"
|
| 13 | #include "_gen/frontend/syntax.asdl.h"
|
| 14 |
|
| 15 | using value_asdl::value; // This is a bit ad hoc
|
| 16 |
|
| 17 | namespace error { // forward declare
|
| 18 | class _ErrorWithLocation;
|
| 19 | class Usage;
|
| 20 | class Parse;
|
| 21 | class WordFailure;
|
| 22 | class FailGlob;
|
| 23 | class VarSubFailure;
|
| 24 | class RedirectEval;
|
| 25 | class FatalRuntime;
|
| 26 | class Strict;
|
| 27 | class ErrExit;
|
| 28 | class NoUnset;
|
| 29 | class Expr;
|
| 30 | class Structured;
|
| 31 | class AssertionErr;
|
| 32 | class TypeErrVerbose;
|
| 33 | class TypeErr;
|
| 34 | class Runtime;
|
| 35 | class Decode;
|
| 36 | class Encode;
|
| 37 | }
|
| 38 |
|
| 39 | namespace error { // declare
|
| 40 |
|
| 41 | extern int EXPR_STATUS;
|
| 42 | extern int CODEC_STATUS;
|
| 43 | extern int GLOB_STATUS;
|
| 44 | extern int BUILTIN_DEFAULT_STATUS;
|
| 45 | BigStr* _ValType(value_asdl::value_t* val);
|
| 46 | class _ErrorWithLocation {
|
| 47 | public:
|
| 48 | _ErrorWithLocation(BigStr* msg, syntax_asdl::loc_t* location);
|
| 49 | bool HasLocation();
|
| 50 | BigStr* UserErrorString();
|
| 51 | syntax_asdl::loc_t* location{};
|
| 52 | BigStr* msg{};
|
| 53 |
|
| 54 | static constexpr uint32_t field_mask() {
|
| 55 | return maskbit(offsetof(_ErrorWithLocation, location))
|
| 56 | | maskbit(offsetof(_ErrorWithLocation, msg));
|
| 57 | }
|
| 58 |
|
| 59 | static constexpr ObjHeader obj_header() {
|
| 60 | return ObjHeader::ClassFixed(field_mask(), sizeof(_ErrorWithLocation));
|
| 61 | }
|
| 62 |
|
| 63 | DISALLOW_COPY_AND_ASSIGN(_ErrorWithLocation)
|
| 64 | };
|
| 65 |
|
| 66 | class Usage : public ::error::_ErrorWithLocation {
|
| 67 | public:
|
| 68 | Usage(BigStr* msg, syntax_asdl::loc_t* location);
|
| 69 |
|
| 70 | static constexpr uint32_t field_mask() {
|
| 71 | return ::error::_ErrorWithLocation::field_mask();
|
| 72 | }
|
| 73 |
|
| 74 | static constexpr ObjHeader obj_header() {
|
| 75 | return ObjHeader::ClassFixed(field_mask(), sizeof(Usage));
|
| 76 | }
|
| 77 |
|
| 78 | DISALLOW_COPY_AND_ASSIGN(Usage)
|
| 79 | };
|
| 80 |
|
| 81 | class Parse : public ::error::_ErrorWithLocation {
|
| 82 | public:
|
| 83 | Parse(BigStr* msg, syntax_asdl::loc_t* location);
|
| 84 |
|
| 85 | static constexpr uint32_t field_mask() {
|
| 86 | return ::error::_ErrorWithLocation::field_mask();
|
| 87 | }
|
| 88 |
|
| 89 | static constexpr ObjHeader obj_header() {
|
| 90 | return ObjHeader::ClassFixed(field_mask(), sizeof(Parse));
|
| 91 | }
|
| 92 |
|
| 93 | DISALLOW_COPY_AND_ASSIGN(Parse)
|
| 94 | };
|
| 95 |
|
| 96 | class WordFailure : public ::error::_ErrorWithLocation {
|
| 97 | public:
|
| 98 | WordFailure(BigStr* msg, syntax_asdl::loc_t* location);
|
| 99 |
|
| 100 | static constexpr uint32_t field_mask() {
|
| 101 | return ::error::_ErrorWithLocation::field_mask();
|
| 102 | }
|
| 103 |
|
| 104 | static constexpr ObjHeader obj_header() {
|
| 105 | return ObjHeader::ClassFixed(field_mask(), sizeof(WordFailure));
|
| 106 | }
|
| 107 |
|
| 108 | DISALLOW_COPY_AND_ASSIGN(WordFailure)
|
| 109 | };
|
| 110 |
|
| 111 | class FailGlob : public ::error::WordFailure {
|
| 112 | public:
|
| 113 | FailGlob(BigStr* msg, syntax_asdl::loc_t* location);
|
| 114 |
|
| 115 | static constexpr uint32_t field_mask() {
|
| 116 | return ::error::WordFailure::field_mask();
|
| 117 | }
|
| 118 |
|
| 119 | static constexpr ObjHeader obj_header() {
|
| 120 | return ObjHeader::ClassFixed(field_mask(), sizeof(FailGlob));
|
| 121 | }
|
| 122 |
|
| 123 | DISALLOW_COPY_AND_ASSIGN(FailGlob)
|
| 124 | };
|
| 125 |
|
| 126 | class VarSubFailure : public ::error::WordFailure {
|
| 127 | public:
|
| 128 | VarSubFailure(BigStr* msg, syntax_asdl::loc_t* location);
|
| 129 |
|
| 130 | static constexpr uint32_t field_mask() {
|
| 131 | return ::error::WordFailure::field_mask();
|
| 132 | }
|
| 133 |
|
| 134 | static constexpr ObjHeader obj_header() {
|
| 135 | return ObjHeader::ClassFixed(field_mask(), sizeof(VarSubFailure));
|
| 136 | }
|
| 137 |
|
| 138 | DISALLOW_COPY_AND_ASSIGN(VarSubFailure)
|
| 139 | };
|
| 140 |
|
| 141 | class RedirectEval : public ::error::_ErrorWithLocation {
|
| 142 | public:
|
| 143 | RedirectEval(BigStr* msg, syntax_asdl::loc_t* location);
|
| 144 |
|
| 145 | static constexpr uint32_t field_mask() {
|
| 146 | return ::error::_ErrorWithLocation::field_mask();
|
| 147 | }
|
| 148 |
|
| 149 | static constexpr ObjHeader obj_header() {
|
| 150 | return ObjHeader::ClassFixed(field_mask(), sizeof(RedirectEval));
|
| 151 | }
|
| 152 |
|
| 153 | DISALLOW_COPY_AND_ASSIGN(RedirectEval)
|
| 154 | };
|
| 155 |
|
| 156 | class FatalRuntime : public ::error::_ErrorWithLocation {
|
| 157 | public:
|
| 158 | FatalRuntime(int exit_status, BigStr* msg, syntax_asdl::loc_t* location);
|
| 159 | int ExitStatus();
|
| 160 |
|
| 161 | int exit_status{};
|
| 162 |
|
| 163 | static constexpr uint32_t field_mask() {
|
| 164 | return ::error::_ErrorWithLocation::field_mask();
|
| 165 | }
|
| 166 |
|
| 167 | static constexpr ObjHeader obj_header() {
|
| 168 | return ObjHeader::ClassFixed(field_mask(), sizeof(FatalRuntime));
|
| 169 | }
|
| 170 |
|
| 171 | DISALLOW_COPY_AND_ASSIGN(FatalRuntime)
|
| 172 | };
|
| 173 |
|
| 174 | class Strict : public ::error::FatalRuntime {
|
| 175 | public:
|
| 176 | Strict(BigStr* msg, syntax_asdl::loc_t* location);
|
| 177 |
|
| 178 | static constexpr uint32_t field_mask() {
|
| 179 | return ::error::FatalRuntime::field_mask();
|
| 180 | }
|
| 181 |
|
| 182 | static constexpr ObjHeader obj_header() {
|
| 183 | return ObjHeader::ClassFixed(field_mask(), sizeof(Strict));
|
| 184 | }
|
| 185 |
|
| 186 | DISALLOW_COPY_AND_ASSIGN(Strict)
|
| 187 | };
|
| 188 |
|
| 189 | class ErrExit : public ::error::FatalRuntime {
|
| 190 | public:
|
| 191 | ErrExit(int exit_status, BigStr* msg, syntax_asdl::loc_t* location, bool show_code = false);
|
| 192 |
|
| 193 | bool show_code{};
|
| 194 |
|
| 195 | static constexpr uint32_t field_mask() {
|
| 196 | return ::error::FatalRuntime::field_mask();
|
| 197 | }
|
| 198 |
|
| 199 | static constexpr ObjHeader obj_header() {
|
| 200 | return ObjHeader::ClassFixed(field_mask(), sizeof(ErrExit));
|
| 201 | }
|
| 202 |
|
| 203 | DISALLOW_COPY_AND_ASSIGN(ErrExit)
|
| 204 | };
|
| 205 |
|
| 206 | class NoUnset : public ::error::FatalRuntime {
|
| 207 | public:
|
| 208 | NoUnset(BigStr* msg, syntax_asdl::loc_t* location);
|
| 209 |
|
| 210 | static constexpr uint32_t field_mask() {
|
| 211 | return ::error::FatalRuntime::field_mask();
|
| 212 | }
|
| 213 |
|
| 214 | static constexpr ObjHeader obj_header() {
|
| 215 | return ObjHeader::ClassFixed(field_mask(), sizeof(NoUnset));
|
| 216 | }
|
| 217 |
|
| 218 | DISALLOW_COPY_AND_ASSIGN(NoUnset)
|
| 219 | };
|
| 220 |
|
| 221 | class Expr : public ::error::FatalRuntime {
|
| 222 | public:
|
| 223 | Expr(BigStr* msg, syntax_asdl::loc_t* location);
|
| 224 |
|
| 225 | static constexpr uint32_t field_mask() {
|
| 226 | return ::error::FatalRuntime::field_mask();
|
| 227 | }
|
| 228 |
|
| 229 | static constexpr ObjHeader obj_header() {
|
| 230 | return ObjHeader::ClassFixed(field_mask(), sizeof(Expr));
|
| 231 | }
|
| 232 |
|
| 233 | DISALLOW_COPY_AND_ASSIGN(Expr)
|
| 234 | };
|
| 235 |
|
| 236 | class Structured : public ::error::FatalRuntime {
|
| 237 | public:
|
| 238 | Structured(int status, BigStr* msg, syntax_asdl::loc_t* location, Dict<BigStr*, value_asdl::value_t*>* properties = nullptr);
|
| 239 | value::Dict* ToDict();
|
| 240 |
|
| 241 | Dict<BigStr*, value_asdl::value_t*>* properties{};
|
| 242 |
|
| 243 | static constexpr uint32_t field_mask() {
|
| 244 | return ::error::FatalRuntime::field_mask()
|
| 245 | | maskbit(offsetof(Structured, properties));
|
| 246 | }
|
| 247 |
|
| 248 | static constexpr ObjHeader obj_header() {
|
| 249 | return ObjHeader::ClassFixed(field_mask(), sizeof(Structured));
|
| 250 | }
|
| 251 |
|
| 252 | DISALLOW_COPY_AND_ASSIGN(Structured)
|
| 253 | };
|
| 254 |
|
| 255 | class AssertionErr : public ::error::Expr {
|
| 256 | public:
|
| 257 | AssertionErr(BigStr* msg, syntax_asdl::loc_t* location);
|
| 258 |
|
| 259 | static constexpr uint32_t field_mask() {
|
| 260 | return ::error::Expr::field_mask();
|
| 261 | }
|
| 262 |
|
| 263 | static constexpr ObjHeader obj_header() {
|
| 264 | return ObjHeader::ClassFixed(field_mask(), sizeof(AssertionErr));
|
| 265 | }
|
| 266 |
|
| 267 | DISALLOW_COPY_AND_ASSIGN(AssertionErr)
|
| 268 | };
|
| 269 |
|
| 270 | class TypeErrVerbose : public ::error::Expr {
|
| 271 | public:
|
| 272 | TypeErrVerbose(BigStr* msg, syntax_asdl::loc_t* location);
|
| 273 |
|
| 274 | static constexpr uint32_t field_mask() {
|
| 275 | return ::error::Expr::field_mask();
|
| 276 | }
|
| 277 |
|
| 278 | static constexpr ObjHeader obj_header() {
|
| 279 | return ObjHeader::ClassFixed(field_mask(), sizeof(TypeErrVerbose));
|
| 280 | }
|
| 281 |
|
| 282 | DISALLOW_COPY_AND_ASSIGN(TypeErrVerbose)
|
| 283 | };
|
| 284 |
|
| 285 | class TypeErr : public ::error::TypeErrVerbose {
|
| 286 | public:
|
| 287 | TypeErr(value_asdl::value_t* actual_val, BigStr* msg, syntax_asdl::loc_t* location);
|
| 288 |
|
| 289 | static constexpr uint32_t field_mask() {
|
| 290 | return ::error::TypeErrVerbose::field_mask();
|
| 291 | }
|
| 292 |
|
| 293 | static constexpr ObjHeader obj_header() {
|
| 294 | return ObjHeader::ClassFixed(field_mask(), sizeof(TypeErr));
|
| 295 | }
|
| 296 |
|
| 297 | DISALLOW_COPY_AND_ASSIGN(TypeErr)
|
| 298 | };
|
| 299 |
|
| 300 | class Runtime {
|
| 301 | public:
|
| 302 | Runtime(BigStr* msg);
|
| 303 | BigStr* UserErrorString();
|
| 304 | BigStr* msg{};
|
| 305 |
|
| 306 | static constexpr ObjHeader obj_header() {
|
| 307 | return ObjHeader::ClassScanned(1, sizeof(Runtime));
|
| 308 | }
|
| 309 |
|
| 310 | DISALLOW_COPY_AND_ASSIGN(Runtime)
|
| 311 | };
|
| 312 |
|
| 313 | class Decode {
|
| 314 | public:
|
| 315 | Decode(BigStr* msg, BigStr* s, int start_pos, int end_pos, int line_num);
|
| 316 | BigStr* Message();
|
| 317 | BigStr* __str__();
|
| 318 | BigStr* msg{};
|
| 319 | BigStr* s{};
|
| 320 | int start_pos{};
|
| 321 | int end_pos{};
|
| 322 | int line_num{};
|
| 323 |
|
| 324 | static constexpr ObjHeader obj_header() {
|
| 325 | return ObjHeader::ClassScanned(2, sizeof(Decode));
|
| 326 | }
|
| 327 |
|
| 328 | DISALLOW_COPY_AND_ASSIGN(Decode)
|
| 329 | };
|
| 330 |
|
| 331 | class Encode {
|
| 332 | public:
|
| 333 | Encode(BigStr* msg);
|
| 334 | BigStr* Message();
|
| 335 | BigStr* msg{};
|
| 336 |
|
| 337 | static constexpr ObjHeader obj_header() {
|
| 338 | return ObjHeader::ClassScanned(1, sizeof(Encode));
|
| 339 | }
|
| 340 |
|
| 341 | DISALLOW_COPY_AND_ASSIGN(Encode)
|
| 342 | };
|
| 343 |
|
| 344 | [[noreturn]] void e_usage(BigStr* msg, syntax_asdl::loc_t* location);
|
| 345 | [[noreturn]] void e_strict(BigStr* msg, syntax_asdl::loc_t* location);
|
| 346 | [[noreturn]] void p_die(BigStr* msg, syntax_asdl::loc_t* location);
|
| 347 | [[noreturn]] void e_die(BigStr* msg, syntax_asdl::loc_t* location = nullptr);
|
| 348 | [[noreturn]] void e_die_status(int status, BigStr* msg, syntax_asdl::loc_t* location = nullptr);
|
| 349 |
|
| 350 | } // declare namespace error
|
| 351 |
|
| 352 | #endif // CORE_ERROR_MYCPP_H
|