Mercurial > repos > rhope
view test/test.c @ 138:1411de6050e1
First stab at transaction data structures, needs work
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 16 Nov 2010 21:53:18 -0500 |
parents | 31f8182f3433 |
children |
line wrap: on
line source
#include <stdio.h> #include "builtin.h" #include "object.h" #include "integer.h" #include "context.h" #include "func.h" FuncNoLocals(Main, NumParams 0, CallSpace 2) call->params[0] = make_Int32(2); call->params[1] = make_Int32(3); MCall(METHOD_ADD, 2) call->params[1] = make_Int32(1); MCall(METHOD_SUB, 2) Ret(0,call->params[0]) EndFunc int main(int argc, char ** argv) { returntype ret; calldata *cdata; context * ct; register_builtin_types(); ct = new_context(); cdata = alloc_cdata(ct, 1); cdata->num_params = 0; cdata->resume = 0; ret = f_Main(cdata); while(ret == TAIL_RETURN) ret = cdata->tail_func(cdata); if(ret == EXCEPTION_RETURN) { puts("Exception!"); return -1; } printf("Result: %d\n", ((t_Int32 *)cdata->params[0])->num); return 0; }