Mercurial > repos > tabletprog
comparison runtime/object.c @ 45:2a9c6eed0c70
Move closure/lambda object def into compiler rather than runtime code. Add while:do method to lambda
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 13 Jul 2012 00:23:38 -0700 |
parents | bf5e88f6419d |
children | abc6f3d644a4 |
comparison
equal
deleted
inserted
replaced
44:9dd370530f69 | 45:2a9c6eed0c70 |
---|---|
19 } | 19 } |
20 va_end(args); | 20 va_end(args); |
21 return newobj; | 21 return newobj; |
22 } | 22 } |
23 | 23 |
24 object * make_closure(void * env, closure_func func) | |
25 { | |
26 closure * ret = malloc(sizeof(closure)); | |
27 ret->header.meta = &lambda_meta; | |
28 ret->header.parent = NULL; | |
29 ret->env = env; | |
30 ret->func = func; | |
31 return (object *) ret; | |
32 } | |
33 | |
34 object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...) | 24 object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...) |
35 { | 25 { |
36 va_list args; | 26 va_list args; |
37 va_start(args, self); | 27 va_start(args, self); |
38 object * ret = self->meta->meth_lookup[method_id & 0xF](method_id, num_args, self, args); | 28 object * ret = self->meta->meth_lookup[method_id & 0xF](method_id, num_args, self, args); |