diff options
author | ubq323 <ubq323@ubq323.website> | 2024-06-26 22:45:16 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-06-26 22:45:16 +0100 |
commit | a559125a2d7af771784614b7a2092cc7fb707345 (patch) | |
tree | 4e4f31197d28a41b5c62fdd19086295cf0acad84 /com.c | |
parent | 2e62b41072738142dea9f0b5dd5d2d22455c7616 (diff) |
array literals
Diffstat (limited to 'com.c')
-rw-r--r-- | com.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -38,6 +38,7 @@ static int stack_effect_of(Op opcode) { case OP_NIL: case OP_TRUE: case OP_FALSE: + case OP_ARRNEW: return 1; case OP_SKIP: case OP_REDO: @@ -55,6 +56,7 @@ static int stack_effect_of(Op opcode) { case OP_CMP: case OP_EQU: case OP_MOD: + case OP_ARRAPPEND: return -1; // these ones depend on their argument. handle them specifically @@ -402,6 +404,16 @@ static void compile_node(Compiler *C, AstNode a) { compile_byte(C, compile_constant(C, VAL_OBJ(o))); break; } + case AST_ARR: { + compile_opcode(C, OP_ARRNEW); + AstVec v = a.as.list; + for (int i = 0; i < v.len; i++) { + compile_node(C, v.vals[i]); + compile_opcode(C, OP_ARRAPPEND); + } + break; + } + case AST_LIST: { AstVec l = a.as.list; |