comparison runtime/context.c @ 56:d2f9b0a9403d

Initial experiment with goto and switch
author Mike Pavone <pavone@retrodev.com>
date Thu, 08 Oct 2009 01:52:38 -0400
parents 640f541e9116
children 04baa003de5a
comparison
equal deleted inserted replaced
38:7f05bbe82f24 56:d2f9b0a9403d
16 context * new_context() 16 context * new_context()
17 { 17 {
18 context * c = malloc(sizeof(context)); 18 context * c = malloc(sizeof(context));
19 c->stack_begin = new_stack(); 19 c->stack_begin = new_stack();
20 c->current_stack = c->stack_begin; 20 c->current_stack = c->stack_begin;
21 c->unwind = NULL;
22 return c; 21 return c;
23 } 22 }
24 23
25 void * alloc_stack(context * ct, uint32_t size) 24 void * alloc_stack(context * ct, uint32_t size)
26 { 25 {
49 ret = current->data + current->used; 48 ret = current->data + current->used;
50 current->used += size; 49 current->used += size;
51 return ret; 50 return ret;
52 } 51 }
53 52
54 calldata * alloc_cdata(context * ct, uint32_t num_params) 53 calldata * alloc_cdata(context * ct, calldata * lastframe, uint32_t num_params)
55 { 54 {
56 calldata * out = alloc_stack(ct, sizeof(calldata)+(num_params-1)*sizeof(object *)); 55 calldata * retval = (calldata *)(((char *)alloc_stack(ct, sizeof(calldata)+(num_params-1)*sizeof(object *))) + sizeof(object *)*(num_params-1));
57 if(out) 56 retval->lastframe = lastframe;
58 out->ct = ct; 57 return retval;
59 return out;
60 } 58 }
61 59
62 void free_stack(context * ct, void * data) 60 void free_stack(context * ct, void * data)
63 { 61 {
64 char * cdata = data; 62 char * cdata = data;