aboutgitcodelistschat:MatrixIRC
diff options
context:
space:
mode:
-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);
}