From 1e1e5373de456d6ef02d2b397767ebbf881f1a80 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Mon, 14 Mar 2005 14:38:06 +0000 Subject: [PATCH] find_array_dimension() added some doxygen docu added [r5379] --- ir/tr/type.c | 22 +++++++++++++++++----- ir/tr/type.h | 12 ++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ir/tr/type.c b/ir/tr/type.c index ba28b7754..b91392594 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -1338,8 +1338,7 @@ int (is_Union_type)(const type *uni) { /* create a new type array -- set dimension sizes independently */ -type *new_type_array (ident *name, int n_dimensions, - type *element_type) { +type *new_type_array(ident *name, int n_dimensions, type *element_type) { type *res; int i; ir_graph *rem = current_ir_graph; @@ -1353,9 +1352,9 @@ type *new_type_array (ident *name, int n_dimensions, current_ir_graph = get_const_code_irg(); for (i = 0; i < n_dimensions; i++) { - res->attr.aa.lower_bound[i] = new_Unknown(mode_Iu); - res->attr.aa.upper_bound[i] = new_Unknown(mode_Iu); - res->attr.aa.order[i] = i; + res->attr.aa.lower_bound[i] = new_Unknown(mode_Iu); + res->attr.aa.upper_bound[i] = new_Unknown(mode_Iu); + res->attr.aa.order[i] = i; } current_ir_graph = rem; @@ -1469,11 +1468,24 @@ void set_array_order (type *array, int dimension, int order) { assert(array && (array->type_op == type_array)); array->attr.aa.order[dimension] = order; } + int get_array_order (const type *array, int dimension) { assert(array && (array->type_op == type_array)); return array->attr.aa.order[dimension]; } +int find_array_dimension(const type *array, int order) { + int dim; + + assert(array && (array->type_op == type_array)); + + for (dim = 0; dim < array->attr.aa.n_dimensions; ++dim) { + if (array->attr.aa.order[dim] == order) + return dim; + } + return -1; +} + void set_array_element_type (type *array, type *tp) { assert(array && (array->type_op == type_array)); assert(!is_Method_type(tp)); diff --git a/ir/tr/type.h b/ir/tr/type.h index 16c1713a0..ce5e1ed16 100644 --- a/ir/tr/type.h +++ b/ir/tr/type.h @@ -792,13 +792,25 @@ ir_node * get_array_upper_bound (const type *array, int dimension); /** Works only if bound is Const node with tarval that can be converted to long. */ long get_array_upper_bound_int (const type *array, int dimension); +/** Sets an array dimension to a specific order. */ void set_array_order (type *array, int dimension, int order); + +/** Returns the order of an array dimension. */ int get_array_order (const type *array, int dimension); +/** Find the array dimension that is placed at order ord. */ +int find_array_dimension(const type *array, int order); + +/** Sets the array element type. */ void set_array_element_type (type *array, type *tp); + +/** Gets the array element type. */ type *get_array_element_type (type *array); +/** Sets the array element entity. */ void set_array_element_entity (type *array, entity *ent); + +/** Get the array element entity. */ entity *get_array_element_entity (const type *array); /** Returns true if a type is an array type. */ -- 2.20.1