- teach the analyzer how to handle inner functions
[libfirm] / ir / tr / type.c
index 869bc79..0984a39 100644 (file)
 
 #include "config.h"
 
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
+#include <string.h>
+#include <stdlib.h>
 #include <stddef.h>
 
 #include "type_t.h"
@@ -1166,7 +1161,7 @@ build_value_type(ident *name, int len, tp_ent_pair *tps) {
 
                /* use the parameter name if specified */
                if (! id)
-                       id = mangle_u(name, get_type_ident(elt_type));
+                       id = id_mangle_u(name, get_type_ident(elt_type));
                tps[i].ent = new_entity(res, id, elt_type);
                set_entity_allocation(tps[i].ent, allocation_parameter);
        }
@@ -1212,7 +1207,7 @@ ir_type *clone_type_method(ir_type *tp, ident *prefix) {
 
        name = tp->name;
        if (prefix != NULL)
-               name = mangle(prefix, name);
+               name = id_mangle(prefix, name);
 
        mode     = tp->mode;
        n_params = tp->attr.ma.n_params;
@@ -1319,7 +1314,7 @@ ir_entity *get_method_value_param_ent(ir_type *method, int pos) {
        if (!method->attr.ma.value_params) {
                /* parameter value type not created yet, build */
                method->attr.ma.value_params
-                       = build_value_type(mangle_u(get_type_ident(method), value_params_suffix),
+                       = build_value_type(id_mangle_u(get_type_ident(method), value_params_suffix),
                        get_method_n_params(method), method->attr.ma.params);
        }
        /*
@@ -1373,7 +1368,7 @@ ir_entity *get_method_value_res_ent(ir_type *method, int pos) {
        if (!method->attr.ma.value_ress) {
                /* result value type not created yet, build */
                method->attr.ma.value_ress
-                       = build_value_type(mangle_u(get_type_ident(method), value_ress_suffix),
+                       = build_value_type(id_mangle_u(get_type_ident(method), value_ress_suffix),
                        get_method_n_ress(method), method->attr.ma.res_type);
        }
        /*
@@ -1603,7 +1598,7 @@ ir_type *new_d_type_array(ident *name, int n_dimensions, ir_type *element_type,
        current_ir_graph = rem;
 
        res->attr.aa.element_type = element_type;
-       new_entity(res, mangle_u(name, new_id_from_chars("elem_ent", 8)), element_type);
+       new_entity(res, id_mangle_u(name, new_id_from_chars("elem_ent", 8)), element_type);
        hook_new_type(res);
        return res;
 }
@@ -1650,8 +1645,8 @@ set_array_bounds_int(ir_type *array, int dimension, int lower_bound, int upper_b
        ir_graph *rem = current_ir_graph;
        current_ir_graph = get_const_code_irg();
        set_array_bounds(array, dimension,
-                 new_Const(mode_Iu, new_tarval_from_long (lower_bound, mode_Iu)),
-                 new_Const(mode_Iu, new_tarval_from_long (upper_bound, mode_Iu )));
+                 new_Const_long(mode_Iu, lower_bound),
+                 new_Const_long(mode_Iu, upper_bound));
        current_ir_graph = rem;
 }
 
@@ -1666,7 +1661,7 @@ void set_array_lower_bound_int(ir_type *array, int dimension, int lower_bound) {
        ir_graph *rem = current_ir_graph;
        current_ir_graph = get_const_code_irg();
        set_array_lower_bound(array, dimension,
-            new_Const(mode_Iu, new_tarval_from_long (lower_bound, mode_Iu)));
+            new_Const_long(mode_Iu, lower_bound));
        current_ir_graph = rem;
 }
 void
@@ -1679,7 +1674,7 @@ void set_array_upper_bound_int(ir_type *array, int dimension, int upper_bound) {
        ir_graph *rem = current_ir_graph;
        current_ir_graph = get_const_code_irg();
        set_array_upper_bound(array, dimension,
-                   new_Const(mode_Iu, new_tarval_from_long (upper_bound, mode_Iu)));
+                   new_Const_long(mode_Iu, upper_bound));
        current_ir_graph = rem;
 }
 
@@ -2067,6 +2062,8 @@ ir_type *clone_frame_type(ir_type *type) {
        int     i, n;
 
        assert(is_frame_type(type));
+       /* the entity link resource should be allocated if this function is called */
+       assert(irp_resources_reserved(irp) & IR_RESOURCE_ENTITY_LINK);
 
        res = new_type_frame(type->name);
        for (i = 0, n = get_class_n_members(type); i < n; ++i) {
@@ -2129,7 +2126,7 @@ ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment, i
        frame_align = get_type_alignment_bytes(frame_type);
        size = (size + frame_align - 1) & ~(frame_align - 1);
 
-       tp = new_type_array(mangle_u(get_type_ident(frame_type), name), 1, a_byte);
+       tp = new_type_array(id_mangle_u(get_type_ident(frame_type), name), 1, a_byte);
        set_array_bounds_int(tp, 0, 0, size);
        set_type_alignment_bytes(tp, alignment);