comparison runtime/object.h @ 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 e7be612fd3ae
children 18598163e3ef
comparison
equal deleted inserted replaced
44:9dd370530f69 45:2a9c6eed0c70
13 } object; 13 } object;
14 14
15 typedef object * (*method)(uint32_t method_id, uint32_t num_args, object * self, va_list args); 15 typedef object * (*method)(uint32_t method_id, uint32_t num_args, object * self, va_list args);
16 16
17 typedef object * (*closure_func)(void *, uint32_t, ...); 17 typedef object * (*closure_func)(void *, uint32_t, ...);
18 18 /*
19 typedef struct closure 19 typedef struct closure
20 { 20 {
21 object header; 21 object header;
22 void * env; 22 void * env;
23 closure_func func; 23 closure_func func;
24 } closure; 24 } closure;
25 25 */
26 struct obj_meta 26 struct obj_meta
27 { 27 {
28 uint32_t size; 28 uint32_t size;
29 method meth_lookup[16]; 29 method meth_lookup[16];
30 }; 30 };
31 31
32 extern obj_meta lambda_meta; 32 extern obj_meta lambda_meta;
33 33
34 object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...); 34 object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...);
35 #define ccall(clos, num_args, ...) (((closure *)clos)->func(((closure *)clos)->env, num_args,##__VA_ARGS__)) 35 #define ccall(clos, num_args, ...) (((lambda *)clos)->func(((lambda *)clos)->env, num_args,##__VA_ARGS__))
36 36
37 object * make_object(obj_meta * meta, void * parent, int num_props, ...); 37 object * make_object(obj_meta * meta, void * parent, int num_props, ...);
38 object * make_closure(void * env, closure_func func); 38 object * make_lambda(void * env, closure_func func);
39 object * make_array(uint32_t num_els, ...); 39 object * make_array(uint32_t num_els, ...);
40 40
41 #endif //OBJECT_H_ 41 #endif //OBJECT_H_