* sim/ucsim/*.*, sim/ucsim/configure, sim/ucsim/configure.in:
[fw/sdcc] / sim / ucsim / error.cc
index a8c533bbc7f5d40bce7ca99ad00fbe83631be4ec..eea6639175bdd0860df24654ea12bd4e62f2ade3 100644 (file)
 
 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_error_class error_class_base(err_error, "non-classified", ERROR_ON);
+static class cl_error_registry error_registry;
 
-class cl_list *registered_errors= NIL;
+class cl_list *cl_error_registry::registered_errors= NIL;
 
 /*
  */
 
-cl_error_class::cl_error_class(enum error_type typ, char *aname):
-  cl_base()
-{
-  type= typ;
-  on= ERROR_PARENT;
-  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,
-                              enum error_on_off be_on):
+cl_error_class::cl_error_class(enum error_type typ, const char *aname,
+                               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):
-  cl_base()
-{
-  type= typ;
-  on= ERROR_PARENT;
-  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);
-}
-
-cl_error_class::cl_error_class(enum error_type typ, char *aname,
-                              class cl_error_class *parent,
-                              enum error_on_off be_on):
+cl_error_class::cl_error_class(enum error_type typ, const char *aname,
+                               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);
 }
@@ -119,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<class cl_error_class *>(get_parent());
+        dynamic_cast<class cl_error_class *>(get_parent());
       return(p->is_on());
     }
   else
@@ -140,7 +109,7 @@ cl_error_class::get_name(void)
   return(name);
 }*/
 
-char *
+const char *
 cl_error_class::get_type_name()
 {
   return(get_id_string(error_type_names, type, "untyped"));
@@ -160,8 +129,7 @@ cl_error_class::get_type_name()
 cl_error::cl_error(void):
   cl_base()
 {
-  //type= err_unknown;
-  classification= 0;
+  classification= error_registry.find("non-classified");
 }
 
 cl_error::~cl_error(void)
@@ -199,17 +167,23 @@ 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());
 }
 
-char *
+const char *
 cl_error::get_type_name()
 {
   enum error_type type= get_type();
   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 */