Add ERRORK opcode to trigger constant errors

This commit is contained in:
Emanuele Torre authored and Nico Williams committed 2023-08-04 11:47:34 -05:00
1 parent 71941a0d47
commit 5fc5453409
4 files changed
+16

No files matched your search

+7
View File
@@ -144,6 +144,13 @@ block gen_op_simple(opcode op) {
}
block gen_error(jv constant) {
assert(opcode_describe(ERRORK)->flags & OP_HAS_CONSTANT);
inst *i = inst_new(ERRORK);
i->imm.constant = constant;
return inst_block(i);
}
block gen_const(jv constant) {
assert(opcode_describe(LOADK)->flags & OP_HAS_CONSTANT);
inst* i = inst_new(LOADK);
+1
View File
@@ -19,6 +19,7 @@ block gen_location(location, struct locfile*, block);
block gen_noop();
int block_is_noop(block b);
block gen_op_simple(opcode op);
block gen_error(jv constant);
block gen_const(jv constant);
block gen_const_global(jv constant, const char *name);
int block_is_const(block b);
+6
View File
@@ -405,6 +405,12 @@ jv jq_next(jq_state *jq) {
case TOP: break;
case ERRORK: {
jv v = jv_array_get(jv_copy(frame_current(jq)->bc->constants), *pc++);
set_error(jq, jv_invalid_with_msg(v));
goto do_backtrack;
}
case LOADK: {
jv v = jv_array_get(jv_copy(frame_current(jq)->bc->constants), *pc++);
assert(jv_is_valid(v));
+2
View File
@@ -47,3 +47,5 @@ OP(GENLABEL, NONE, 0, 1)
OP(DESTRUCTURE_ALT, BRANCH, 0, 0)
OP(STOREVN, VARIABLE, 1, 0)
OP(ERRORK, CONSTANT, 1, 0)