Mercurial > repos > rhope
changeset 63:04baa003de5a
Merged latest changes with better C branch
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 05 May 2010 22:12:23 -0400 |
parents | b218af069da7 (diff) 048046186d22 (current diff) |
children | e1fd6d244f14 |
files | runtime/bool.c runtime/bool.h runtime/builtin.c runtime/context.c runtime/context.h runtime/func.h runtime/integer.c runtime/integer.h runtime/object.c runtime/object.h |
diffstat | 9 files changed, 474 insertions(+), 214 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/bool.h Thu Apr 29 01:47:10 2010 -0400 +++ b/runtime/bool.h Wed May 05 22:12:23 2010 -0400 @@ -3,6 +3,5 @@ #include "object.h" -MethodDef(If,Boolean) #endif //BOOL_H_
--- a/runtime/builtin.c Thu Apr 29 01:47:10 2010 -0400 +++ b/runtime/builtin.c Wed May 05 22:12:23 2010 -0400 @@ -24,7 +24,6 @@ for(i = 0; i < TYPE_FIRST_USER; ++i) register_builtin_type(i); } - object * make_Int64(int64_t val) { t_Int64 * obj; @@ -127,21 +126,4 @@ return retobj; } -#define lval ((t_Boolean *)(cdata->params[0]))->Val - -MethodNoLocals(If,Boolean, - NumParams 1, - CallSpace 1) - - Param(0, TYPE_BOOLEAN) - - if(lval) - { - Ret(1, NULL) - } else { - Ret(1, cdata->params[0]); - Ret(0, NULL) - } -EndFunc -
--- a/runtime/builtin.h Thu Apr 29 01:47:10 2010 -0400 +++ b/runtime/builtin.h Wed May 05 22:12:23 2010 -0400 @@ -47,7 +47,4 @@ void register_builtin_types(); void register_builtin_type(uint32_t type); -//TODO: Remove this when it's possible to write Print in Rhope -FuncDef(Print) - #endif //_BUILTIN_H_
--- a/runtime/context.c Thu Apr 29 01:47:10 2010 -0400 +++ b/runtime/context.c Wed May 05 22:12:23 2010 -0400 @@ -18,7 +18,6 @@ context * c = malloc(sizeof(context)); c->stack_begin = new_stack(); c->current_stack = c->stack_begin; - c->unwind = NULL; return c; } @@ -63,12 +62,11 @@ return ret; } -calldata * alloc_cdata(context * ct, uint32_t num_params) +calldata * alloc_cdata(context * ct, calldata * lastframe, uint32_t num_params) { - calldata * out = alloc_stack(ct, sizeof(calldata)+(num_params-1)*sizeof(object *)); - if(out) - out->ct = ct; - return out; + calldata * retval = (calldata *)(((char *)alloc_stack(ct, sizeof(calldata)+(num_params-1)*sizeof(object *))) + sizeof(object *)*(num_params-1)); + retval->lastframe = lastframe; + return retval; } void free_stack(context * ct, void * data)
--- a/runtime/context.h Thu Apr 29 01:47:10 2010 -0400 +++ b/runtime/context.h Wed May 05 22:12:23 2010 -0400 @@ -14,15 +14,9 @@ char data[STACK_CHUNK_SIZE]; } stackchunk; -typedef struct { - rhope_func func; - calldata *params; -} unwind_cell; - typedef struct context { stackchunk *stack_begin; stackchunk *current_stack; - unwind_cell *unwind; } context; stackchunk * new_stack();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/runtime/fib.c Wed May 05 22:12:23 2010 -0400 @@ -0,0 +1,356 @@ +#include <stdio.h> +#include "builtin.h" +#include "object.h" +#include "context.h" +#include "func.h" +#include "integer.h" +#include "bool.h" + +typedef enum { + FUNC__LT_, + FUNC__LT__AT_Int32, + FUNC__MN_, + FUNC__MN__AT_Int32, + FUNC__PL_, + FUNC__PL__AT_Int32, + FUNC_Fib, + FUNC_Fib_1, + FUNC_Fib_2, + FUNC_Fib_3, + FUNC_Fib_4, + FUNC_Fib_5, + FUNC_Fib_6, + FUNC_If, + FUNC_If_AT_Yes_SP_No, + FUNC_Main, + FUNC_Main_1, + FUNC_Main_2, + FUNC_Print, + END +} funcids; + +#define DISPATCH switch(func) { \ + case FUNC__LT_: goto f__LT_;\ + case FUNC__LT__AT_Int32: goto f__LT__AT_Int32;\ + case FUNC__MN_: goto f__MN_;\ + case FUNC__MN__AT_Int32: goto f__MN__AT_Int32;\ + case FUNC__PL_: goto f__PL_;\ + case FUNC__PL__AT_Int32: goto f__PL__AT_Int32;\ + case FUNC_Fib: goto f_Fib;\ + case FUNC_Fib_1: goto r1_Fib;\ + case FUNC_Fib_2: goto r2_Fib;\ + case FUNC_Fib_3: goto r3_Fib;\ + case FUNC_Fib_4: goto r4_Fib;\ + case FUNC_Fib_5: goto r5_Fib;\ + case FUNC_Fib_6: goto r6_Fib;\ + case FUNC_If: goto f_If;\ + case FUNC_If_AT_Yes_SP_No: goto f_If_AT_Yes_SP_No;\ + case FUNC_Main: goto f_Main;\ + case FUNC_Main_1: goto r1_Main;\ + case FUNC_Main_2: goto r2_Main;\ + case FUNC_Print: goto f_Print;\ + case END: goto DO_END;\ +} + + +typedef struct { + struct object *____result__0__0; + struct object *____result__0__1; + struct object *____result__10__0; + struct object *____result__11__0; + struct object *____result__1__0; + struct object *____result__5__0; + struct object *____result__6__0; + struct object *____result__7__0; + struct object *out; +} lt_Fib; + +typedef struct { + struct object *____result__0__0; + struct object *____result__1__0; +} lt_Main; + +object * _const_Whole_SP_Number__1; +object * _const_Whole_SP_Number__2; +object * _const_Whole_SP_Number__30; + +void rhope(uint32_t func) +{ + uint16_t resume,idx; + context * ct; + calldata * cdata, *temp_cdata; +FuncDef(Fib) +FuncDef(Main) + + ct = new_context(); + cdata = alloc_cdata(ct, NULL, 0); + cdata->num_params = 0; + cdata->func = END; +DISPATCH +Method(_LT_) + MethodDispatch(TYPE_INT32,_LT_,Int32) +EndMethod + +MethodImplNoLocals(_LT_,Int32,TYPE_INT32, + NumParams 2) + + Param(1, TYPE_INT32) + + if(((t_Int32 *)cdata->params[0])->num < ((t_Int32 *)cdata->params[-1])->num) + { + release_ref(cdata->params[0]); + Ret(0, Yes) + } else { + release_ref(cdata->params[0]); + Ret(0, No) + } + + release_ref(cdata->params[-1]); +EndFuncNoLocals +DISPATCH + +Method(_MN_) + MethodDispatch(TYPE_INT32,_MN_,Int32) +EndMethod +DISPATCH + +MethodImplNoLocals(_MN_,Int32,TYPE_INT32, + NumParams 2) + + Param(1, TYPE_INT32) + + cdata->params[0] = copy_object(cdata->params[0]); + ((t_Int32 *)cdata->params[0])->num -= ((t_Int32 *)cdata->params[-1])->num; + + release_ref(cdata->params[-1]); +EndFuncNoLocals +DISPATCH + +Method(_PL_) + MethodDispatch(TYPE_INT32,_PL_,Int32) +EndMethod +DISPATCH + +MethodImplNoLocals(_PL_,Int32,TYPE_INT32, + NumParams 2) + + Param(1, TYPE_INT32) + + cdata->params[0] = copy_object(cdata->params[0]); + ((t_Int32 *)cdata->params[0])->num += ((t_Int32 *)cdata->params[-1])->num; + + release_ref(cdata->params[-1]); +EndFuncNoLocals +DISPATCH + +Func(Fib, + NumParams 1) + lv_Fib->____result__0__0 = NULL; + lv_Fib->____result__0__1 = NULL; + lv_Fib->____result__1__0 = NULL; + lv_Fib->____result__5__0 = NULL; + lv_Fib->____result__6__0 = NULL; + lv_Fib->____result__7__0 = NULL; + lv_Fib->____result__10__0 = NULL; + lv_Fib->____result__11__0 = NULL; + lv_Fib->out = NULL; + + PrepCall(2) + + SetParam(0, add_ref(cdata->lastframe->params[0])) + SetParam(1, add_ref(_const_Whole_SP_Number__2)) + Call(_LT_, + NumParams 2, 1, Fib) + lv_Fib->____result__1__0 = cdata->params[0]; + + SetParam(0, add_ref(lv_Fib->____result__1__0)) + Call(If, + NumParams 1, 2, Fib) + lv_Fib->____result__0__0 = cdata->params[0]; + lv_Fib->____result__0__1 = cdata->params[-1]; + + if(lv_Fib->____result__0__1) + { + SetParam(0, add_ref(cdata->lastframe->params[0])) + SetParam(1, add_ref(_const_Whole_SP_Number__1)) + Call(_MN_, + NumParams 2, 3, Fib) + lv_Fib->____result__7__0 = cdata->params[0]; + } + if(lv_Fib->____result__0__1) + { + SetParam(0, add_ref(cdata->lastframe->params[0])) + SetParam(1, add_ref(_const_Whole_SP_Number__2)) + Call(_MN_, + NumParams 2, 4, Fib) + lv_Fib->____result__11__0 = cdata->params[0]; + } + if(lv_Fib->____result__0__0) + { + lv_Fib->out = add_ref(_const_Whole_SP_Number__1); + } + if(lv_Fib->____result__0__1) + { + SetParam(0, add_ref(lv_Fib->____result__7__0)) + Call(Fib, + NumParams 1, 5, Fib) + lv_Fib->____result__6__0 = cdata->params[0]; + } + if(lv_Fib->____result__0__1) + { + SetParam(0, add_ref(lv_Fib->____result__11__0)) + Call(Fib, + NumParams 1, 6, Fib) + lv_Fib->____result__10__0 = cdata->params[0]; + } + if(lv_Fib->____result__0__1) + { + if(lv_Fib->____result__0__0) + { + release_ref(lv_Fib->____result__0__0); + } + if(lv_Fib->____result__0__1) + { + release_ref(lv_Fib->____result__0__1); + } + if(lv_Fib->____result__1__0) + { + release_ref(lv_Fib->____result__1__0); + } + if(lv_Fib->____result__7__0) + { + release_ref(lv_Fib->____result__7__0); + } + if(lv_Fib->____result__11__0) + { + release_ref(lv_Fib->____result__11__0); + } + TPrepCall(2) + SetParam(0, lv_Fib->____result__6__0) + SetParam(1, lv_Fib->____result__10__0) + TCall(_PL_, + NumParams 2) + //lv_Fib->____result__5__0 = cdata->params[0]; + } + FreeCall + if(lv_Fib->____result__0__1) + { + lv_Fib->out = add_ref(lv_Fib->____result__5__0); + } + if(lv_Fib->____result__0__0) + { + release_ref(lv_Fib->____result__0__0); + } + if(lv_Fib->____result__0__1) + { + release_ref(lv_Fib->____result__0__1); + } + if(lv_Fib->____result__1__0) + { + release_ref(lv_Fib->____result__1__0); + } + if(lv_Fib->____result__5__0) + { + release_ref(lv_Fib->____result__5__0); + } + if(lv_Fib->____result__6__0) + { + release_ref(lv_Fib->____result__6__0); + } + if(lv_Fib->____result__7__0) + { + release_ref(lv_Fib->____result__7__0); + } + if(lv_Fib->____result__10__0) + { + release_ref(lv_Fib->____result__10__0); + } + if(lv_Fib->____result__11__0) + { + release_ref(lv_Fib->____result__11__0); + } + release_ref(cdata->params[0]); + Ret(0, lv_Fib->out) +EndFunc(Fib) +DISPATCH + +Method(If) + MethodDispatch(TYPE_BOOLEAN,If,Yes_SP_No) +EndMethod + +MethodImplNoLocals(If,Yes_SP_No,TYPE_BOOLEAN, + NumParams 1) + + if(((t_Boolean *)(cdata->params[0]))->val) + { + Ret(1, NULL) + } else { + Ret(1, cdata->params[0]); + Ret(0, NULL) + } +EndFuncNoLocals +DISPATCH + +Func(Main, + NumParams 0) + + lv_Main->____result__0__0 = NULL; + lv_Main->____result__1__0 = NULL; + + PrepCall(1) + SetParam(0, add_ref(_const_Whole_SP_Number__30)) + Call(Fib, + NumParams 1, 1, Main) + lv_Main->____result__1__0 = cdata->params[0]; + FreeCall + + PrepCall(1) + SetParam(0, add_ref(lv_Main->____result__1__0)) + Call(Print, + NumParams 1, 2, Main) + lv_Main->____result__0__0 = cdata->params[0]; + FreeCall + + if(lv_Main->____result__0__0) + { + release_ref(lv_Main->____result__0__0); + } + if(lv_Main->____result__1__0) + { + release_ref(lv_Main->____result__1__0); + } +EndFunc(Main) +DISPATCH + +FuncNoLocals(Print, + NumParams 1) + + if(get_blueprint(cdata->params[0])->type_id == TYPE_INT32) + { + printf("%d\n", ((t_Int32 *)(cdata->params[0]))->num); + } else { + puts("Don't know how to print this type"); + } + release_ref(cdata->params[0]); + Ret(0, make_Int32(0)) +EndFuncNoLocals +DISPATCH + +DO_END: + return; + +_exception: + puts("whoops, exception!"); +} + +int main(int argc, char ** argv) +{ + register_builtin_types(); + + _const_Whole_SP_Number__1 = make_Int32(1); + _const_Whole_SP_Number__2 = make_Int32(2); + _const_Whole_SP_Number__30 = make_Int32(30); + + rhope(FUNC_Main); + return 0; +}
--- a/runtime/func.h Thu Apr 29 01:47:10 2010 -0400 +++ b/runtime/func.h Wed May 05 22:12:23 2010 -0400 @@ -18,190 +18,123 @@ #define MethodName(name,type) f_ ## name ## AT_ ## type -#define Func(name,numparams,callspace,localtype) \ - returntype f_ ## name (calldata * cdata)\ - {\ - localtype *locals;\ - calldata *call;\ - returntype ret;\ - int idx;\ - if(cdata->resume)\ - {\ - call = cdata->call;\ - locals = cdata->locals;\ - }\ - switch(cdata->resume)\ - {\ - case 0:\ - for(idx = numparams; idx < cdata->num_params; ++idx)\ - release_ref(cdata->params[idx]); cdata->num_params = numparams;\ - cdata->num_params = numparams;\ - cdata->call = call = alloc_cdata(cdata->ct, callspace);\ - cdata->locals = locals = alloc_stack(cdata->ct, sizeof(localtype)); + +#define Func(name,numparams) \ +f_ ## name:\ + for(idx = numparams; idx < cdata->num_params; ++idx)\ + release_ref(cdata->params[0-idx]); cdata->num_params = numparams;\ +sf_ ## name:\ + lv_ ## name = alloc_stack(ct, sizeof(lt_ ## name)); + -#define FuncNoLocals(name,numparams,callspace) \ - returntype f_ ## name (calldata * cdata)\ - {\ - calldata *call;\ - returntype ret;\ - int idx;\ - if(cdata->resume)\ - call = cdata->locals;\ - switch(cdata->resume)\ - {\ - case 0:\ - for(idx = numparams; idx < cdata->num_params; ++idx)\ - release_ref(cdata->params[idx]);\ - cdata->num_params = numparams;\ - cdata->locals = call = alloc_cdata(cdata->ct, callspace); +#define FuncNoLocals(name,numparams) \ +f_ ## name:\ + for(idx = numparams; idx < cdata->num_params; ++idx)\ + release_ref(cdata->params[0-idx]); cdata->num_params = numparams;\ +sf_ ## name: + +#define EndFunc(name) \ + free_stack(ct, lv_ ## name);\ + func = cdata->func; + +#define EndFuncNoLocals \ + func = cdata->func; -#define EndFunc \ - free_stack(cdata->ct, call);\ - return NORMAL_RETURN;\ - }\ - } - -#define Method(name,type,numparams,callspace,localtype) \ - returntype MethodName(name,type) (calldata * cdata)\ - {\ - localtype *locals;\ - calldata *call;\ - returntype ret;\ - int idx;\ - if(cdata->resume)\ - {\ - call = cdata->call;\ - locals = cdata->locals;\ - }\ - switch(cdata->resume)\ +#define Method(name) \ +f_ ## name:\ +sf_ ## name:\ + switch(get_blueprint(cdata->params[0])->type_id)\ + { + +#define EndMethod \ + default:\ + goto _exception;\ + } + + +#define MethodDispatch(type_id,name,type_name) \ + case type_id:\ + goto m_ ## name ## _AT_ ## type_name; + +#define MethodImpl(name,type_name,mytype_id,numparams) \ +f_ ## name ## _AT_ ## type_name:\ +sf_ ## name ## _AT_ ## type_name:\ + if (cdata->num_params < 1)\ + goto _exception;\ + if(get_blueprint(cdata->params[0])->type_id != mytype_id)\ {\ - case 0:\ - for(idx = numparams; idx < cdata->num_params; ++idx)\ - release_ref(cdata->params[idx]); cdata->num_params = numparams;\ - cdata->num_params = numparams;\ - cdata->call = call = alloc_cdata(cdata->ct, callspace);\ - cdata->locals = locals = alloc_stack(cdata->ct, sizeof(localtype)); - -#define MethodNoLocals(name,type,numparams,callspace) \ - returntype MethodName(name,type) (calldata * cdata)\ - {\ - calldata *call;\ - returntype ret;\ - int idx;\ - if(cdata->resume)\ - call = cdata->locals;\ - switch(cdata->resume)\ + puts("uh oh, need conversion and that's not implemented yet!");\ + exit(1);\ + }\ +m_ ## name ## _AT_ ## type_name:\ + for(idx = numparams; idx < cdata->num_params; ++idx)\ + release_ref(cdata->params[0-idx]); cdata->num_params = numparams;\ + lv_ ## name ## _AT_ ## type_name = alloc_stack(ct, sizeof(lt_ ## name ## _AT_ ## type_name)); + + +#define MethodImplNoLocals(name,type_name,mytype_id,numparams) \ +f_ ## name ## _AT_ ## type_name:\ +sf_ ## name ## _AT_ ## type_name:\ + if (cdata->num_params < 1)\ + goto _exception;\ + if(get_blueprint(cdata->params[0])->type_id != mytype_id)\ {\ - case 0:\ - for(idx = numparams; idx < cdata->num_params; ++idx)\ - release_ref(cdata->params[idx]);\ - cdata->num_params = numparams;\ - cdata->locals = call = alloc_cdata(cdata->ct, callspace); - + puts("uh oh, need conversion and that's not implemented yet!");\ + exit(1);\ + }\ +m_ ## name ## _AT_ ## type_name:\ + for(idx = numparams; idx < cdata->num_params; ++idx)\ + release_ref(cdata->params[0-idx]); cdata->num_params = numparams; + #define NumParams #define CallSpace #define Param(num,convtypeid) \ - call->params[0] = cdata->params[num];\ - call->resume = 0;\ - ret = coerce_value(convtypeid, call);\ - while(ret == TAIL_RETURN)\ - ret = call->tail_func(call);\ - if(ret == EXCEPTION_RETURN)\ + if(get_blueprint(cdata->params[0-num])->type_id != convtypeid)\ {\ - for(idx = 0; idx < cdata->num_params; ++idx)\ - if(idx != num && cdata->params[idx])\ - release_ref(cdata->params[idx]);\ - cdata->params[0] = call->params[0];\ - free_stack(cdata->ct, call);\ - return ret;\ - }\ - cdata->params[num] = call->params[0]; + puts("uh oh, need conversion and that's not implemented yet!");\ + exit(1);\ + } #define CopiedParam(num,convtypeid) Param(num,convtypeid) cdata->params[num] = copy_object(cdata->params[num]); -#define Ret(num,val) cdata->params[num] = (object *)(val); -#define Return return NORMAL_RETURN; +#define Ret(num,val) cdata->params[0-num] = (object *)(val); #define Exception -#define FuncDef(name) returntype f_ ## name (calldata * cdata); -#define MethodDef(name,type) returntype MethodName(name,type) (calldata * cdata); +#define FuncDef(name) lt_ ## name * lv_ ## name; +#define MethodDef(name) lt_ ## name ## _AT_ ## type_name * lv_ ## name ## _AT_ ## type_name; + + +#define PrepCall(callspace) cdata = alloc_cdata(ct, cdata, callspace); -#define Call(func, numparams)\ - call->num_params = numparams;\ - call->resume = 0;\ - ret = f_ ## func (call);\ - while(ret == TAIL_RETURN)\ - ret = call->tail_func(call);\ - if(ret == EXCEPTION_RETURN)\ - {\ - for(idx = 0; idx < cdata->num_params; ++idx)\ - if(cdata->params[idx])\ - release_ref(cdata->params[idx]);\ - cdata->params[0] = call->params[0];\ - free_stack(cdata->ct, call);\ - return ret;\ - } - -#define MCall(methodid, numparams)\ - call->num_params = numparams;\ - call->resume = 0;\ - ret = call_method(methodid, call);\ - while(ret == TAIL_RETURN)\ - ret = call->tail_func(call);\ - if(ret == EXCEPTION_RETURN)\ - {\ - for(idx = 0; idx < cdata->num_params; ++idx)\ - if(cdata->params[idx])\ - release_ref(cdata->params[idx]);\ - cdata->params[0] = call->params[0];\ - free_stack(cdata->ct, call);\ - return ret;\ - } +#define SetParam(num,value) cdata->params[0-num] = value; + +#define Call(tocall, numparams, resumeto, myname)\ + cdata->func = FUNC_ ## myname ## _ ## resumeto;\ + cdata->num_params = numparams;\ + goto sf_ ## tocall;\ +r ## resumeto ## _ ## myname:\ + lv_ ## myname = (lt_ ## myname *)(cdata->lastframe+1); -#define GFieldCall(fieldid)\ - call->num_params = 1;\ - call->resume = 0;\ - ret = get_field(fieldid, call);\ - while(ret == TAIL_RETURN)\ - ret = call->tail_func(call);\ - if(ret == EXCEPTION_RETURN)\ - {\ - for(idx = 0; idx < cdata->num_params; ++idx)\ - if(cdata->params[idx])\ - release_ref(cdata->params[idx]);\ - cdata->params[0] = call->params[0];\ - free_stack(cdata->ct, call);\ - return ret;\ - } - -#define SFieldCall(fieldid)\ - call->num_params = 2;\ - call->resume = 0;\ - ret = set_field(fieldid, call);\ - while(ret == TAIL_RETURN)\ - ret = call->tail_func(call);\ - if(ret == EXCEPTION_RETURN)\ - {\ - for(idx = 0; idx < cdata->num_params; ++idx)\ - if(cdata->params[idx])\ - release_ref(cdata->params[idx]);\ - cdata->params[0] = call->params[0];\ - free_stack(cdata->ct, call);\ - return ret;\ - } +#define FreeCall\ + temp_cdata = cdata->lastframe;\ + free_stack(ct, cdata);\ + cdata = temp_cdata; -#define TMCall(methodid, numparams)\ - free_stack(cdata->ct, call);\ - cdata->num_params = numparams;\ - cdata->resume = 0;\ - ret = call_method(methodid, cdata);\ - return ret; - -#define TCall(func, numparams)\ - free_stack(cdata->ct, call);\ - cdata->num_params = numparams;\ - cdata->resume = 0;\ - cdata->tail_func = f_ ## func;\ - return TAIL_RETURN; +#define FreeCallMethod(myname,mytype)\ + temp_cdata = cdata->lastframe;\ + free_stack(ct, cdata);\ + cdata = temp_cdata;\ + lv_ ## myname ## _AT_ ## type_name = (lt_ ## myname ## _AT_ ## type_name *)(cdata+1); + +#define TPrepCall(callspace) \ + func = cdata->lastframe->func;\ + temp_cdata = cdata->lastframe->lastframe;\ + free_stack(ct, cdata->lastframe);\ + cdata = alloc_cdata(ct, temp_cdata, callspace);\ + cdata->func = func; + +#define TCall(tocall, numparams)\ + cdata->num_params = numparams;\ + goto sf_ ## tocall; #endif //_FUNC_H_
--- a/runtime/object.c Thu Apr 29 01:47:10 2010 -0400 +++ b/runtime/object.c Wed May 05 22:12:23 2010 -0400 @@ -10,6 +10,7 @@ uint32_t type_storage = 0; mem_manager * manager = NULL; +/* returntype call_method(uint32_t methodid, calldata * params) { @@ -124,7 +125,7 @@ release_ref(params->params[i]); params->params[0] = new_object(TYPE_WRONGTYPEEXCEPTION); return EXCEPTION_RETURN; -} +}*/ object * alloc_object(blueprint * bp) { @@ -309,6 +310,7 @@ bp->size = size; bp->boxed_size = size >= 0 ? size + sizeof(object) : 0; bp->method_lookup = bp->getter_lookup = bp->setter_lookup = bp->convert_to = bp->convert_from = NULL; + bp->type_id = type; bp->init = init ? init : default_action; bp->copy = copy ? copy : default_action; bp->cleanup = cleanup ? cleanup : default_action;
--- a/runtime/object.h Thu Apr 29 01:47:10 2010 -0400 +++ b/runtime/object.h Wed May 05 22:12:23 2010 -0400 @@ -16,6 +16,7 @@ special_func cleanup; special_func free; struct object *name; + uint32_t type_id; uint32_t first_methodid; uint32_t last_methodid; uint32_t first_getfieldid; @@ -40,17 +41,15 @@ uint32_t size; } multisize; - -struct calldata { - rhope_func tail_func; - struct context *ct; - void *locals; - struct calldata *call; - uint32_t original_methodid; - uint16_t num_params; - uint16_t resume; - object *params[1]; +#pragma pack(push,1) +typedef struct calldata { + object *params[1]; + struct calldata *lastframe; + uint16_t num_params; + uint16_t resume; + uint32_t func; }; +#pragma pack(pop) #define OBegin typedef struct { #define Object(name) } nt_ ## name; typedef struct { object SP_header; nt_ ## name payload; } t_ ## name;