From 2ab371d0cfdbf0a79d1b5db62ed2bf44dec3ca66 Mon Sep 17 00:00:00 2001 From: Sebastian Hack Date: Tue, 14 Jan 2003 16:08:52 +0000 Subject: [PATCH] added flag variadicity to type method [r623] --- ir/tr/type.c | 15 +++++++++++++++ ir/tr/type.h | 13 +++++++++++++ ir/tr/type_t.h | 1 + 3 files changed, 29 insertions(+) diff --git a/ir/tr/type.c b/ir/tr/type.c index c47c13010..d64113fc3 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -337,6 +337,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++) { @@ -429,6 +430,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++) { @@ -765,6 +767,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 +811,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); diff --git a/ir/tr/type.h b/ir/tr/type.h index 57249e3a1..9d5675981 100644 --- a/ir/tr/type.h +++ b/ir/tr/type.h @@ -425,6 +425,19 @@ int get_method_n_ress (type *method); type *get_method_res_type(type *method, int pos); void set_method_res_type(type *method, int pos, type* tp); +/* + * this enum flags the variadicity of methods (methods with a + * variable amount of arguments (e.g. C's printf). Default is + * non_variadic. + */ +typedef enum variadicity { + non_variadic, + variadic +} variadicity; + +variadicity get_method_variadicity(type *method); +void set_method_variadicity(type *method, variadicity vari); + /* typecheck */ bool is_method_type (type *method); diff --git a/ir/tr/type_t.h b/ir/tr/type_t.h index c9e435e6b..b8ae15fc4 100644 --- a/ir/tr/type_t.h +++ b/ir/tr/type_t.h @@ -37,6 +37,7 @@ typedef struct { methods? */ int n_res; /* number of results */ type **res_type; /* array with result types */ + variadicity variadicity; /* variadicity of the method */ } mtd_attr; typedef struct { -- 2.20.1