X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftr%2Ftype.c;h=720c37bb2b3d68ac9f754870823319d1e367a28f;hb=16eb5aad86dbc0ff0d4bf0c59bd2ad15109b29ff;hp=c47c130109fd4cd3c63e5d83703d3602451f7902;hpb=df83e37827032795585d3b25776c465870672901;p=libfirm diff --git a/ir/tr/type.c b/ir/tr/type.c index c47c13010..720c37bb2 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -204,7 +204,6 @@ set_type_state(type *tp, type_state state) { assert(get_entity_offset(get_class_member(tp, i)) > -1); assert(is_method_type(get_entity_type(get_class_member(tp, i))) || (get_entity_allocation(get_class_member(tp, i)) == automatic_allocated)); - /* @@@ lowerfirm geht nicht durch */ } } break; case tpo_struct: @@ -250,6 +249,16 @@ void mark_type_visited(type *tp) { assert(tp->visit < type_visited); tp->visit = type_visited; } +/* @@@ name clash with master flag +bool type_visited(type *tp) { + assert(tp && tp->kind == k_type); + return tp->visit >= type_visited; + }*/ +bool type_not_visited(type *tp) { + assert(tp && tp->kind == k_type); + return tp->visit < type_visited; +} + int is_type (void *thing) { assert(thing); @@ -337,6 +346,7 @@ bool equal_type(type *typ1, type *typ2) { } } break; case tpo_method: { + if (get_method_variadicity(typ1) != get_method_variadicity(typ2)) return false; if (get_method_n_params(typ1) != get_method_n_params(typ2)) return false; if (get_method_n_ress(typ1) != get_method_n_ress(typ2)) return false; for (i = 0; i < get_method_n_params(typ1); i++) { @@ -368,7 +378,6 @@ bool equal_type(type *typ1, type *typ2) { } } break; case tpo_array: { - type *set, *let; /* small/large elt. type */ if (get_array_n_dimensions(typ1) != get_array_n_dimensions(typ2)) return false; if (!equal_type(get_array_element_type(typ1), get_array_element_type(typ2))) @@ -429,6 +438,7 @@ bool smaller_type (type *st, type *lt) { } } break; case tpo_method: { + if (get_method_variadicity(st) != get_method_variadicity(lt)) return false; if (get_method_n_params(st) != get_method_n_params(lt)) return false; if (get_method_n_ress(st) != get_method_n_ress(lt)) return false; for (i = 0; i < get_method_n_params(st); i++) { @@ -543,6 +553,14 @@ int get_class_n_members (type *clss) { assert(clss && (clss->type_op == type_class)); return (ARR_LEN (clss->attr.ca.members))-1; } +int get_class_member_index(type *clss, entity *mem) { + int i; + assert(clss && (clss->type_op == type_class)); + for (i = 0; i < get_class_n_members(clss); i++) + if (get_class_member(clss, i) == mem) + return i; + return -1; +} entity *get_class_member (type *clss, int pos) { assert(clss && (clss->type_op == type_class)); assert(pos >= 0 && pos < get_class_n_members(clss)); @@ -627,6 +645,15 @@ int get_class_n_supertypes (type *clss) { assert(clss && (clss->type_op == type_class)); return (ARR_LEN (clss->attr.ca.supertypes))-1; } +int get_class_supertype_index(type *clss, type *super_clss) { + int i; + assert(clss && (clss->type_op == type_class)); + assert(super_clss && (super_clss->type_op == type_class)); + for (i = 0; i < get_class_n_supertypes(clss); i++) + if (get_class_supertype(clss, i) == super_clss) + return i; + return -1; +} type *get_class_supertype (type *clss, int pos) { assert(clss && (clss->type_op == type_class)); assert(pos >= 0 && pos < get_class_n_supertypes(clss)); @@ -765,6 +792,7 @@ INLINE type *new_type_method (ident *name, int n_param, int n_res) { res->attr.ma.param_type = (type **) xmalloc (sizeof (type *) * n_param); res->attr.ma.n_res = n_res; res->attr.ma.res_type = (type **) xmalloc (sizeof (type *) * n_res); + res->attr.ma.variadicity = non_variadic; return res; } type *new_d_type_method (ident *name, int n_param, int n_res, dbg_info* db) { @@ -808,6 +836,18 @@ void set_method_res_type(type *method, int pos, type* tp) { method->attr.ma.res_type[pos] = tp; } +variadicity get_method_variadicity(type *method) +{ + assert(method && (method->type_op == type_method)); + return method->attr.ma.variadicity; +} + +void set_method_variadicity(type *method, variadicity vari) +{ + assert(method && (method->type_op == type_method)); + method->attr.ma.variadicity = vari; +} + /* typecheck */ bool is_method_type (type *method) { assert(method);