#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr scope_methods[meth_max];
extern cptr list_methods[meth_max];
extern cptr identifier_methods[meth_max];
extern cptr string_methods[meth_max];
extern cptr function_methods[meth_max];
#include "croutine.h"
extern cptr strpool_methods[meth_max];
extern cptr parameter_methods[meth_max];

extern cint strpool_str_87;


cptr exprfunc_methods[meth_max];

cint exprfunc_alloc(cint exprfunc_self, cint exprfunc_f){
  cint exprfunc_result, exprfunc_b, exprfunc_id;
  cint t1, t2;
  t2 = object_alloc((cint)exprfunc_self);
  exprfunc_result = t2;
  ((cptr)exprfunc_self)[4] /* class_of*/ = strpool_str_87;
  ((cptr)exprfunc_self)[7] /* globvals*/ = 0;
  ((cptr)exprfunc_self)[8] /* fun*/ = exprfunc_f;
  t1 = exprfunc_result;
  goto t1_label;
  t1_label: return t1;
}

cint exprfunc_alloc_new(cint exprfunc_f){
  cint exprfunc_result;
  cint t3, t4, t5;
  t4 = mem_malloc(36); ((cptr)t4)[0] = exprfunc_methods;
  t5 = exprfunc_alloc((cint)t4, (cint)exprfunc_f);
  exprfunc_result = t5;
  t3 = exprfunc_result;
  goto t3_label;
  t3_label: return t3;
}

cint exprfunc_reclaim(cint exprfunc_self){
  cint t6;
  object_Dec_ref(((cptr)exprfunc_self)[7] /* globvals*/);
  object_reclaim((cint)exprfunc_self);
  t6_label: return t6;
}

cint exprfunc_Apply(cint exprfunc_self, cint exprfunc_params){
  cint exprfunc_result;
  cint t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17;
  t8 = exprfunc_params == 0;
  if (t8){
    ((cptr)((cptr)exprfunc_self)[8] /* fun*/)[1] += 1;
    ((cptr)((cptr)exprfunc_self)[7] /* globvals*/)[1] += 1;
    t9 = ((cptr)(((cptr)((cptr)exprfunc_self)[8] /* fun*/)[0]))[9];
    t10 = ((f0)t9)((cint)((cptr)exprfunc_self)[8] /* fun*/, (cint)((cptr)exprfunc_self)[7] /* globvals*/); /* Apply*/
    exprfunc_result = t10;
  }else{
    ((cptr)((cptr)exprfunc_self)[8] /* fun*/)[1] += 1;
    ((cptr)((cptr)exprfunc_self)[7] /* globvals*/)[1] += 1;
    t12 = ((cptr)(((cptr)((cptr)exprfunc_self)[7] /* globvals*/)[0]))[97];
    t13 = ((f0)t12)((cint)((cptr)exprfunc_self)[7] /* globvals*/, (cint)exprfunc_params); /* Plus*/
    t14 = ((cptr)(((cptr)((cptr)exprfunc_self)[8] /* fun*/)[0]))[9];
    t15 = ((f0)t14)((cint)((cptr)exprfunc_self)[8] /* fun*/, (cint)t13); /* Apply*/
    exprfunc_result = t15;
  };
  object_Dec_ref(exprfunc_self);
  t7 = exprfunc_result;
  goto t7_label;
  t7_label: return t7;
}

cint exprfunc_Make_parameter(cint exprfunc_self, cint exprfunc_ob){
  cint exprfunc_result;
  cint t18, t19, t20;
  t19 = mem_malloc(36); ((cptr)t19)[0] = parameter_methods;
  t20 = parameter_alloc((cint)t19, (cint)exprfunc_self, (cint)exprfunc_ob);
  t18 = t20;
  goto t18_label;
  t18_label: return t18;
}

cint exprfunc_Make_parameterless(cint exprfunc_self){
  cint exprfunc_result;
  cint t21, t22, t23;
  t22 = mem_malloc(36); ((cptr)t22)[0] = parameter_methods;
  t23 = parameter_alloc((cint)t22, (cint)exprfunc_self, (cint)0);
  t21 = t23;
  goto t21_label;
  t21_label: return t21;
}

cint exprfunc_Mkstr(cint exprfunc_self){
  cint exprfunc_result;
  cint t24, t25, t26, t27;
  ((cptr)((cptr)exprfunc_self)[8] /* fun*/)[1] += 1;
  t25 = ((cptr)(((cptr)((cptr)exprfunc_self)[8] /* fun*/)[0]))[88];
  t26 = ((f0)t25)((cint)((cptr)exprfunc_self)[8] /* fun*/); /* Mkstr*/
  t24 = t26;
  goto t24_label;
  t24_label: return t24;
}

cint exprfunc_Save_free_vars(cint exprfunc_self, cint exprfunc_fv){
  cint t28;
  ((cptr)exprfunc_self)[7] /* globvals*/ = exprfunc_fv;
  object_Dec_ref(exprfunc_self);
  t28_label: return t28;
}

void init_exprfunc(){
  copy_meth_table(exprfunc_methods, object_methods);
  exprfunc_methods[0] = 36;
  exprfunc_methods[3] = exprfunc_alloc;
  exprfunc_methods[119] = exprfunc_alloc_new;
  exprfunc_methods[4] = exprfunc_reclaim;
  exprfunc_methods[9] = exprfunc_Apply;
  exprfunc_methods[77] = exprfunc_Make_parameter;
  exprfunc_methods[78] = exprfunc_Make_parameterless;
  exprfunc_methods[88] = exprfunc_Mkstr;
  exprfunc_methods[100] = exprfunc_Save_free_vars;
}
