Skip to content

Commit 50dcf68

Browse files
committed
feat: Implement core runtime components including VM, object system, bytecode generation, garbage collection, and project manifest handling.
1 parent f87cea1 commit 50dcf68

8 files changed

Lines changed: 865 additions & 15 deletions

File tree

include/bytecode.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ typedef enum {
2020
OP_TRUE,
2121
OP_FALSE,
2222
OP_POP,
23+
OP_DUP,
24+
OP_BUILD_LIST,
25+
OP_BUILD_MAP,
26+
OP_GET_INDEX,
27+
OP_SET_INDEX,
2328
OP_GET_LOCAL,
2429
OP_SET_LOCAL,
2530
OP_GET_GLOBAL,

include/object.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
#define IS_BOUND_METHOD(value) isObjType(value, OBJ_BOUND_METHOD)
4646
#define AS_BOUND_METHOD(value) ((struct ObjBoundMethod *)AS_OBJ(value))
4747

48+
#define IS_LIST(value) isObjType(value, OBJ_LIST)
49+
#define AS_LIST(value) ((struct ObjList *)AS_OBJ(value))
50+
51+
#define IS_DICTIONARY(value) isObjType(value, OBJ_DICTIONARY)
52+
#define AS_DICTIONARY(value) ((struct ObjDictionary *)AS_OBJ(value))
53+
4854
typedef enum {
4955
OBJ_STRING,
5056
OBJ_FUNCTION,
@@ -55,6 +61,8 @@ typedef enum {
5561
OBJ_CLASS,
5662
OBJ_INSTANCE,
5763
OBJ_BOUND_METHOD,
64+
OBJ_LIST,
65+
OBJ_DICTIONARY
5866
} ObjType;
5967

6068
struct Obj {
@@ -124,6 +132,18 @@ struct ObjBoundMethod {
124132
ObjClosure *method;
125133
};
126134

135+
struct ObjList {
136+
Obj obj;
137+
int count;
138+
int capacity;
139+
Value *items;
140+
};
141+
142+
struct ObjDictionary {
143+
Obj obj;
144+
Table items;
145+
};
146+
127147
#ifdef __cplusplus
128148
extern "C" {
129149
#endif
@@ -139,6 +159,8 @@ ObjUpvalue *newUpvalue(Value *slot);
139159
struct ObjClass *newClass(ObjString *name);
140160
struct ObjInstance *newInstance(struct ObjClass *klass);
141161
struct ObjBoundMethod *newBoundMethod(Value receiver, ObjClosure *method);
162+
struct ObjList *newList();
163+
struct ObjDictionary *newDictionary();
142164
void printObject(Value value);
143165

144166
static inline bool isObjType(Value value, ObjType type) {

include/vm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "table.h"
1313
#include "importer.h"
1414

15-
#define FRAMES_MAX 64
15+
#define FRAMES_MAX 256
1616
#define STACK_MAX (FRAMES_MAX * 256)
1717

1818
// CallFrame is now defined in common.h

0 commit comments

Comments
 (0)