X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=sim%2Fucsim%2Ferror.cc;h=8494cdd24cebb1d5c62f8c651614772ee0bf1dbb;hb=011a73edf0a9ef1e9c50cdf01c94050bbfc70bdf;hp=b63a9bf5183cdbedfc619491c1c577c28d547834;hpb=5156ec0bb15ef639c2aa78f616a05e3ab0435813;p=fw%2Fsdcc diff --git a/sim/ucsim/error.cc b/sim/ucsim/error.cc index b63a9bf5..8494cdd2 100644 --- a/sim/ucsim/error.cc +++ b/sim/ucsim/error.cc @@ -40,39 +40,35 @@ struct id_element error_on_off_names[]= { { ERROR_PARENT, "unset" }, - { ERROR_ON , "on" }, - { ERROR_OFF , "off" }, - { 0 , 0 } + { ERROR_ON , "on" }, + { ERROR_OFF , "off" }, + { 0 , 0 } }; -class cl_list *registered_errors= NIL; +static class cl_error_registry error_registry; + +class cl_list *cl_error_registry::registered_errors= NIL; /* */ cl_error_class::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_base() { type= typ; on= be_on; set_name(aname, "not-known"); - if (!registered_errors) - registered_errors= new cl_list(2, 2, "registered errors"); - registered_errors->add(this); } cl_error_class::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*/): cl_base() { type= typ; on= be_on; set_name(aname, "not-known"); - if (!registered_errors) - registered_errors= new cl_list(2, 2, "registered errors"); - registered_errors->add(this); if (parent) parent->add_child(this); } @@ -92,9 +88,9 @@ cl_error_class::is_on(void) if (on == ERROR_PARENT) { if (!get_parent()) - return(DD_TRUE); + return(DD_TRUE); class cl_error_class *p= - dynamic_cast(get_parent()); + dynamic_cast(get_parent()); return(p->is_on()); } else @@ -130,15 +126,10 @@ cl_error_class::get_type_name() /* */ -class cl_error_class *cl_error::error_class_base; - cl_error::cl_error(void): cl_base() { - if (NULL == error_class_base) - error_class_base = new cl_error_class(err_error, "non-classified", ERROR_ON); - //type= err_unknown; - classification= error_class_base; + classification= error_registry.find("non-classified"); } cl_error::~cl_error(void) @@ -176,7 +167,7 @@ cl_error::is_on(void) } void -cl_error::print(class cl_commander *c) +cl_error::print(class cl_commander_base *c) { c->dd_printf("%s\n", get_type_name()); } @@ -188,5 +179,11 @@ cl_error::get_type_name() return(get_id_string(error_type_names, type, "untyped")); } +cl_error_registry::cl_error_registry(void) +{ + if (NULL == error_registry.find("non-classified")) + register_error(new cl_error_class(err_error, "non-classified", ERROR_ON)); +} + /* End of sim.src/error.cc */