version 0.5.2
[fw/sdcc] / sim / ucsim / errorcl.h
1 /*
2  * Simulator of microcontrollers (errorcl.h)
3  *
4  * Copyright (C) 2001,01 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /*
11   This file is part of microcontroller simulator: ucsim.
12
13   UCSIM is free software; you can redistribute it and/or modify
14   it under the terms of the GNU General Public License as published by
15   the Free Software Foundation; either version 2 of the License, or
16   (at your option) any later version.
17
18   UCSIM is distributed in the hope that it will be useful,
19   but WITHOUT ANY WARRANTY; without even the implied warranty of
20   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21   GNU General Public License for more details.
22
23   You should have received a copy of the GNU General Public License
24   along with UCSIM; see the file COPYING.  If not, write to the Free
25   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26   02111-1307, USA.
27 */
28 /*@1@*/
29
30 #ifndef ERRORCL_HEADER
31 #define ERRORCL_HEADER
32
33 // prj
34 #include "pobjcl.h"
35 #include "stypes.h"
36
37 extern struct id_element error_on_off_names[];
38
39 enum error_on_off {
40   ERROR_PARENT,
41   ERROR_ON,
42   ERROR_OFF
43 };
44
45 const int err_stop= (err_unknown|err_error);
46
47 /*
48 #define ERROR_METHODS(NAME) \
49 enum error_type \
50 cl_error_##NAME ::get_type(void)\
51 {\
52   return(err_##NAME##_class.get_type());\
53 }\
54 bool \
55 cl_error_##NAME ::is_on(void)\
56 {\
57   return(err_##NAME##_class.is_on());\
58 }
59 */
60
61 #define ERROR_CLASS_DECL(NAME) \
62 extern class cl_error_class error_##NAME##_class;\
63 class cl_error_##NAME
64
65 /*
66 #define ERROR_CLASS_DEF(TYPE,NAME,CLASS_NAME) \
67 class cl_error_class error_##NAME##_class(TYPE, CLASS_NAME);
68 */
69 /*
70 #define ERROR_CLASS_DEF_ON(TYPE,NAME,CLASS_NAME,ON) \
71 class cl_error_class error_##NAME##_class(TYPE, CLASS_NAME, ON);
72 */
73
74 #define ERROR_CLASS_DEF_PARENT(TYPE,NAME,CLASS_NAME,PARENT) \
75 class cl_error_class error_##NAME##_class(TYPE, CLASS_NAME, &(PARENT));
76
77 #define ERROR_CLASS_DEF_PARENT_ON(TYPE,NAME,CLASS_NAME,PARENT,ON) \
78 class cl_error_class error_##NAME##_class(TYPE, CLASS_NAME, &(PARENT), ON);
79
80
81 extern class cl_list *registered_errors;
82
83 class cl_error_class: public cl_base
84 {
85 protected:
86   enum error_type type;
87   //char *name;
88   enum error_on_off on;
89 public:
90   cl_error_class(enum error_type typ, char *aname);
91   cl_error_class(enum error_type typ, char *aname,
92                  enum error_on_off be_on);
93   cl_error_class(enum error_type typ, char *aname,
94                  class cl_error_class *parent);
95   cl_error_class(enum error_type typ, char *aname,
96                  class cl_error_class *parent,
97                  enum error_on_off be_on);
98   
99   enum error_on_off get_on(void) { return(on); }
100   void set_on(enum error_on_off val);
101   bool is_on(void);
102   enum error_type get_type(void);
103   char *get_type_name(void);
104   //char *get_name(void);
105 };
106
107 extern class cl_error_class error_class_base;
108
109
110 class cl_commander; //forward
111
112 class cl_error: public cl_base
113 {
114 protected:
115   class cl_error_class *classification;
116 public:
117   bool inst;    // Occured during instruction execution
118   t_addr PC;    // Address of the instruction
119 public:
120   cl_error(void);
121   virtual ~cl_error(void);
122   virtual int init(void);
123  
124 public:
125   virtual enum error_type get_type(void);
126   virtual enum error_on_off get_on(void);
127   virtual bool is_on(void);
128   virtual class cl_error_class *get_class(void) { return(classification); }
129
130   virtual void print(class cl_commander *c);
131   virtual char *get_type_name();
132 };
133
134
135 #endif
136
137 /* End of sim.src/errorcl.h */