#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr list_methods[meth_max];
extern cptr slist_methods[meth_max];
extern cptr variable_methods[meth_max];
extern cptr scope_methods[meth_max];
extern cptr iterator_methods[meth_max];
extern cptr stdin_methods[meth_max];
extern cptr strpool_methods[meth_max];

extern cint strpool_str_6;
extern cint object_Undefined;
extern cint strpool_str_78;


cptr namelist_methods[meth_max];

cint namelist_alloc(cint namelist_self, cint namelist_n1, cint namelist_n2){
  cint namelist_result;
  cint t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
  t2 = object_alloc((cint)namelist_self);
  namelist_result = t2;
  ((cptr)namelist_self)[4] /* class_of*/ = strpool_str_78;
  t3 = mem_malloc(40); ((cptr)t3)[0] = slist_methods;
  t4 = slist_alloc((cint)t3, (cint)5);
  t5 = ((cptr)(((cptr)t4)[0]))[7];
  t6 = ((f0)t5)((cint)t4, (cint)namelist_n1); /* Append*/
  t8 = ((cptr)(((cptr)t6)[0]))[7];
  t9 = ((f0)t8)((cint)t6, (cint)namelist_n2); /* Append*/
  ((cptr)namelist_self)[7] /* names*/ = t9;
  t1 = namelist_result;
  goto t1_label;
  t1_label: return t1;
}

cint namelist_reclaim(cint namelist_self){
  cint t11;
  object_Dec_ref(((cptr)namelist_self)[7] /* names*/);
  object_reclaim((cint)namelist_self);
  t11_label: return t11;
}

cint namelist_Call(cint namelist_self){
  cint namelist_i;
  cint t12, t14, t15, t16, t17;
  for (namelist_i = 1; namelist_i <= ((cptr)((cptr)namelist_self)[7] /* names*/)[3] /* len*/; namelist_i++){
    t16 = ((cptr)(((cptr)((cptr)namelist_self)[7] /* names*/)[0]))[62];
    t15 = ((f0)t16)((cint)((cptr)namelist_self)[7] /* names*/, (cint)namelist_i); /* lookup*/
    ((cptr)t15)[1] += 1;
    t17 = (cptr)(((cptr)(((cptr)t15)[0]))[16]); /* Call*/
    ((f0)t17)((cint)t15);
  };t13:;
  object_Dec_ref(namelist_self);
  t12_label: return t12;
}

cint namelist_Declare_as_constant(cint namelist_self, cint namelist_val){
  cint namelist_i;
  cint t18, t20, t21, t22, t23, t24, t25, t26;
  for (namelist_i = 1; namelist_i <= ((cptr)((cptr)namelist_self)[7] /* names*/)[3] /* len*/; namelist_i++){
    t22 = ((cptr)(((cptr)((cptr)namelist_self)[7] /* names*/)[0]))[62];
    t21 = ((f0)t22)((cint)((cptr)namelist_self)[7] /* names*/, (cint)namelist_i); /* lookup*/
    ((cptr)t21)[1] += 1;
    t25 = ((cptr)(((cptr)namelist_val)[0]))[62];
    t24 = ((f0)t25)((cint)namelist_val, (cint)namelist_i); /* lookup*/
    ((cptr)t24)[1] += 1;
    t26 = (cptr)(((cptr)(((cptr)t21)[0]))[24]); /* Declare_as_constant*/
    ((f0)t26)((cint)t21, (cint)t24);
  };t19:;
  object_Dec_ref(namelist_self);
  object_Dec_ref(namelist_val);
  t18_label: return t18;
}

cint namelist_Declare_as_var(cint namelist_self, cint namelist_typ, cint namelist_lno){
  cint namelist_result, namelist_i;
  cint t27, t29, t30, t31, t32;
  for (namelist_i = 1; namelist_i <= ((cptr)((cptr)namelist_self)[7] /* names*/)[3] /* len*/; namelist_i++){
    t29 = ((cptr)(((cptr)((cptr)namelist_self)[7] /* names*/)[0]))[62];
    t30 = ((f0)t29)((cint)((cptr)namelist_self)[7] /* names*/, (cint)namelist_i); /* lookup*/
    ((cptr)namelist_typ)[1] += 1;
    t32 = (cptr)(((cptr)(((cptr)t30)[0]))[27]); /* Declare_as_var*/
    ((f0)t32)((cint)t30, (cint)namelist_typ, (cint)namelist_lno);
  };t28:;
  object_Dec_ref(namelist_typ);
  t27 = namelist_self;
  goto t27_label;
  t27_label: return t27;
}

cint namelist_Get(cint namelist_self){
  cint namelist_i, namelist_nam, namelist_ob;
  cint t33, t35, t36, t37, t38, t39, t40, t41;
  for (namelist_i = 1; namelist_i <= ((cptr)((cptr)namelist_self)[7] /* names*/)[3] /* len*/; namelist_i++){
    t35 = ((cptr)(((cptr)((cptr)namelist_self)[7] /* names*/)[0]))[62];
    t36 = ((f0)t35)((cint)((cptr)namelist_self)[7] /* names*/, (cint)namelist_i); /* lookup*/
    namelist_nam = t36;
    t38 = namelist_i < ((cptr)((cptr)namelist_self)[7] /* names*/)[3] /* len*/;
    if (t38){
      t39 = stdin_get_item();
      namelist_ob = t39;
    }else{
      t40 = stdin_get_rest_of_line();
      namelist_ob = t40;
    };
    t41 = (cptr)(((cptr)(((cptr)namelist_self)[0]))[261]); /* convert_and_assign*/
    ((f0)t41)((cint)namelist_self, (cint)namelist_nam, (cint)namelist_ob);
  };t34:;
  object_Dec_ref(namelist_self);
  t33_label: return t33;
}

cint namelist_convert_and_assign(cint namelist_self, cint namelist_nam, cint namelist_ob){
  cint namelist_num;
  cint t42, t43, t44, t45, t46, t47, t48, t49, t50, t51, t52, t53, t54, t55;
  t43 = ((cptr)namelist_ob)[4] /* class_of*/ != strpool_str_6;
  if (t43){
    ((cptr)namelist_nam)[1] += 1;
    t44 = (cptr)(((cptr)(((cptr)namelist_nam)[0]))[96]); /* OpAssign*/
    ((f0)t44)((cint)namelist_nam, (cint)namelist_ob, (cint)0);
  }else{
    ((cptr)namelist_ob)[1] += 1;
    t45 = ((cptr)(((cptr)namelist_ob)[0]))[87];
    t46 = ((f0)t45)((cint)namelist_ob); /* Mknum*/
    namelist_num = t46;
    t48 = namelist_num == object_Undefined;
    if (t48){
      ((cptr)namelist_nam)[1] += 1;
      t49 = (cptr)(((cptr)(((cptr)namelist_nam)[0]))[96]); /* OpAssign*/
      ((f0)t49)((cint)namelist_nam, (cint)namelist_ob, (cint)0);
    }else{
      ((cptr)namelist_nam)[1] += 1;
      t50 = (cptr)(((cptr)(((cptr)namelist_nam)[0]))[96]); /* OpAssign*/
      ((f0)t50)((cint)namelist_nam, (cint)namelist_num, (cint)0);
      ((cptr)namelist_nam)[1] += 1;
      t51 = ((cptr)(((cptr)namelist_nam)[0]))[38];
      t52 = ((f0)t51)((cint)namelist_nam); /* Eval*/
      namelist_num = t52;
      t54 = namelist_num == object_Undefined;
      if (t54){
        ((cptr)namelist_nam)[1] += 1;
        t55 = (cptr)(((cptr)(((cptr)namelist_nam)[0]))[96]); /* OpAssign*/
        ((f0)t55)((cint)namelist_nam, (cint)namelist_ob, (cint)0);
      }else{
        object_Dec_ref(namelist_ob);
        object_Dec_ref(namelist_num);
      };
    };
  };
  t42_label: return t42;
}

cint namelist_Make_iterator(cint namelist_self, cint namelist_ob){
  cint namelist_result;
  cint t56, t57, t58;
  t57 = mem_malloc(52); ((cptr)t57)[0] = iterator_methods;
  t58 = iterator_alloc((cint)t57, (cint)namelist_self, (cint)namelist_ob);
  t56 = t58;
  goto t56_label;
  t56_label: return t56;
}

cint namelist_Make_name_list(cint namelist_self, cint namelist_ob){
  cint namelist_result;
  cint t59, t60, t61, t62;
  t60 = ((cptr)(((cptr)((cptr)namelist_self)[7] /* names*/)[0]))[7];
  t61 = ((f0)t60)((cint)((cptr)namelist_self)[7] /* names*/, (cint)namelist_ob); /* Append*/
  ((cptr)namelist_self)[7] /* names*/ = t61;
  t59 = namelist_self;
  goto t59_label;
  t59_label: return t59;
}

cint namelist_OpAssign(cint namelist_self, cint namelist_expr, cint namelist_op){
  cint namelist_i, namelist_n, namelist_v;
  cint t63, t65, t66, t67, t68, t69, t70, t71;
  for (namelist_i = 1; namelist_i <= ((cptr)((cptr)namelist_self)[7] /* names*/)[3] /* len*/; namelist_i++){
    t67 = ((cptr)(((cptr)((cptr)namelist_self)[7] /* names*/)[0]))[62];
    t66 = ((f0)t67)((cint)((cptr)namelist_self)[7] /* names*/, (cint)namelist_i); /* lookup*/
    ((cptr)t66)[1] += 1;
    namelist_n = t66;
    t70 = ((cptr)(((cptr)namelist_expr)[0]))[62];
    t69 = ((f0)t70)((cint)namelist_expr, (cint)namelist_i); /* lookup*/
    ((cptr)t69)[1] += 1;
    namelist_v = t69;
    t71 = (cptr)(((cptr)(((cptr)namelist_n)[0]))[96]); /* OpAssign*/
    ((f0)t71)((cint)namelist_n, (cint)namelist_v, (cint)namelist_op);
  };t64:;
  object_Dec_ref(namelist_self);
  object_Dec_ref(namelist_expr);
  t63_label: return t63;
}

void init_namelist(){
  copy_meth_table(namelist_methods, object_methods);
  namelist_methods[0] = 32;
  namelist_methods[3] = namelist_alloc;
  namelist_methods[4] = namelist_reclaim;
  namelist_methods[16] = namelist_Call;
  namelist_methods[24] = namelist_Declare_as_constant;
  namelist_methods[27] = namelist_Declare_as_var;
  namelist_methods[45] = namelist_Get;
  namelist_methods[261] = namelist_convert_and_assign;
  namelist_methods[67] = namelist_Make_iterator;
  namelist_methods[69] = namelist_Make_name_list;
  namelist_methods[96] = namelist_OpAssign;
}
