+/********************************************************************/
+static
+void create_abstract_proc_effect(module_t *module, proc_t *proc)
+{
+ int i, num;
+ ir_type *class_typ = NULL;
+ type_t *type;
+ ir_entity *fent;
+
+ /* find the class of a procedure */
+ VERBOSE_PRINT((stdout, "do find owner id %s\n", get_id_str(proc -> ownerid)));
+ type = find_type_in_module(module, proc -> ownerid);
+ assert(type && "class not found in module");
+
+ class_typ = get_glob_type();
+ VERBOSE_PRINT((stdout, "test type %s\n", get_type_name(class_typ)));
+ if(type -> type_ident != get_type_ident(class_typ)) {
+ /* find module as class */
+ num = get_irp_n_types();
+ for(i = 0; i < num; i++) {
+ class_typ = get_irp_type(i);
+ VERBOSE_PRINT((stdout, "test type %s\n", get_type_name(class_typ)));
+ if (is_Class_type(class_typ)
+ && (type -> type_ident == get_type_ident(class_typ))) {
+ /* found class type */
+ VERBOSE_PRINT((stdout, "found type %s\n", get_type_name(class_typ)));
+ break;
+ }
+ class_typ = NULL;
+ }
+ }
+ else {
+ VERBOSE_PRINT((stdout, "found global type %s\n", get_type_name(class_typ)));
+ }
+ assert(class_typ && "type not found");
+ assert(is_Class_type(class_typ) && "is not a class type");
+ type -> f_tp = class_typ;
+
+ /* find ir_entity for procedure in class */
+ VERBOSE_PRINT((stdout, "find method %s\n",
+ get_id_str(proc -> proc_ident)));
+
+ num = get_class_n_members(class_typ);
+ fent = NULL;
+ for(i = 0; i < num; i++) {
+ fent = get_class_member(class_typ, i);
+ VERBOSE_PRINT((stdout, "test proc %s\n", get_entity_name(fent)));
+ if(proc -> proc_ident == get_entity_ident(fent)) {
+ VERBOSE_PRINT((stdout, "found proc %s\n",
+ get_id_str(proc -> proc_ident)));
+ /* @@@ TODO check args types - not in xml yet */
+ /* create Firm stuff */
+ create_abstract_firm(module, proc, fent);
+ return;
+ }
+ else {
+ fent = NULL;
+ }
+ }
+
+ /* fail */
+ fprintf(stderr,
+ "method %s not found\nNo effects generated\nCandidates are:\n",
+ get_id_str(proc -> proc_ident));
+ for(i = 0; i < num; i++) {
+ fent = get_class_member(class_typ, i);
+ fprintf(stderr, "%s\n", get_entity_name(fent));
+ }
+ //assert(fent && "procedure not found in class");
+}
+
+static
+void create_abstract_module(module_t *module)
+{
+ proc_t *proc;
+ type_t *type;
+ entity_t *ent;
+
+ VERBOSE_PRINT((stdout, "create an abstraction for module %s\n",
+ get_id_str(module -> id)));
+
+ VERBOSE_PRINT((stdout, "--handle types for module\n"));
+ for(type = module -> types; type; type = type -> prev) {
+ assign_firm_type(type);
+ }
+
+ VERBOSE_PRINT((stdout, "--handle entities for module\n"));
+ /* @@@ TODO */
+ for(ent = module -> entities; ent; ent = ent -> prev) {
+ assign_firm_entity(module, ent);
+ }
+
+ VERBOSE_PRINT((stdout, "--handle procs for module\n"));
+ for(proc = module -> procs; proc; proc = proc -> next) {
+ create_abstract_proc_effect(module, proc);
+ }
+}
+
+
+int create_abstraction(const char *filename)
+{
+ module_t *module;
+
+ /* read and parse XML file */
+ if (! read_extern(filename))
+ return 0;
+
+ /* finished reading and parsing here */
+ /* build FIRM graphs */
+ module = modules;
+ while(module) {
+ current_module = module;
+ create_abstract_module(module);
+ module = module -> next;
+ }
+ current_module = NULL;
+
+ /* free data structures */
+ free_data();
+
+ types = NULL;
+ entities = NULL;
+ procs = NULL;
+ modules = NULL;
+
+ return 1;
+}
+
+
+void free_abstraction(void) {
+ int i, n_pseudo_irgs = get_irp_n_pseudo_irgs();
+ for (i = 0; i < n_pseudo_irgs; ++i) {
+ ir_graph *p_irg = get_irp_pseudo_irg(i);
+ set_entity_visibility(get_irg_entity(p_irg), visibility_external_allocated);
+ // @@@ free_pseudo_ir_graph(p_irg);
+ }