#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
#include "cint.h"
#include "cprocess.h"
extern cptr integer_methods[meth_max];
extern cptr string_methods[meth_max];
extern cptr stdout_methods[meth_max];
extern cptr strpool_methods[meth_max];
#include "cstring.h"
#include "cfile.h"
extern cptr clib_methods[meth_max];
extern cptr slist_methods[meth_max];
extern cptr procedure_methods[meth_max];

extern cint object_Undefined;
extern cint strpool_str_13;
extern cint strpool_str_14;
extern cint strpool_str_15;
extern cint clib_stdo;

cint debug_Curr_col;
cint debug_Curr_module;
cint debug_High_level_message;
cint debug_Curr_line;

cptr debug_methods[meth_max];

cint debug_init(){
  cint t1;
  debug_High_level_message = object_Undefined;
  t1_label: return t1;
}

cint debug_interact(){
  cint t2;
  cprocess_exitt((cint)1);
  t2_label: return t2;
}

cint debug_message(cint debug_s){
  cint t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13;
  t4 = debug_High_level_message == object_Undefined;
  if (t4){
    cfile_fprintf((cint)clib_stdo, (cint)debug_Curr_module);
    ((cptr)strpool_str_13)[1] += 1;
    stdout_Put((cint)strpool_str_13);
    t5 = mem_malloc(28); ((cptr)t5)[0] = integer_methods;
    t6 = integer_ialloc((cint)t5, (cint)debug_Curr_line);
    stdout_Put((cint)t6);
    ((cptr)strpool_str_14)[1] += 1;
    stdout_Put((cint)strpool_str_14);
    t7 = mem_malloc(28); ((cptr)t7)[0] = integer_methods;
    t8 = integer_ialloc((cint)t7, (cint)debug_Curr_col);
    stdout_Put((cint)t8);
    ((cptr)strpool_str_15)[1] += 1;
    stdout_Put((cint)strpool_str_15);
    stdout_Put_space();
    stdout_Put((cint)debug_s);
    stdout_Put_eol();
  }else{
    ((cptr)debug_High_level_message)[1] += 1;
    t9 = mem_malloc(40); ((cptr)t9)[0] = slist_methods;
    t10 = slist_alloc((cint)t9, (cint)1);
    ((cptr)t10)[1] += 1;
    ((cptr)debug_s)[1] += 1;
    t11 = ((cptr)(((cptr)t10)[0]))[7];
    t12 = ((f0)t11)((cint)t10, (cint)debug_s); /* Append*/
    t13 = (cptr)(((cptr)(((cptr)debug_High_level_message)[0]))[18]); /* Call_with_params*/
    ((f0)t13)((cint)debug_High_level_message, (cint)t12);
  };
  t3_label: return t3;
}

cint debug_get_module(){
  cint debug_result;
  cint t14;
  t14 = debug_Curr_module;
  goto t14_label;
  t14_label: return t14;
}

cint debug_set_line_num_and_col(cint debug_l, cint debug_c){
  cint t15;
  debug_Curr_line = debug_l;
  debug_Curr_col = debug_c;
  t15_label: return t15;
}

cint debug_set_module(cint debug_mid){
  cint t16;
  debug_Curr_module = debug_mid;
  t16_label: return t16;
}

cint debug_set_high_level_message(cint debug_hlm){
  cint t17;
  debug_High_level_message = debug_hlm;
  t17_label: return t17;
}

void init_debug(){
  copy_meth_table(debug_methods, entity_methods);
  debug_methods[0] = 0;
  debug_methods[1] = debug_init;
  debug_methods[113] = debug_interact;
  debug_methods[114] = debug_message;
  debug_methods[115] = debug_get_module;
  debug_methods[116] = debug_set_line_num_and_col;
  debug_methods[117] = debug_set_module;
  debug_methods[118] = debug_set_high_level_message;
  debug_Curr_line = 1;
  debug_Curr_col = 1;
}
