aboutgitcodelistschat:MatrixIRC
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-06-05 14:06:33 +0200
committerAlice Frosi <afrosi@redhat.com>2023-06-05 14:06:33 +0200
commit12129d46981106fa0d356cfd6000d6006942f0e4 (patch)
tree51bbac6dd6201fb2e3465d36470d16424714307f
parentc021082abcc9d94c2e94679f6729265fe65529a3 (diff)
downloadseitan-12129d46981106fa0d356cfd6000d6006942f0e4.tar
seitan-12129d46981106fa0d356cfd6000d6006942f0e4.tar.gz
seitan-12129d46981106fa0d356cfd6000d6006942f0e4.tar.bz2
seitan-12129d46981106fa0d356cfd6000d6006942f0e4.tar.lz
seitan-12129d46981106fa0d356cfd6000d6006942f0e4.tar.xz
seitan-12129d46981106fa0d356cfd6000d6006942f0e4.tar.zst
seitan-12129d46981106fa0d356cfd6000d6006942f0e4.zip
cooker: add emit_end
-rw-r--r--cooker/emit.c16
-rw-r--r--cooker/emit.h1
-rw-r--r--cooker/parse.c2
3 files changed, 18 insertions, 1 deletions
diff --git a/cooker/emit.c b/cooker/emit.c
index e2b5461..625ff69 100644
--- a/cooker/emit.c
+++ b/cooker/emit.c
@@ -296,6 +296,22 @@ void emit_copy_field(struct gluten_ctx *g, struct field *field,
field->size ? field->size : gluten_size[field->type]);
}
+/**
+ * emit_end() - Emit OP_END instruction: end of the operation block
+ * @g: gluten context
+ */
+void emit_end(struct gluten_ctx *g)
+{
+ struct op *op = (struct op *)gluten_ptr(&g->g, g->ip);
+
+ op->type = OP_END;
+
+ debug(" %i: OP_END", g->ip.offset);
+
+ if (++g->ip.offset > INST_MAX)
+ die("Too many instructions");
+}
+
static struct gluten_offset emit_data_do(struct gluten_ctx *g,
struct gluten_offset offset,
enum type type, size_t str_len,
diff --git a/cooker/emit.h b/cooker/emit.h
index 31c3378..70ffd72 100644
--- a/cooker/emit.h
+++ b/cooker/emit.h
@@ -26,6 +26,7 @@ void emit_copy(struct gluten_ctx *g,
struct gluten_offset dst, struct gluten_offset src, size_t size);
void emit_copy_field(struct gluten_ctx *g, struct field *field,
struct gluten_offset dst, struct gluten_offset src);
+void emit_end(struct gluten_ctx *g);
struct gluten_offset emit_data(struct gluten_ctx *g, enum type type,
size_t str_len, union value *value);
struct gluten_offset emit_data_at(struct gluten_ctx *g,
diff --git a/cooker/parse.c b/cooker/parse.c
index ab77e6b..81ad159 100644
--- a/cooker/parse.c
+++ b/cooker/parse.c
@@ -234,7 +234,7 @@ static void parse_block(struct gluten_ctx *g, JSON_Object *block)
if (!parser->type)
die(" Invalid rule type: \"%s\"", type);
}
-
+ emit_end(g);
link_block(g);
}