7 typedef Ref<Class> ClassRef;
9 extern list<ClassRef> classes;
11 class Class : public NameSpace {
12 list<InterfaceRef> ifaces;
15 struct ParamInfo : public RefCountable<ParamInfo> {
19 typedef Ref<ParamInfo> ParamInfoRef;
22 // C++ associative arrays are much more of a
23 // pain to use than they should be.
25 typedef map<ParamRef, ParamInfoRef> params_map_type;
26 typedef params_map_type::value_type params_valtype;
27 typedef params_map_type::const_iterator params_iter;
30 struct MethodInfo : public RefCountable<MethodInfo> {
32 bool copy_params; // True if at least one parameter
33 // has the copy attribute.
36 params_map_type params;
39 ParamInfo *get_param(Param *p)
41 params_iter ret = params.find(p);
43 if (ret != params.end())
49 ParamInfo *add_param(Param *p)
51 ParamInfo *pi = get_param(p);
57 pair<params_iter, bool> ret =
58 params.insert(params_valtype(p, pi));
67 typedef Ref<MethodInfo> MethodInfoRef;
70 typedef map<MethodRef, MethodInfoRef> method_map_type;
71 typedef method_map_type::value_type methods_valtype;
72 typedef method_map_type::const_iterator methods_iter;
74 method_map_type methods;
77 InterfaceRef concrete_iface;
79 Class(const String *name) :
80 Symbol(name), concrete_iface(new Interface(new String("<anon>")))
82 classes.push_back(this);
85 void add_iface(Interface *iface)
87 ifaces.push_back(iface);
88 concrete_iface->add_super(iface);
91 MethodInfo *get_method(Method *m)
93 methods_iter ret = methods.find(m);
95 if (ret != methods.end())
101 MethodInfo *add_method(Method *m)
103 MethodInfo *mi = get_method(m);
107 mi->copy_params = false;
109 pair<methods_iter, bool> ret =
110 methods.insert(methods_valtype(m, mi));
118 typedef list<InterfaceRef>::const_iterator ifaces_iterator;
120 ifaces_iterator ifaces_begin()
122 return ifaces.begin();
125 ifaces_iterator ifaces_end()
130 // FIXME: check for duplicate method implementation names.
133 concrete_iface->finalize_class_iface();