#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr boolean_methods[meth_max];
#include "cint.h"
extern cptr iterator_methods[meth_max];
extern cptr slist_methods[meth_max];
extern cptr sset_methods[meth_max];
extern cptr strpool_methods[meth_max];

extern cint boolean_True;
extern cint strpool_str_75;


cptr filter_methods[meth_max];

cint filter_alloc(cint filter_self, cint filter_s, cint filter_fe){
  cint filter_result;
  cint t1, t2;
  t2 = object_alloc((cint)filter_self);
  filter_result = t2;
  ((cptr)filter_self)[4] /* class_of*/ = strpool_str_75;
  ((cptr)filter_self)[7] /* source*/ = filter_s;
  ((cptr)filter_self)[8] /* filtexp*/ = filter_fe;
  t1 = filter_result;
  goto t1_label;
  t1_label: return t1;
}

cint filter_reclaim(cint filter_self){
  cint t3;
  object_Dec_ref(((cptr)filter_self)[7] /* source*/);
  object_Dec_ref(((cptr)filter_self)[8] /* filtexp*/);
  object_reclaim((cint)filter_self);
  t3_label: return t3;
}

cint filter_eval_target(cint filter_self){
  cint filter_result;
  cint t4, t5, t6, t7;
  t5 = ((cptr)(((cptr)((cptr)filter_self)[7] /* source*/)[0]))[40];
  t6 = ((f0)t5)((cint)((cptr)filter_self)[7] /* source*/); /* eval_target*/
  t4 = t6;
  goto t4_label;
  t4_label: return t4;
}

cint filter_iterate(cint filter_self){
  cint filter_result;
  cint t8, t11, t12, t13, t14, t15, t16;
  t9:
    t11 = ((cptr)(((cptr)((cptr)filter_self)[7] /* source*/)[0]))[55];
    t12 = ((f0)t11)((cint)((cptr)filter_self)[7] /* source*/); /* iterate*/
    t13 = t12 == 0;
    if (t13){
      t8 = 0;
      goto t8_label;
    };
    ((cptr)((cptr)filter_self)[8] /* filtexp*/)[1] += 1;
    t14 = ((cptr)(((cptr)((cptr)filter_self)[8] /* filtexp*/)[0]))[38];
    t15 = ((f0)t14)((cint)((cptr)filter_self)[8] /* filtexp*/); /* Eval*/
    t16 = t15 == boolean_True;
    if (t16){
      t8 = 1;
      goto t8_label;
    };
  goto t9;
  t10:;
  t8 = filter_result;
  goto t8_label;
  t8_label: return t8;
}

cint filter_Make_list(cint filter_self){
  cint filter_result;
  cint t17, t18, t19, t20, t21, t24, t25, t26, t27, t28, t29, t30, t31, t32;
  t18 = mem_malloc(40); ((cptr)t18)[0] = slist_methods;
  t19 = slist_alloc((cint)t18, (cint)0);
  filter_result = t19;
  t22:
  t24 = ((cptr)(((cptr)filter_self)[0]))[55];
  t25 = ((f0)t24)((cint)filter_self); /* iterate*/
  t26 = t25 != 0;
  if (!t26) goto t23;
    t27 = ((cptr)(((cptr)((cptr)filter_self)[7] /* source*/)[0]))[40];
    t28 = ((f0)t27)((cint)((cptr)filter_self)[7] /* source*/); /* eval_target*/
    t29 = ((cptr)(((cptr)filter_result)[0]))[7];
    t30 = ((f0)t29)((cint)filter_result, (cint)t28); /* Append*/
    filter_result = t30;
  goto t22;
  t23:;
  object_Dec_ref(filter_self);
  t17 = filter_result;
  goto t17_label;
  t17_label: return t17;
}

cint filter_Make_set(cint filter_self){
  cint filter_result;
  cint t33, t34, t35, t36, t37, t40, t41, t42, t43, t44, t45, t46, t47, t48;
  t34 = mem_malloc(48); ((cptr)t34)[0] = sset_methods;
  t35 = sset_alloc((cint)t34);
  filter_result = t35;
  t38:
  t40 = ((cptr)(((cptr)filter_self)[0]))[55];
  t41 = ((f0)t40)((cint)filter_self); /* iterate*/
  t42 = t41 != 0;
  if (!t42) goto t39;
    t43 = ((cptr)(((cptr)((cptr)filter_self)[7] /* source*/)[0]))[40];
    t44 = ((f0)t43)((cint)((cptr)filter_self)[7] /* source*/); /* eval_target*/
    t45 = ((cptr)(((cptr)filter_result)[0]))[7];
    t46 = ((f0)t45)((cint)filter_result, (cint)t44); /* Append*/
    filter_result = t46;
  goto t38;
  t39:;
  object_Dec_ref(filter_self);
  t33 = filter_result;
  goto t33_label;
  t33_label: return t33;
}

void init_filter(){
  copy_meth_table(filter_methods, object_methods);
  filter_methods[0] = 36;
  filter_methods[3] = filter_alloc;
  filter_methods[4] = filter_reclaim;
  filter_methods[40] = filter_eval_target;
  filter_methods[55] = filter_iterate;
  filter_methods[68] = filter_Make_list;
  filter_methods[74] = filter_Make_set;
}
