File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff line change 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+
4854typedef 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
6068struct 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
128148extern "C" {
129149#endif
@@ -139,6 +159,8 @@ ObjUpvalue *newUpvalue(Value *slot);
139159struct ObjClass * newClass (ObjString * name );
140160struct ObjInstance * newInstance (struct ObjClass * klass );
141161struct ObjBoundMethod * newBoundMethod (Value receiver , ObjClosure * method );
162+ struct ObjList * newList ();
163+ struct ObjDictionary * newDictionary ();
142164void printObject (Value value );
143165
144166static inline bool isObjType (Value value , ObjType type ) {
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments