Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to latest Zig #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
.version = "0.0.0",
.dependencies = .{
.linenoise = .{
.url = "git+https://github.com/joachimschmidt557/linenoize.git#892957cf06f0be402b970e285b5a14bdd1b012a6",
.hash = "122006320179fc177087b871ce969221d427bc0af08d5b5738f14ac3c436bea6bc04",
.url = "git+https://github.com/joachimschmidt557/linenoize?ref=0.14.x#1398679d3e329f6803dd630c40e89e8873c6893b",
.hash = "12204d720f02e3d783c138c92baf333fddac47f9fe40f9e7051d047e64f15bba6821",
},
},
.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion src/Vm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ fn isNegative(val: *Value) bool {
}

fn getFrame(vm: *Vm, f: *Frame) void {
const cached = vm.frame_cache.popOrNull() orelse return;
const cached = vm.frame_cache.pop() orelse return;
f.stack = cached.s;
f.err_handlers = cached.e;
}
Expand Down
12 changes: 6 additions & 6 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ fn help() !void {
process.exit(0);
}

fn run(gpa: std.mem.Allocator, args: [][]const u8) !void {
fn run(gpa: std.mem.Allocator, args: []const []const u8) !void {
std.debug.assert(args.len > 0);
const file_name = args[0];

var vm = bog.Vm.init(gpa, .{ .import_files = true });
defer vm.deinit();
try vm.addStd();
const S = struct {
var _args: [][]const u8 = undefined;
var _args: []const []const u8 = undefined;

fn argsToBog(ctx: bog.Vm.Context) bog.Vm.Error!*bog.Value {
const ret = try ctx.vm.gc.alloc(.list);
Expand Down Expand Up @@ -116,7 +116,7 @@ const usage_fmt =
\\
;

fn fmt(gpa: std.mem.Allocator, args: [][]const u8) !void {
fn fmt(gpa: std.mem.Allocator, args: []const []const u8) !void {
if (args.len == 0) fatal("expected at least one file", .{});

var any_err = false;
Expand Down Expand Up @@ -186,7 +186,7 @@ fn fatal(comptime msg: []const u8, args: anytype) noreturn {
process.exit(1);
}

fn getFileName(usage_arg: []const u8, args: [][]const u8) []const u8 {
fn getFileName(usage_arg: []const u8, args: []const []const u8) []const u8 {
if (args.len != 1) {
fatal("{s}", .{usage_arg});
}
Expand All @@ -198,7 +198,7 @@ const usage_debug =
\\
;

fn debugDump(gpa: std.mem.Allocator, args: [][]const u8) !void {
fn debugDump(gpa: std.mem.Allocator, args: []const []const u8) !void {
const file_name = getFileName(usage_debug, args);

var errors = bog.Errors.init(gpa);
Expand All @@ -225,7 +225,7 @@ fn debugDump(gpa: std.mem.Allocator, args: [][]const u8) !void {
mod.dump(mod.main, 0);
}

fn debugTokens(gpa: std.mem.Allocator, args: [][]const u8) !void {
fn debugTokens(gpa: std.mem.Allocator, args: []const []const u8) !void {
const file_name = getFileName(usage_debug, args);

const source = std.fs.cwd().readFileAlloc(gpa, file_name, 1024 * 1024) catch |e| switch (e) {
Expand Down
2 changes: 1 addition & 1 deletion src/repl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub const Repl = struct {
const compile = @import("Compiler.zig").compileRepl;

fn init(repl: *Repl, gpa: Allocator) !void {
repl.buffer = try ArrayList(u8).initCapacity(gpa, std.mem.page_size);
repl.buffer = try ArrayList(u8).initCapacity(gpa, std.heap.pageSize());
errdefer repl.buffer.deinit();

if (builtin.os.tag != .windows) {
Expand Down