/* generated by Id 1.0 at 2007-08-31 06:58:51 Z */
/* with the command: -I../stage1/ -c _object.st -o ../stage2/_object.o.c */

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <setjmp.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <assert.h>
#define GC_DLL 1
#include <gc/gc.h>
#if defined(WIN32)
# include <malloc.h>
# include <windows.h>
  typedef HINSTANCE dlhandle_t;
# define dlopen(path, mode)	LoadLibrary(path)
# define dlsym(handle, name)	((void *)GetProcAddress(handle, name))
# define dlclose(handle)	FreeLibrary(handle)
# include <winbase.h>
  inline int gettimeofday(struct timeval *tp, void *tzp)
  {
     union {
       long long ns100;
       FILETIME ft;
     } _now;
     GetSystemTimeAsFileTime(&_now.ft);
     tp->tv_usec= (long)((_now.ns100 / 10LL) % 1000000LL);
     tp->tv_sec= (long)((_now.ns100 - (116444736000000000LL)) / 10000000LL);
     return 0;
   }
#else
# include <dlfcn.h>
  typedef void *dlhandle_t;
#endif
#ifndef O_BINARY
# define O_BINARY 0
#endif

typedef struct t__object *oop;

typedef oop (*_imp_t)(oop _thunk, oop receiver, ...);

struct __closure
{
  _imp_t method;
  oop	 data;
};

static void              *(*_local_param   )(int index)= 0;
static oop  		  (*_local_intern  )(const char *string)= 0;
static oop  		  (*_local_proto   )(oop base)= 0;
static oop  		  (*_local_import  )(const char *name)= 0;
static oop  		  (*_local_export  )(const char *name, oop value)= 0;
static void 		  (*_local_method  )(oop type, oop selector, _imp_t method)= 0;
static oop  		  (*_local_alloc   )(oop type, size_t size)= 0;
static oop  		 *(*_local_palloc  )(size_t size)= 0;
static void  		 *(*_local_balloc  )(size_t size)= 0;
static struct __closure  *(*_local_bind    )(oop selector, oop receiver)= 0;
static oop                (*_local_nlreturn)(oop nlr, oop result)= 0;
static oop                (*_local_nlresult)(void)= 0;
static oop  		    _local_object= 0;
static oop  		   *_local_tag_vtable= 0;
static oop  		   *_local_nil_vtable= 0;
static void               (*_local_gc_addRoots)(char *lo, char *hi)= 0;
static void	          (*_local_gc_unregisterDisappearingLink)(void *ptr)= 0;
static void		  (*_local_gc_generalRegisterDisappearingLink)(void *link, void *ptr)= 0;
static void		  (*_local_gc_gcollect)(void)= 0;
static void		 *(*_local_enter)(char *name, char *type, char *file)= 0;
static void		  (*_local_line)(int line)= 0;
static void		  (*_local_leave)(void *)= 0;
static char		 *(*_local_backtrace)(void)= 0;

#define _param(INDEX)		_local_param(INDEX)
#define _selector(NAME)		_local_intern(NAME)
#define _proto(BASE)		_local_proto(BASE)
#define _id_import(NAME)	_local_import(NAME)
#define _id_export(NAME, VAL)	_local_export((NAME), (VAL))
#define _method(TYPE, SEL, IMP)	_local_method((TYPE), (SEL), (_imp_t)(IMP))
#define _alloc(RCV, LBS)	_local_alloc((RCV), (LBS))
#define _palloc(LBS)		_local_palloc((LBS))
#define _balloc(LBS)		_local_balloc((LBS))
#define _nlreturn(NLR, ARG)	_local_nlreturn((NLR), (ARG))
#define _nlresult()		_local_nlresult()
#define _backtrace()		_local_backtrace()
#ifdef ID_DEBUG
# define _enter(NM, TYPE, FILE)	void *__id_debug= _local_enter(NM, TYPE, FILE)
# define _line(line)		_local_line(line)
# define _leave()		_local_leave(__id_debug)
#else
# define _enter(NM, TYPE, FILE)
# define _line(line)
# define _leave()
#endif
#define _return			_leave(); return

#define _send(MSG, RCV, ARG...) ({					\
  register oop _r= (RCV);						\
  struct __closure *_c= (struct __closure *)_local_bind((MSG), _r);	\
  (_c->method)((oop)_c, _r, _r, ##ARG);					\
})

#define _super(TYP, MSG, RCV, ARG...) ({				\
  register oop _r= (RCV);						\
  struct __closure *_c= (struct __closure *)_local_bind((MSG), (TYP));	\
  (_c->method)((oop)_c, _r, _r, ##ARG);					\
})

static oop s_new_5f_= 0;
static oop s__5fstring= 0;
static oop s_size_5f_value_5f_= 0;
static oop s__5fdebugName= 0;
static oop s__5ftypeName_doesNotUnderstand_= 0;
static oop s_doesNotUnderstand_= 0;
static oop s__5fsizeof= 0;
static struct _Selector { const char *name; oop *addr; } _Selectors[]= {
  { "new_:", &s_new_5f_ },
  { "_string", &s__5fstring },
  { "size_:value_:", &s_size_5f_value_5f_ },
  { "_debugName", &s__5fdebugName },
  { "_typeName:doesNotUnderstand:", &s__5ftypeName_doesNotUnderstand_ },
  { "doesNotUnderstand:", &s_doesNotUnderstand_ },
  { "_sizeof", &s__5fsizeof },
  { 0, 0 }
};
struct t__object {
  struct _vtable *_vtable[0];
};
struct t__selector {
  struct _vtable *_vtable[0];
  oop v__size;
  oop v__elements;
};
struct t__assoc {
  struct _vtable *_vtable[0];
  oop v_key;
  oop v_value;
};
struct t__closure {
  struct _vtable *_vtable[0];
  oop v__method;
  oop v_data;
};
struct t__vector {
  struct _vtable *_vtable[0];
  oop v__size;
};
struct t__vtable {
  struct _vtable *_vtable[0];
  oop v__tally;
  oop v_bindings;
  oop v_delegate;
};
static oop v__object= 0;
static oop v__selector= 0;
static oop v__assoc= 0;
static oop v__closure= 0;
static oop v__vector= 0;
static oop v__vtable= 0;
static oop _object___5fdebugName(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_debugName", "_object", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(48);
 {
# define self ((struct t__object *)v_self)
 return (oop)"_object";   
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _object___5fsizeof(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_sizeof", "_object", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(48);
 {
# define self ((struct t__object *)v_self)
 return (oop)sizeof(struct t__object  ); 
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _selector___5fdebugName(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_debugName", "_selector", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(49);
 {
# define self ((struct t__selector *)v_self)
 return (oop)"_selector"; 
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _selector___5fsizeof(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_sizeof", "_selector", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(49);
 {
# define self ((struct t__selector *)v_self)
 return (oop)sizeof(struct t__selector); 
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _assoc___5fdebugName(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_debugName", "_assoc", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(50);
 {
# define self ((struct t__assoc *)v_self)
 return (oop)"_assoc";    
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _assoc___5fsizeof(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_sizeof", "_assoc", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(50);
 {
# define self ((struct t__assoc *)v_self)
 return (oop)sizeof(struct t__assoc   ); 
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _closure___5fdebugName(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_debugName", "_closure", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(51);
 {
# define self ((struct t__closure *)v_self)
 return (oop)"_closure";  
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _closure___5fsizeof(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_sizeof", "_closure", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(51);
 {
# define self ((struct t__closure *)v_self)
 return (oop)sizeof(struct t__closure ); 
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _vector___5fdebugName(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_debugName", "_vector", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(52);
 {
# define self ((struct t__vector *)v_self)
 return (oop)"_vector";   
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _vector___5fsizeof(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_sizeof", "_vector", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(52);
 {
# define self ((struct t__vector *)v_self)
 return (oop)sizeof(struct t__vector  ); 
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _vtable___5fdebugName(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_debugName", "_vtable", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(53);
 {
# define self ((struct t__vtable *)v_self)
 return (oop)"_vtable";   
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _vtable___5fsizeof(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_sizeof", "_vtable", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(53);
 {
# define self ((struct t__vtable *)v_self)
 return (oop)sizeof(struct t__vtable  ); 
# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _object__doesNotUnderstand_(oop v__closure, oop v_stateful_self, oop v_self, oop v_aSelector)
 {
  _enter("doesNotUnderstand:", "_object", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  oop _2= 0;
  oop _3= 0;
  _line(57);
  _1= v_self;
  _2= v_self;
  _line(59);
  _2=_send(s__5fdebugName, _2);
  _3= v_aSelector;
  _line(59);
  _3=_send(s__5fstring, _3);
  _line(59);
  _1=_send(s__5ftypeName_doesNotUnderstand_, _1, _2, _3);
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _object___5ftypeName_doesNotUnderstand_(oop v__closure, oop v_stateful_self, oop v_self, oop v__cName, oop v__cSelector)
 {
  _enter("_typeName:doesNotUnderstand:", "_object", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(62);
 {
# define self ((struct t__object *)v_self)

  fprintf(stderr, "%s does not understand '%s'\n", (char *)v__cName, (char *)v__cSelector);
  abort();

# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _selector__size_5f_value_5f_(oop v__closure, oop v_stateful_self, oop v_self, oop v__stringSize, oop v__stringValue)
 {
  _enter("size_:value_:", "_selector", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(68);
 {
# define self ((struct t__selector *)v_self)

  char *buf= alloca((size_t)v__stringSize + 1);
  memcpy((void *)buf, (void *)v__stringValue, (size_t)v__stringSize);
  buf[(size_t)v__stringSize]= '\0';
  return _local_intern(buf);

# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }
static oop _selector___5fstring(oop v__closure, oop v_stateful_self, oop v_self)
 {
  _enter("_string", "_selector", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(76);
  _1= ((struct t__selector *)v_stateful_self)->v__elements;
  _leave();
  return _1;
  _leave();
 }
static oop _vector__new_5f_(oop v__closure, oop v_stateful_self, oop v_self, oop v__newSize)
 {
  _enter("new_:", "_vector", "/home/saintiss/source/svn/stIdst_278/object/st80/_object.st");
  oop _1= 0;
  _line(83);
 {
# define self ((struct t__vector *)v_self)

#ifndef STAGE1
  v_stateful_self=
#endif
  v_self= _alloc(v_self, sizeof(struct t__vector) + sizeof(oop) * (size_t)v__newSize);
  ((struct t__vector *)v_self)->v__size= v__newSize;

# undef self
 }
  _1= 0;
  _1= v_self;
  _leave();
  return _1;
  _leave();
 }

void __id__init___5fobject(void)
{
  if (_local_object) return;
  { 
    dlhandle_t global= dlopen(0, RTLD_LAZY);
    _local_object= *(oop *)dlsym(global, "_libid_object");
    _local_param= dlsym(global, "_libid_param");
    _local_intern= dlsym(global, "_libid_intern");
    _local_proto= dlsym(global, "_libid_proto");
    _local_import= dlsym(global, "_libid_import");
    _local_export= dlsym(global, "_libid_export");
    _local_method= dlsym(global, "_libid_method");
    _local_alloc= dlsym(global, "_libid_alloc");
    _local_palloc= dlsym(global, "_libid_palloc");
    _local_balloc= dlsym(global, "_libid_balloc");
    _local_bind= dlsym(global, "_libid_bind");
    _local_nlreturn= dlsym(global, "_libid_nlreturn");
    _local_nlresult= dlsym(global, "_libid_nlresult");
    _local_enter= dlsym(global, "_libid_enter");
    _local_line= dlsym(global, "_libid_line");
    _local_leave= dlsym(global, "_libid_leave");
    _local_backtrace= dlsym(global, "_libid_backtrace");
    _local_tag_vtable= dlsym(global, "_libid_tag_vtable");
    _local_nil_vtable= dlsym(global, "_libid_nil_vtable");
    _local_gc_addRoots= dlsym(global, "GC_add_roots");
    _local_gc_unregisterDisappearingLink= dlsym(global, "GC_unregister_disappearing_link");
    _local_gc_generalRegisterDisappearingLink= dlsym(global, "GC_general_register_disappearing_link");
    _local_gc_gcollect= dlsym(global, "GC_gcollect");
    dlclose(global);
  }
# define GC_add_roots _local_gc_addRoots
  GC_INIT();
  {
    struct _Selector *s= 0;
    for (s= _Selectors;  s->name;  ++s)
      *s->addr= _selector(s->name);
  }
  _enter("__id__init__", "<initialisation>", "_object.st");

  v__object= _id_import("_object");
  v__selector= _id_import("_selector");
  v__assoc= _id_import("_assoc");
  v__closure= _id_import("_closure");
  v__vector= _id_import("_vector");
  v__vtable= _id_import("_vtable");
  _method(v__object, s__5fdebugName, _object___5fdebugName);
  _method(v__object, s__5fsizeof, _object___5fsizeof);
  _method(v__selector, s__5fdebugName, _selector___5fdebugName);
  _method(v__selector, s__5fsizeof, _selector___5fsizeof);
  _method(v__assoc, s__5fdebugName, _assoc___5fdebugName);
  _method(v__assoc, s__5fsizeof, _assoc___5fsizeof);
  _method(v__closure, s__5fdebugName, _closure___5fdebugName);
  _method(v__closure, s__5fsizeof, _closure___5fsizeof);
  _method(v__vector, s__5fdebugName, _vector___5fdebugName);
  _method(v__vector, s__5fsizeof, _vector___5fsizeof);
  _method(v__vtable, s__5fdebugName, _vtable___5fdebugName);
  _method(v__vtable, s__5fsizeof, _vtable___5fsizeof);
  _method(v__object, s_doesNotUnderstand_, _object__doesNotUnderstand_);
  _method(v__object, s__5ftypeName_doesNotUnderstand_, _object___5ftypeName_doesNotUnderstand_);
  _method(v__selector, s_size_5f_value_5f_, _selector__size_5f_value_5f_);
  _method(v__selector, s__5fstring, _selector___5fstring);
  _method(v__vector, s_new_5f_, _vector__new_5f_);
  _leave();
}
