X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=sim%2Fucsim%2Ferrorcl.h;h=91d821f3a5d6c90034ce953471fa12d437caf080;hb=90f4aedaef8a2310573eef905f95c671f84e5cde;hp=a061b3a311e6d0c07de6704fff515bc8637ae04c;hpb=5156ec0bb15ef639c2aa78f616a05e3ab0435813;p=fw%2Fsdcc diff --git a/sim/ucsim/errorcl.h b/sim/ucsim/errorcl.h index a061b3a3..91d821f3 100644 --- a/sim/ucsim/errorcl.h +++ b/sim/ucsim/errorcl.h @@ -30,6 +30,8 @@ #ifndef ERRORCL_HEADER #define ERRORCL_HEADER +#include + // prj #include "pobjcl.h" #include "stypes.h" @@ -44,8 +46,6 @@ enum error_on_off { const int err_stop= (err_unknown|err_error); -extern class cl_list *registered_errors; - class cl_error_class: public cl_base { protected: @@ -54,10 +54,10 @@ protected: enum error_on_off on; public: cl_error_class(enum error_type typ, char *aname, - enum error_on_off be_on= ERROR_PARENT); + enum error_on_off be_on= ERROR_PARENT); cl_error_class(enum error_type typ, char *aname, - class cl_error_class *parent, - enum error_on_off be_on= ERROR_PARENT); + class cl_error_class *parent, + enum error_on_off be_on= ERROR_PARENT); enum error_on_off get_on(void) { return(on); } void set_on(enum error_on_off val); @@ -67,17 +67,47 @@ public: //char *get_name(void); }; -class cl_commander; //forward +class cl_error_registry +{ +public: + cl_error_registry(void); + class cl_error_class *find(char *type_name) + { + if (NIL == registered_errors) + return NIL; + return static_cast(registered_errors->first_that(compare, static_cast(type_name))); + } + static class cl_list *get_list(void) + { + return registered_errors; + } + +protected: + class cl_error_class *register_error(class cl_error_class *error_class) + { + if (!registered_errors) + registered_errors= new cl_list(2, 2, "registered errors"); + registered_errors->add(error_class); + return error_class; + } + +private: + static class cl_list *registered_errors; + static int compare(void *obj1, void *obj2) + { + return (static_cast(obj1))->is_named(static_cast(obj2)); + } +}; + +class cl_commander_base; //forward class cl_error: public cl_base { -private: - static class cl_error_class *error_class_base; protected: class cl_error_class *classification; public: - bool inst; // Occured during instruction execution - t_addr PC; // Address of the instruction + bool inst; // Occured during instruction execution + t_addr PC; // Address of the instruction public: cl_error(void); virtual ~cl_error(void); @@ -89,11 +119,11 @@ public: virtual bool is_on(void); virtual class cl_error_class *get_class(void) { return(classification); } - virtual void print(class cl_commander *c); + virtual void print(class cl_commander_base *c); virtual char *get_type_name(); }; - #endif + /* End of sim.src/errorcl.h */