home *** CD-ROM | disk | FTP | other *** search
- #line 1 "/fzi/prost/stone/SOS3-2/src/mta/mta.c"
- /* --------------------------------------------------------------------------
- * Copyright 1992 by Forschungszentrum Informatik (FZI)
- *
- * You can use and distribute this software under the terms of the licence
- * you should have received along with this program.
- * If not or if you want additional information, write to
- * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
- * D-7500 Karlsruhe 1, Germany.
- * --------------------------------------------------------------------------
- */
- // **************************************************************************
- // Module mta 03/06/89 Juergen Uhl (ju)
- //
- // **************************************************************************
- // implements methods of all classes declared in schema "mta"
- // **************************************************************************
-
- #include "sys.h"
- #include "smg.h"
- #include "mta_err.h"
- #include "trc_mta.h"
-
- #include "dir_use.h"
- #include "cci_use.h"
-
- #include "mta_sos.h"
-
- static sos_Schema_type get_object_type();
- static sos_Schema_type get_scalar_object_type();
-
- // *************************************************************************
- sos_Schema_type _sos_Imports::lookup_type (sos_Typed_id &_tpid,sos_String name,
- sos_Bool look_for_alias)
- // *************************************************************************
-
- {
- T_PROC ("sos_Imports::lookup_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result = sos_Schema_type::make (NO_OBJECT);
- sos_Imports imp = sos_Imports::make(_tpid,this);
- agg_iterate (imp, sos_Schema_module sm)
- { result = sm.get_type_table()[name];
- if (result != NO_OBJECT)
- if (NOT look_for_alias AND
- NOT result.get_name().equal(name))
- result = sos_Schema_type::make (NO_OBJECT);
- else
- break;
- }
- agg_iterate_end (imp, sm);
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Schema_module_Directory _sos_Schema_module::schema_dir ()
- // *************************************************************************
- {
- T_PROC ("sos_Schema_module::schema_dir");
- TT (mta_H, T_ENTER);
-
- sos_String name;
- sos_Schema_module_Directory dir;
- sos_Directory root_dir;
-
- name = smg_String ("sos_schemas").make_String (TEMP_CONTAINER);
- ROOT_CONTAINER.open (READING, WAITING);
- root_dir = sos_Object_Directory::root();
- dir = sos_Schema_module_Directory::make (root_dir [name]);
- ROOT_CONTAINER.close ();
- if (dir == NO_OBJECT)
- { dir = sos_Schema_module_Directory::create (sos_Container::create(), name);
- ROOT_CONTAINER.open (WRITING, WAITING);
- root_dir.insert (name, dir);
- ROOT_CONTAINER.close ();
- }
- name.destroy();
-
- TT (mta_H, T_LEAVE);
-
- return dir;
- }
-
- // *************************************************************************
- sos_Schema_module _sos_Schema_module::lookup (sos_String name)
- // *************************************************************************
- { T_PROC ("sos_Schema_module::lookup")
- TT (mta_H, T_ENTER);
-
- sos_Schema_module sm;
- sos_Schema_module_Directory sd = sos_Schema_module::schema_dir ();
-
- sd.container().open (READING, WAITING);
- if (sd.is_key (name))
- sm = sos_Schema_module::make (sd [name]);
- else
- sm = sos_Schema_module::make (NO_OBJECT);
- sd.container().close ();
-
- TT (mta_H, T_LEAVE);
-
- return sm;
- }
-
- // *************************************************************************
- sos_Schema_module _sos_Schema_module::retrieve (sos_Container ct)
- // *************************************************************************
- { T_PROC ("sos_Schema_module::retrieve")
- TT (mta_H, T_ENTER);
-
- sos_Schema_module sm = sos_Schema_module::make (ct.root_object());
-
- TT (mta_H, T_LEAVE);
- return sm;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Schema_module::lookup_type
- (sos_Typed_id &_tpid,sos_String name, sos_Bool look_for_alias)
- // *************************************************************************
-
- // search for a type declaration with 'name' in the type table
- // of the schema module. If no declaration is found search for 'name'
- // in the type tables of the imported modules. If the search fails
- // return NO_OBJECT.
-
- { T_PROC ("sos_Schema_module::lookup_type")
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result;
- sos_Type_table tt = sos_Schema_module::make(_tpid,this).get_type_table();
-
- result = tt[name];
- if (result == NO_OBJECT)
- result = sos_Schema_module::make(_tpid,this).get_imports().lookup_type (name, look_for_alias);
- else if (NOT look_for_alias AND
- NOT result.get_name().equal(name))
- result = sos_Schema_type::make (NO_OBJECT);
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- void _sos_Schema_module::open_imports (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Schema_module::open_imports");
- TT (mta_H, T_ENTER);
-
- sos_Imports imp = sos_Schema_module::make(_tpid,this).get_imports();
- agg_iterate (imp, sos_Schema_module sm)
- { sm.container().open(READING, WAITING);
- }
- agg_iterate_end (imp, sm);
-
- TT (mta_H, T_LEAVE);
- }
-
- // *************************************************************************
- void _sos_Schema_module::close_imports (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Schema_module::close_imports");
- TT (mta_H, T_ENTER);
-
- sos_Imports imp = sos_Schema_module::make(_tpid,this).get_imports();
- agg_iterate (imp, sos_Schema_module sm)
- { sm.container().close();
- }
- agg_iterate_end (imp, sm);
-
- TT (mta_H, T_LEAVE);
- }
-
- // *************************************************************************
- void _sos_Schema_module::install (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Schema_module::install");
- TT (mta_H, T_ENTER);
-
- sos_String str;
- sos_Container ct;
- sos_Schema_module_Directory sd = sos_Schema_module::schema_dir ();
-
- sd.container().open (WRITING, WAITING);
- str = sos_Schema_module::make(_tpid,this).get_name ();
- if (sd.is_key (str))
- { // not yet implemented:
- // info that schemas must be recompiled
- ct = sd[str].container();
- sd.remove (str);
- ct.open (WRITING, WAITING);
- ct.destroy();
- ct.close();
- }
-
- sd.insert (str, sos_Schema_module::make(_tpid,this));
- sd.container().close ();
-
- TT (mta_H, T_LEAVE);
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Type_name::make_base_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Type_name::make_base_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result = sos_Type_name::make(_tpid,this).make_type();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Expr_List _sos_Type_name::create_params (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Type_name::create_params");
- TT (mta_H, T_ENTER);
-
- sos_Expr_List result = sos_Expr_List::make (NO_OBJECT);
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Type_name::make_root_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Type_name::make_root_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result = sos_Type_name::make(_tpid,this).make_base_type();
- if (NOT sos_Type_name::make(_tpid,this).identical (result))
- result = result.make_root_type();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Schema_type::make_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Schema_type::make_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result = sos_Schema_type::make(_tpid,this);
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_String _sos_Schema_type::make_type_name (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Schema_type::make_type_name");
- TT (mta_H, T_ENTER);
-
- sos_String result = sos_Schema_type::make(_tpid,this).get_name();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Schema_type::is_derived_from (sos_Typed_id &_tpid,sos_Type tp)
- // *************************************************************************
- {
- T_PROC ("sos_Schema_type::is_derived_from");
- TT (mta_H, T_ENTER);
-
- sos_Bool result;
-
- sos_Type b1 = sos_Schema_type::make(_tpid,this).base ();
- sos_Type b2 = tp.base ();
-
- #ifdef ATT
- if (b1.operator== (b2))
- #else
- if (b1 == b2)
- #endif
- result = TRUE;
- else
- {
- #ifdef ATT
- if (sos_Schema_type::make(_tpid,this).operator!= (b1) OR tp.operator!= (b2))
- #else
- if (sos_Schema_type::make(_tpid,this) != b1 OR tp != b2)
- #endif
- result = b1.is_derived_from (b2);
- else if (b1.has_type (sos_Extern_type_type) OR
- b1.has_type (sos_Enum_type_type))
- result = get_scalar_object_type().is_derived_from (b2);
- // this handles the cases:
- // - b2 is no scalar type
- // - b2 is a scalar type different from b1
- // 'b2 is a scalar type identical with b1' is handled above
- else
- result = (sos_Bool)(b1.equal (b2) OR
- b2.equal (get_object_type()));
- }
-
- TT (mta_H, T_LEAVE; TB (result));
-
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Schema_type::is_derived_from_some (sos_Typed_id &_tpid,sos_Type tp)
- // *************************************************************************
- {
- T_PROC ("sos_Schema_type::is_derived_from_some");
- TT (mta_H, T_ENTER);
-
- sos_Bool result;
-
- sos_Type b1 = sos_Schema_type::make(_tpid,this).base ();
- sos_Type b2 = tp.base ();
-
- #ifdef ATT
- if (b1.operator== (b2))
- #else
- if (b1 == b2)
- #endif
- result = TRUE;
- else
- {
- #ifdef ATT
- if (sos_Schema_type::make(_tpid,this).operator!= (b1) OR tp.operator!= (b2))
- #else
- if (sos_Schema_type::make(_tpid,this) != b1 OR tp != b2)
- #endif
- result = b1.is_derived_from_some (b2);
- else if (b1.has_type (sos_Extern_type_type) OR
- b1.has_type (sos_Enum_type_type))
- result = get_scalar_object_type().is_derived_from_some (b2);
- // this handles the cases:
- // - b2 is no scalar type
- // - b2 is a scalar type different from b1
- // 'b2 is a scalar type identical with b1' is handled above
- else
- result = (sos_Bool)(b1.equal (b2) OR
- b2.equal (get_object_type()));
- }
-
- TT (mta_H, T_LEAVE; TB (result));
-
- return result;
- }
-
- // *************************************************************************
- sos_Type _sos_Schema_type::base (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Schema_type::base");
- TT (mta_H, T_ENTER);
-
- sos_Type t = sos_Schema_type::make(_tpid,this).make_base_type();
-
- TT (mta_H, T_LEAVE);
-
- return t;
- }
-
- // *************************************************************************
- sos_Bool _sos_Schema_type::is_scalar (sos_Typed_id &_tpid)
- // *************************************************************************
- { T_PROC ("sos_Schema_type::is_scalar")
- TT (mta_H, T_ENTER);
-
- sos_Type bt = sos_Schema_type::make(_tpid,this).base ();
- sos_Bool result = (sos_Bool) (bt.has_type (sos_Extern_type_type) OR
- bt.has_type (sos_Enum_type_type));
-
- TT (mta_H, T_LEAVE; TB (result));
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Schema_type::total_equal (sos_Schema_type x,
- sos_Object o,
- sos_Eq_kind )
- // *************************************************************************
- {
- T_PROC ("sos_Schema_type::total_equal");
- TT (mta_H, T_ENTER);
-
- sos_Bool result;
-
- sos_Type y = sos_Type::make (o);
- sos_Type b1 = x.base ();
- sos_Type b2 = y.base ();
-
- #ifdef ATT
- if (x.operator!= (b1) OR y.operator!= (b2))
- result = b1.equal (b2);
- else
- result = b1.operator==(b2);
- #else
- if (x != b1 OR y != b2)
- result = b1.equal (b2);
- else
- result = b1 == b2;
- #endif
-
- TT (mta_H, T_LEAVE; TB (result));
-
- return result;
- }
-
- // *************************************************************************
- sos_Int _sos_Schema_type::total_hash_value (sos_Schema_type)
- // *************************************************************************
- {
- T_PROC ("sos_Schema_type::total_hash_value");
- TT (mta_H, T_ENTER);
-
- sos_Int result = 0;
-
- TT (mta_H, T_LEAVE; TB (result));
-
- return result;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Unidentified_type::make_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Unidentified_type::make_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result = sos_Schema_type::make (NO_OBJECT);
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_String _sos_Unidentified_type::make_type_name (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Unidentified_type::make_type_name");
- TT (mta_H, T_ENTER);
-
- sos_String result = sos_Unidentified_type::make(_tpid,this).get_name();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Expr_List _sos_Type_with_params::create_params (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Type_with_params::create_params");
- TT (mta_H, T_ENTER);
-
- sos_Expr_List result = sos_Type_with_params::make(_tpid,this).get_params();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Type_with_params::make_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Type_with_params::make_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result = sos_Type_with_params::make(_tpid,this).get_type_name().make_type();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_String _sos_Type_with_params::make_type_name (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Type_with_params::make_type_name");
- TT (mta_H, T_ENTER);
-
- sos_String result = sos_Type_with_params::make(_tpid,this).get_type_name().make_type_name();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Generic_instantiation::make_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Generic_instantiation::make_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result = sos_Generic_instantiation::make(_tpid,this).get_instantiation();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_String _sos_Generic_instantiation::make_type_name (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Generic_instantiation::make_type_name");
- TT (mta_H, T_ENTER);
-
- sos_String result = sos_Generic_instantiation::make(_tpid,this).get_instantiation().make_type_name();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Generic_instantiation::is_universal (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Generic_instantiation::is_universal");
- TT (mta_H, T_ENTER);
-
- sos_Class_type gen_t = sos_Generic_instantiation::make(_tpid,this).get_gen();
-
- sos_Type_name_List tnl = sos_Generic_instantiation::make(_tpid,this).get_gen_params();
- sos_Gen_param_List gpl = sos_Class_type::make (gen_t).get_gen_params();
-
- sos_Bool is_universal = TRUE;
- sos_Cursor c1 = tnl.open_cursor ();
- sos_Cursor c2 = gpl.open_cursor ();
- for (sos_Bool valid1 = tnl.is_valid (c1),
- valid2 = gpl.is_valid (c2);
- valid1 AND valid2 AND is_universal;
- valid1 = tnl.to_succ (c1), valid2 = gpl.to_succ (c2))
- { is_universal =
- tnl.get(c1).make_base_type ().equal (gpl.get(c2).make_base_type());
- }
- tnl.close_cursor (c1);
- gpl.close_cursor (c2);
-
-
- TT (mta_H, T_LEAVE);
-
- return is_universal;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Gen_param::make_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Gen_param::make_type");
- TT (mta_H, T_ENTER);
-
- sos_Type_name sc = sos_Gen_param::make(_tpid,this).get_super_class();
- sos_Schema_type result;
- if (sc == NO_OBJECT)
- result = (get_object_type());
- else
- result = sc.make_type ();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_String _sos_Gen_param::make_type_name (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Gen_param::make_type_name");
- TT (mta_H, T_ENTER);
-
- sos_Type_name sc = sos_Gen_param::make(_tpid,this).get_super_class();
- sos_String result;
- if (sc == NO_OBJECT)
- result = (get_object_type().make_type_name());
- else
- result = sc.make_type_name();
-
- TT (mta_H, T_LEAVE);
-
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Method::overloads (sos_Typed_id &_tpid,sos_Method m)
- // *************************************************************************
- // precondition: self.name == m.name
- {
- T_PROC ("sos_Method::overloads");
- TT (mta_H, T_ENTER);
-
- sos_Bool result = (sos_Bool)
- (sos_Method::make(_tpid,this).get_is_static() == m.get_is_static() AND
- sos_Method::make(_tpid,this).get_params().card() != m.get_params().card());
-
- TT (mta_H, T_LEAVE; TB(result));
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Method::redefines (sos_Typed_id &_tpid,sos_Method m)
- // *************************************************************************
- {
- // precondition: self.get_name() == m.get_name()
-
- T_PROC ("sos_Method::redefines");
- TT (mta_H, T_ENTER);
-
- sos_Bool result;
-
- if (sos_Method::make(_tpid,this).get_is_static() != m.get_is_static())
- result = FALSE;
- else
- { sos_Type ts = sos_Method::make(_tpid,this).get_result_type().make_base_type();
- sos_Type tm = m.get_result_type().make_base_type();
-
- if (ts.equal (tm))
- { result = TRUE;
- sos_Param_List pls = sos_Method::make(_tpid,this).get_params();
- sos_Param_List plm = m.get_params();
-
- sos_Int comp = 0;
- agg_iterate_double (pls, sos_Param ps, plm, sos_Param pm, comp)
- { ts = ps.get_type_name().make_base_type();
- tm = pm.get_type_name().make_base_type();
- result = ts.equal (tm);
- if (NOT result) break;
- }
- agg_iterate_double_end (pls, ps, plm, pm, comp);
- result = (sos_Bool)(result AND comp == 0);
- }
- else
- result = FALSE;
- }
-
- TT (mta_H, T_LEAVE; TB(result));
- return result;
- }
-
- // *************************************************************************
- sos_Object _sos_Method::execute (sos_Typed_id &_tpid,sos_Object o, sos_Object_Array p)
- // *************************************************************************
- {
- T_PROC ("sos_Method::is_execute");
- TT (mta_H, T_ENTER);
-
- sos_Object result;
- sos_Method_impl_List impls = sos_Method::make(_tpid,this).get_impls();
- sos_Bool found = FALSE;
- if (impls != NO_OBJECT)
- { agg_iterate (impls, sos_Method_impl impl)
- { if (impl.isa (cci_Method_impl_type))
- { result = cci_Method_impl::make (impl).execute (o, p);
- found = TRUE;
- break;
- }
- }
- agg_iterate_end (impls, impl);
- }
- if (NOT found)
- err_raise (err_SYS, err_MTA_METHOD_NOT_EXECUTABLE,
- sos_Method::make(_tpid,this).get_name().make_Cstring());
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Method _sos_Method_table::lookup (sos_Typed_id &_tpid,sos_Method m)
- // *************************************************************************
- {
- T_PROC ("sos_Method_table::lookup");
- TT (mta_H, T_ENTER);
-
- sos_Method result = sos_Method::make (NO_OBJECT);
- sos_String m_name = m.get_name();
-
- if (sos_Method_table::make(_tpid,this).is_key (m_name))
- { sos_Method_List ml = sos_Method_table::make(_tpid,this)[m_name];
-
- agg_iterate (ml, sos_Method m1)
- { if (NOT m.overloads (m1))
- { result = m1;
- break;
- }
- }
- agg_iterate_end (ml, m1);
- }
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Method _sos_Method_table::lookup_or_add (sos_Typed_id &_tpid,sos_Method m)
- // *************************************************************************
- {
- T_PROC ("sos_Method_table::lookup_or_add");
- TT (mta_H, T_ENTER);
-
- sos_Method result;
- sos_String m_name = m.get_name();
- sos_Method_List ml;
- sos_Bool found = FALSE;
-
- if (sos_Method_table::make(_tpid,this).is_key (m_name))
- { ml = sos_Method_table::make(_tpid,this)[m_name];
-
- agg_iterate (ml, sos_Method m1)
- if (NOT m.overloads (m1))
- { found = TRUE;
- result = m1;
- break;
- }
- agg_iterate_end (ml, m1);
- }
- else
- { ml = sos_Method_List::create (sos_Method_table::make(_tpid,this).container(), FALSE);
- sos_Method_table::make(_tpid,this).insert (m_name, ml);
- }
-
- if (NOT found)
- { ml.append (m);
- result = m;
- }
-
- TT (mta_H, T_LEAVE;TB(found));
- return result;
- }
-
- // *************************************************************************
- sos_Method _sos_Method_table::replace_or_add (sos_Typed_id &_tpid,sos_Method m)
- // *************************************************************************
- {
- T_PROC ("sos_Method_table::replace_or_add");
- TT (mta_H, T_ENTER);
-
- sos_Method result;
- sos_String m_name = m.get_name();
- sos_Method_List ml;
- sos_Bool found = FALSE;
-
- if (sos_Method_table::make(_tpid,this).is_key (m_name))
- { ml = sos_Method_table::make(_tpid,this)[m_name];
-
- sos_Cursor c = ml.open_cursor();
- for (sos_Bool valid = ml.is_valid (c); valid; valid = ml.to_succ (c))
- { sos_Method m1 = ml.get(c);
- if (NOT m.overloads (m1))
- { ml.set (c, m);
- found = TRUE;
- result = m1;
- break;
- }
- }
- ml.close_cursor (c);
- }
- else
- { ml = sos_Method_List::create (sos_Method_table::make(_tpid,this).container(), FALSE);
- sos_Method_table::make(_tpid,this).insert (m_name, ml);
- }
-
- if (NOT found)
- { ml.append (m);
- result = m;
- }
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Comp_method _sos_Method_table::lookup_comp (sos_Typed_id &_tpid,sos_String name,
- sos_Bool is_set)
- // *************************************************************************
- {
- T_PROC ("sos_Method_table::lookup_comp");
- TT (mta_H, T_ENTER);
-
- sos_String mn = sos_String::create(TEMP_CONTAINER);
- if (is_set)
- mn.assign_Cstring ("set_");
- else
- mn.assign_Cstring ("get_");
- mn += name;
-
- sos_Comp_method result = sos_Comp_method::make (NO_OBJECT);
-
- if (sos_Method_table::make(_tpid,this).is_key (mn))
- { sos_Method_List ml = sos_Method_table::make(_tpid,this)[mn];
-
- agg_iterate (ml, sos_Method m)
- if (m.has_type (sos_Comp_method_type))
- { result = sos_Comp_method::make (m);
- break;
- }
- agg_iterate_end (ml, m);
- }
-
- mn.destroy();
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Union_type::local_equal (sos_Union_type,sos_Object,sos_Eq_kind)
- // *************************************************************************
- {
- T_PROC ("sos_Union_type::local_equal");
- TT (mta_H, T_ENTER);
-
- sos_Bool result = TRUE;
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Int _sos_Union_type::local_hash_value (sos_Union_type)
- // *************************************************************************
- {
- T_PROC ("sos_Union_type::local_hash_value");
- TT (mta_H, T_ENTER);
-
- sos_Int result = 0;
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Typedef_type::make_base_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Typedef_type::make_base_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type t = sos_Typedef_type::make(_tpid,this).get_type_name().make_base_type();
-
- TT (mta_H, T_LEAVE);
- return t;
- }
-
- // *************************************************************************
- sos_Bool _sos_Typedef_type::local_equal (sos_Typedef_type,sos_Object,sos_Eq_kind)
- // *************************************************************************
- {
- T_PROC ("sos_Typedef_type::local_equal");
- TT (mta_H, T_ENTER);
-
- sos_Bool result = TRUE;
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Int _sos_Typedef_type::local_hash_value (sos_Typedef_type)
- // *************************************************************************
- {
- T_PROC ("sos_Typedef_type::local_hash_value");
- TT (mta_H, T_ENTER);
-
- sos_Int result = 0;
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Scalar_object _sos_Enum_type::make_object (sos_Typed_id &_tpid,sos_String literal)
- // *************************************************************************
- { T_PROC ("sos_Enum_type::make_object");
- TT (mta_H, T_ENTER);
-
- sos_String_List sl = sos_Enum_type::make(_tpid,this).get_literals();
- sos_Int idx = 0;
- sos_Bool found = FALSE;
-
- agg_iterate (sl, sos_String lit)
- if (lit.equal (literal))
- { found = TRUE;
- break;
- }
- ++ idx;
- agg_iterate_end (sl, lit);
-
- sos_Scalar_object result = found ? sos_enum_from_sos_Int (idx, sos_Enum_type::make(_tpid,this))
- : sos_Scalar_object::make (NO_OBJECT);
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_String _sos_Enum_type::make_string (sos_Typed_id &_tpid,sos_Scalar_object enum_obj)
- // *************************************************************************
- { T_PROC ("sos_Enum_type::make_string");
- TT (mta_H, T_ENTER);
-
- sos_Int lidx = sos_Int_from_enum (enum_obj, sos_Enum_type::make(_tpid,this)) + 1;
- sos_String_List literals = sos_Enum_type::make(_tpid,this).get_literals();
-
- err_assert (1 <= lidx AND lidx <= literals.card(),
- "sos_Enum_type::make_string : enum out of range");
-
- sos_String result = sos_String::clone (literals.get_nth (lidx),
- TEMP_CONTAINER);
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Enum_type::local_equal (sos_Enum_type,sos_Object,sos_Eq_kind)
- // *************************************************************************
- { T_PROC ("sos_Enum_type::local_equal");
- TT (mta_H, T_ENTER);
-
- sos_Bool result = TRUE;
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Int _sos_Enum_type::local_hash_value (sos_Enum_type)
- // *************************************************************************
- {
- T_PROC ("sos_Enum_type::local_hash_value");
- TT (mta_H, T_ENTER);
-
- sos_Int result = 0;
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Forward_class_type::make_base_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Forward_class_type::make_base_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type t = sos_Forward_class_type::make(_tpid,this).get_complete();
- if (t == NO_OBJECT) t = sos_Forward_class_type::make(_tpid,this);
-
- TT (mta_H, T_LEAVE);
- return t;
- }
-
- // *************************************************************************
- sos_Bool _sos_Forward_class_type::local_equal (sos_Forward_class_type,sos_Object,sos_Eq_kind)
- // *************************************************************************
- {
- T_PROC ("sos_Forward_class_type::local_equal");
- TT (mta_H, T_ENTER);
-
- sos_Bool result = TRUE;
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Int _sos_Forward_class_type::local_hash_value (sos_Forward_class_type)
- // *************************************************************************
- {
- T_PROC ("sos_Forward_class_type::local_hash_value");
- TT (mta_H, T_ENTER);
-
- sos_Int result = 0;
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Class_type _sos_Class_type::root_class (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Class_type::root_class");
- TT (mta_H, T_ENTER);
-
- sos_Class_type ct;
-
- sos_Generic_instantiation gi = sos_Class_type::make(_tpid,this).get_generated_from();
- if (gi != NO_OBJECT)
- ct = gi.get_gen();
- else
- ct = sos_Class_type::make(_tpid,this);
-
- TT (mta_H, T_LEAVE);
- return ct;
- }
-
- // *************************************************************************
- sos_Bool _sos_Class_type::is_derived_from (sos_Typed_id &_tpid,sos_Type tp)
- // *************************************************************************
- {
- T_PROC ("sos_Class_type::is_derived_from");
- TT (mta_H, T_ENTER);
-
- sos_Bool result = FALSE;
-
- if (sos_Class_type::make(_tpid,this).equal (tp) OR tp.equal (get_object_type()))
- result = TRUE;
- else
- { sos_Super_class_List scl = sos_Class_type::make(_tpid,this).get_super_closure();
-
- agg_iterate (scl, sos_Super_class sc)
- if (sc.get_super_class().equal (tp))
- { result = TRUE;
- break;
- }
- agg_iterate_end (scl, sc);
- }
-
- TT (mta_H, T_LEAVE; TB (result));
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Class_type::is_derived_from_some (sos_Typed_id &_tpid,sos_Type tp)
- // *************************************************************************
- {
- T_PROC ("sos_Class_type::is_derived_from_some");
- TT (mta_H, T_ENTER);
-
- sos_Bool result = FALSE;
-
- if (sos_Class_type::make(_tpid,this).equal (tp) OR tp.equal (get_object_type()))
- result = TRUE;
- else
- { sos_Super_class_List scl = sos_Class_type::make(_tpid,this).get_super_closure();
-
- agg_iterate (scl, sos_Super_class sc)
- if (sc.get_super_class().root_class().equal (tp))
- { result = TRUE;
- break;
- }
- agg_iterate_end (scl, sc);
- }
-
- TT (mta_H, T_LEAVE; TB (result));
- return result;
- }
-
- // *************************************************************************
- sos_Type _sos_Class_type::root (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Class_type::root");
- TT (mta_M, T_ENTER);
-
- sos_Type t = sos_Class_type::make(_tpid,this).root_class();
-
- TT (mta_M, T_LEAVE);
- return t;
- }
-
- // *************************************************************************
- sos_Schema_type _sos_Class_type::make_root_type (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Class_type::make_root_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type t = sos_Class_type::make(_tpid,this).root_class();
-
- TT (mta_H, T_LEAVE);
- return t;
- }
-
- // *************************************************************************
- sos_String _sos_Class_type::make_type_name (sos_Typed_id &_tpid)
- // *************************************************************************
- {
- T_PROC ("sos_Class_type::make_type_name");
- TT (mta_H, T_ENTER);
-
- sos_String result = sos_Class_type::make(_tpid,this).get_root_name();
-
- if (result == NO_OBJECT)
- result = sos_Class_type::make(_tpid,this).get_name();
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- static sos_Schema_type *the_object_type;
-
- // *************************************************************************
- static sos_Schema_type get_object_type()
- // *************************************************************************
- {
- T_PROC ("get_object_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result;
- if (the_object_type)
- result = *the_object_type;
- else
- {
- #ifdef BOOT
- sos_Schema_module knl =
- sos_Schema_module::lookup (smg_String ("knl").make_String (TEMP_CONTAINER));
- result = knl.lookup_type (smg_String ("sos_Object").make_String (TEMP_CONTAINER));
- #else
- result = sos_Schema_type::make (sos_Object_type);
- #endif
- the_object_type = new sos_Schema_type;
- *the_object_type = result;
- }
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- static sos_Schema_type *the_scalar_object_type;
-
- // *************************************************************************
- static sos_Schema_type get_scalar_object_type()
- // *************************************************************************
- {
- T_PROC ("get_scalar_object_type");
- TT (mta_H, T_ENTER);
-
- sos_Schema_type result;
- if (the_scalar_object_type)
- result = *the_scalar_object_type;
- else
- {
- #ifdef BOOT
- sos_Schema_module knl =
- sos_Schema_module::lookup (smg_String ("knl").make_String (TEMP_CONTAINER));
- result = knl.lookup_type (smg_String ("sos_Scalar_object").make_String (TEMP_CONTAINER));
- #else
- result = sos_Schema_type::make (sos_Scalar_object_type);
- #endif
- the_scalar_object_type = new sos_Schema_type;
- *the_scalar_object_type = result;
- }
-
- TT (mta_H, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Bool _sos_Class_type::local_equal (sos_Class_type,sos_Object,sos_Eq_kind)
- // *************************************************************************
- {
- T_PROC ("sos_Class_type::local_equal");
- TT (mta_M, T_ENTER);
-
- sos_Bool result = TRUE;
-
- TT (mta_M, T_LEAVE);
- return result;
- }
-
- // *************************************************************************
- sos_Int _sos_Class_type::local_hash_value (sos_Class_type)
- // *************************************************************************
- {
- T_PROC ("sos_Class_type::local_hash_value");
- TT (mta_M, T_ENTER);
-
- sos_Int result = 0;
-
- TT (mta_M, T_LEAVE);
- return result;
- }
-