added flag variadicity to type method
authorSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Tue, 14 Jan 2003 16:08:52 +0000 (16:08 +0000)
committerSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Tue, 14 Jan 2003 16:08:52 +0000 (16:08 +0000)
[r623]

ir/tr/type.c
ir/tr/type.h
ir/tr/type_t.h

index c47c130..d64113f 100644 (file)
@@ -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);
index 57249e3..9d56759 100644 (file)
@@ -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);
 
index c9e435e..b8ae15f 100644 (file)
@@ -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 {