diff options
Diffstat (limited to 'src/bytecode/objects.h')
-rwxr-xr-x | src/bytecode/objects.h | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/bytecode/objects.h b/src/bytecode/objects.h index 6c286b5..a9a7d0f 100755 --- a/src/bytecode/objects.h +++ b/src/bytecode/objects.h | |||
@@ -17,6 +17,20 @@ typedef enum ObjectType { | |||
17 | OBJ_TYPE_ERR, | 17 | OBJ_TYPE_ERR, |
18 | } ObjectType; | 18 | } ObjectType; |
19 | 19 | ||
20 | typedef struct Object Object; | ||
21 | |||
22 | typedef struct Closure { | ||
23 | // Non-owning reference to a chunk. | ||
24 | Chunk *chunk; | ||
25 | // Captured values for this closure. | ||
26 | Object *values; | ||
27 | } Closure; | ||
28 | |||
29 | // typdef struct ConsCell { | ||
30 | // struct Object *car; | ||
31 | // struct Object *cdr; | ||
32 | // } ConsCell; | ||
33 | |||
20 | typedef struct Object { | 34 | typedef struct Object { |
21 | ObjectType type; | 35 | ObjectType type; |
22 | bool marked; | 36 | bool marked; |
@@ -29,26 +43,18 @@ typedef struct Object { | |||
29 | char *text; | 43 | char *text; |
30 | 44 | ||
31 | // OBJ_TYPE_PAIR | 45 | // OBJ_TYPE_PAIR |
32 | // struct { | 46 | // ConsCell *cons_cell; |
33 | // struct Object *car; | ||
34 | // struct Object *cdr; | ||
35 | // }; | ||
36 | 47 | ||
37 | // OBJ_TYPE_LAMBDA | 48 | // OBJ_TYPE_LAMBDA |
38 | Chunk *chunk; | 49 | Closure *closure; |
39 | // struct { | ||
40 | // struct Object *params; | ||
41 | // struct Object *body; | ||
42 | // struct Environment *env; | ||
43 | // }; | ||
44 | }; | 50 | }; |
45 | } Object; | 51 | } Object; |
46 | 52 | ||
47 | Object make_string(StringView sv); | 53 | Object make_string(StringView sv); |
48 | Object make_symbol(StringView sv); | 54 | Object make_symbol(StringView sv); |
49 | Object make_lambda(StringView name); | 55 | Object make_lambda(Chunk *chunk); |
50 | void object_display(Object obj); | 56 | void object_display(Object obj); |
51 | void object_free(Object obj); | 57 | void object_free(Object *obj); |
52 | bool object_equal(Object a, Object b); | 58 | bool object_equal(Object a, Object b); |
53 | Object object_copy(Object src); | 59 | Object object_copy(Object src); |
54 | 60 | ||