#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr strpool_methods[meth_max];

extern cint strpool_str_4;
extern cint strpool_str_17;
extern cint strpool_str_18;

cint boolean_False;
cint boolean_True;

cptr boolean_methods[meth_max];

cint boolean_init(){
  cint t1, t2, t3, t4, t5;
  t2 = mem_malloc(28); ((cptr)t2)[0] = boolean_methods;
  t3 = boolean_alloc((cint)t2);
  boolean_False = t3;
  t4 = mem_malloc(28); ((cptr)t4)[0] = boolean_methods;
  t5 = boolean_alloc((cint)t4);
  boolean_True = t5;
  t1_label: return t1;
}

cint boolean_fini(){
  cint t6, t7, t8;
  t7 = (cptr)(((cptr)(((cptr)boolean_False)[0]))[4]); /* reclaim*/
  ((f0)t7)((cint)boolean_False);
  t8 = (cptr)(((cptr)(((cptr)boolean_True)[0]))[4]); /* reclaim*/
  ((f0)t8)((cint)boolean_True);
  t6_label: return t6;
}

cint boolean_alloc(cint boolean_self){
  cint boolean_result;
  cint t9, t10;
  t10 = object_alloc((cint)boolean_self);
  boolean_result = t10;
  ((cptr)boolean_self)[4] /* class_of*/ = strpool_str_4;
  t9 = boolean_result;
  goto t9_label;
  t9_label: return t9;
}

cint boolean_reclaim(cint boolean_self){
  cint t11;
  object_reclaim((cint)boolean_self);
  t11_label: return t11;
}

cint boolean_Mkstr(cint boolean_self){
  cint boolean_result;
  cint t12, t13, t14, t15;
  t13 = boolean_self == boolean_True;
  if (t13){
    ((cptr)strpool_str_17)[1] += 1;
    t12 = strpool_str_17;
    goto t12_label;
  };
  t14 = boolean_self == boolean_False;
  if (t14){
    ((cptr)strpool_str_18)[1] += 1;
    t12 = strpool_str_18;
    goto t12_label;
  };
  t15 = object_Mkstr((cint)boolean_self);
  t12 = t15;
  goto t12_label;
  t12_label: return t12;
}

cint boolean_Not(cint boolean_self){
  cint boolean_result;
  cint t16, t17;
  t17 = boolean_self == boolean_False;
  if (t17){
    t16 = boolean_True;
    goto t16_label;
  };
  t16 = boolean_False;
  goto t16_label;
  t16_label: return t16;
}

void init_boolean(){
  copy_meth_table(boolean_methods, object_methods);
  boolean_methods[0] = 28;
  boolean_methods[1] = boolean_init;
  boolean_methods[2] = boolean_fini;
  boolean_methods[3] = boolean_alloc;
  boolean_methods[4] = boolean_reclaim;
  boolean_methods[88] = boolean_Mkstr;
  boolean_methods[95] = boolean_Not;
}
