aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/jq/compile.zig
blob: d81f8ac3aca1296f73ad05b602ee1c433d58ffc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const std = @import("std");
const Ast = @import("./parse.zig").Ast;

pub const Opcode = enum {
    nop,
    identity,
};

pub const Instr = struct {
    op: Opcode,
};

pub fn compile(allocator: std.mem.Allocator, compile_allocator: std.mem.Allocator, ast: *const Ast) ![]Instr {
    _ = compile_allocator;
    var instrs = try std.array_list.Aligned(Instr, null).initCapacity(allocator, 16);

    switch (ast.kind) {
        .identity => try instrs.append(allocator, .{ .op = .identity }),
    }

    return instrs.toOwnedSlice(allocator);
}