aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/jq/compile.zig
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-01-17 18:40:47 +0900
committernsfisis <nsfisis@gmail.com>2026-01-17 18:40:47 +0900
commit22a5d1617e79f176ecfca22d6c72be215f0da8b6 (patch)
tree4424a15f2e069aa27312a9e1885d8446ad12bea1 /src/jq/compile.zig
parentd4bacf19b56c21afc7f2f0b5efb244b072873119 (diff)
downloadzgjq-22a5d1617e79f176ecfca22d6c72be215f0da8b6.tar.gz
zgjq-22a5d1617e79f176ecfca22d6c72be215f0da8b6.tar.zst
zgjq-22a5d1617e79f176ecfca22d6c72be215f0da8b6.zip
implement object key access
Diffstat (limited to 'src/jq/compile.zig')
-rw-r--r--src/jq/compile.zig3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/jq/compile.zig b/src/jq/compile.zig
index ddb4be5..0c30a3d 100644
--- a/src/jq/compile.zig
+++ b/src/jq/compile.zig
@@ -5,12 +5,14 @@ const Ast = @import("./parse.zig").Ast;
pub const Opcode = enum {
nop,
array_index,
+ object_key,
literal,
};
pub const Instr = union(Opcode) {
nop,
array_index,
+ object_key: []const u8,
literal: *jv.Value,
pub fn op(self: @This()) Opcode {
@@ -29,6 +31,7 @@ pub fn compile(allocator: std.mem.Allocator, compile_allocator: std.mem.Allocato
try instrs.appendSlice(allocator, index_instrs);
try instrs.append(allocator, .array_index);
},
+ .object_key => |key| try instrs.append(allocator, .{ .object_key = key }),
.literal => |value| try instrs.append(allocator, .{ .literal = value }),
}