1 /* 2 $Id: errorobj.h 2596 2021-04-18 18:52:11Z soci $ 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along 15 with this program; if not, write to the Free Software Foundation, Inc., 16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 18 */ 19 #ifndef ERROROBJ_H 20 #define ERROROBJ_H 21 #include "obj.h" 22 #include "errors_e.h" 23 #include "oper_e.h" 24 #include "stdbool.h" 25 26 extern struct Type *const ERROR_OBJ; 27 28 typedef struct Error { 29 Obj v; 30 Error_types num; 31 const struct file_list_s *file_list; 32 struct linepos_s epoint; 33 linecpos_t caret; 34 const uint8_t *line; 35 union { 36 struct { 37 Oper_types op; 38 Obj *v1; 39 Obj *v2; 40 } invoper; 41 struct { 42 Obj *symbol; 43 struct Namespace *names; 44 bool down; 45 } notdef; 46 struct { 47 unsigned int bits; 48 Obj *val; 49 } intconv; 50 struct { 51 const struct Type *t; 52 Obj *val; 53 } conv; 54 Obj *obj; 55 struct { 56 uint32_t am, cod; 57 } addressing; 58 struct { 59 struct Register *reg; 60 uint32_t cod; 61 } reg; 62 struct { 63 size_t num; 64 uint32_t cod; 65 } opers; 66 struct { 67 uint32_t cod; 68 } addresssize; 69 struct { 70 size_t v1; 71 size_t v2; 72 } broadcast; 73 struct { 74 argcount_t num, min, max; 75 } argnum; 76 } u; 77 } Error; 78 79 #define Error(a) ((Error *)(1 ? (a) : (Obj *)(Error *)(a))) 80 81 extern void errorobj_init(void); 82 83 extern MALLOC Error *new_error(Error_types, linepos_t); 84 extern MALLOC Obj *new_error_mem(linepos_t); 85 extern MALLOC Obj *new_error_obj(Error_types, Obj *, linepos_t); 86 extern MALLOC Obj *new_error_conv(Obj *, struct Type *, linepos_t); 87 extern MALLOC Obj *new_error_argnum(argcount_t, argcount_t, argcount_t, linepos_t); 88 extern void error_obj_update(Error *, const Obj *, Obj *); 89 90 #endif 91