Mercurial > repos > rhope
diff runtime/object.h @ 7:d61550e2c001
Added current work on new runtime
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 13 May 2009 00:47:40 -0400 |
parents | |
children | 8d74ef7fa357 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/runtime/object.h Wed May 13 00:47:40 2009 -0400 @@ -0,0 +1,90 @@ +#ifndef _OBJECT_H_ +#define _OBJECT_H_ + +#include "plat_types.h" +#include "thread.h" + +typedef enum { + NORMAL_RETURN=0, + EXCEPTION_RETURN, + TAIL_RETURN, + NO_CONVERSION, + STACK_UNWIND +} returntype; + + +typedef returntype (*rhope_func)(struct calldata *); +typedef void (*special_func) (struct object *); + +typedef struct{ + rhope_func *method_lookup; + rhope_func *getter_lookup; + rhope_func *setter_lookup; + rhope_func *convert_to; + rhope_func *convert_from; + special_func init; + special_func copy; + special_func cleanup; + struct object *name; + uint32_t first_methodid; + uint32_t last_methodid; + uint32_t first_getfieldid; + uint32_t last_getfieldid; + uint32_t first_setfieldid; + uint32_t last_setfieldid; + uint32_t first_convertto; + uint32_t last_convertto; + uint32_t first_convertfrom; + uint32_t last_convertfrom; + uint32_t size; + uint32_t boxed_size; +} blueprint; + +typedef struct object { + rh_atomic32(refcount); + blueprint *bprint; +} object; + +typedef struct { + object base; + uint32_t size; +} multisize; + + +typedef struct calldata { + rhope_func tail_func; + uint32_t num_params; + uint32_t original_methodid; + object *params[32]; +} calldata; + +#define OBegin typedef struct { object header; +#define Object(name) } _t_ ## name; + +#define MOBegin typedef struct { multisize header; + +#define get_blueprint(object) (object)->bprint + +#define add_ref(object) rh_atomic_add(&(object->header), refcount, 1) + +returntype call_method(uint32_t methodid, calldata * params); +returntype set_field(uint32_t setfieldid, calldata * params); +returntype get_field(uint32_t getfieldid, calldata * params); +object * alloc_object(blueprint * bp); +void * alloc_variable(uint32_t size); +object * new_object(uint32_t type); +multisize * new_multisize(uint32_t type, uint32_t size); +void release_ref(object * obj); +blueprint * register_type_byid(uint32_t type, uint32_t size, special_func init, special_func copy, special_func cleanup); +blueprint * new_blueprint(uint32_t type, uint32_t size, special_func init, special_func copy, special_func cleanup); +void add_method(blueprint * bp, uint32_t methodid, rhope_func impl); +returntype convert_to(uint32_t convertto, calldata * params); +returntype convert_from(uint32_t convertfrom, calldata * params); +object * copy_object(object * tocopy); +returntype coerce_value(uint32_t type, calldata * params); + +#define INITIAL_TYPE_STORAGE 32 +#define INITIAL_METHOD_LOOKUP 8 +#define BELOW_INITIAL_METHOD 3 + +#endif //_OBJECT_H_