+ /* ignore methods: these of course reference it's address */
+ if (is_Method_type(tp))
+ return;
+
+ /* let's check if it's the address of a function */
+ n = get_atomic_ent_value(ent);
+ if (get_irn_op(n) == op_SymConst) {
+ if (get_SymConst_kind(n) == symconst_addr_ent) {
+ ent = get_SymConst_entity(n);
+
+ if (is_Method_type(get_entity_type(ent)))
+ eset_insert(set, ent);
+ }
+ }
+ }
+ else {
+ for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i) {
+ n = get_compound_ent_value(ent, i);
+
+ /* let's check if it's the address of a function */
+ if (get_irn_op(n) == op_SymConst) {
+ if (get_SymConst_kind(n) == symconst_addr_ent) {
+ entity *ent = get_SymConst_entity(n);
+
+ if (is_Method_type(get_entity_type(ent)))
+ eset_insert(set, ent);
+ }
+ }
+ }
+ }
+}
+
+/**
+ * returns a list of 'free' methods, i.e., the methods that can be called
+ * from external or via function pointers.
+ *
+ * Die Datenstrukturen für sel-Methoden (sel_methods) muß vor dem
+ * Aufruf von "get_free_methods" aufgebaut sein. Die (internen)
+ * SymConst(name)-Operationen müssen in passende SymConst(ent)-Operationen
+ * umgewandelt worden sein, d.h. SymConst-Operationen verweisen immer
+ * auf eine echt externe Methode.
+ */
+static entity ** get_free_methods(void)
+{
+ eset *free_set = eset_create();
+ int i;
+ entity **arr = NEW_ARR_F(entity *, 0);
+ entity *ent;
+ ir_graph *irg;
+ ir_type *glob;
+
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ irg = get_irp_irg(i);
+ ent = get_irg_entity(irg);
+ /* insert "external visible" methods. */
+ if (get_entity_visibility(ent) != visibility_local) {
+ eset_insert(free_set, ent);
+ }
+ /* Finde alle Methoden die in dieser Methode extern sichtbar werden,
+ z.B. da die Adresse einer Methode abgespeichert wird. */
+ irg_walk_graph(irg, NULL, free_ana_walker, free_set);
+ }
+
+ /* insert sticky methods, too */
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ ent = get_irg_entity(get_irp_irg(i));
+ /* insert "sticky" methods. */
+ if (get_entity_stickyness (ent) == stickyness_sticky) {
+ eset_insert(free_set, ent);
+ }
+ }
+
+ /* insert all methods the initializes global variables */
+ glob = get_glob_type();
+ for (i = get_class_n_members(glob) - 1; i >= 0; --i) {
+ ent = get_class_member(glob, i);
+
+ add_method_address(ent, free_set);
+ }
+
+ /* the main program is even then "free", if it's not external visible. */
+ irg = get_irp_main_irg();
+ if (irg)
+ eset_insert(free_set, get_irg_entity(irg));
+
+ /* Finally, transform the set into an array. */
+ for (ent = eset_first(free_set); ent; ent = eset_next(free_set)) {
+ ARR_APP1(entity *, arr, ent);
+ }
+ eset_destroy(free_set);
+
+ return arr;
+}
+
+/*--------------------------------------------------------------------------*/
+/* Callee analysis. */
+/*--------------------------------------------------------------------------*/
+
+static void callee_ana_node(ir_node * node, eset * methods);