chore: bump zig version to 0.16.0
This commit is contained in:
parent
96866ba9ae
commit
e004d00990
13 changed files with 171 additions and 113 deletions
45
src/main.zig
45
src/main.zig
|
|
@ -38,24 +38,19 @@ const FileExtension = enum {
|
|||
inkc,
|
||||
};
|
||||
|
||||
pub fn main() !void {
|
||||
const gpa = debug_allocator.allocator();
|
||||
defer _ = debug_allocator.deinit();
|
||||
|
||||
var arena_allocator = std.heap.ArenaAllocator.init(gpa);
|
||||
defer arena_allocator.deinit();
|
||||
|
||||
const arena = arena_allocator.allocator();
|
||||
const args = try std.process.argsAlloc(gpa);
|
||||
defer std.process.argsFree(gpa, args);
|
||||
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const gpa = init.gpa;
|
||||
const io = init.io;
|
||||
const arena = init.arena.allocator();
|
||||
const args = try init.minimal.args.toSlice(arena);
|
||||
if (args.len < 2) {
|
||||
fatal("Not enough arguments!", .{});
|
||||
}
|
||||
return mainArgs(gpa, arena, args);
|
||||
return mainArgs(io, gpa, arena, args);
|
||||
}
|
||||
|
||||
fn mainArgs(
|
||||
io: std.Io,
|
||||
gpa: std.mem.Allocator,
|
||||
arena: std.mem.Allocator,
|
||||
args_list: []const [:0]const u8,
|
||||
|
|
@ -106,20 +101,20 @@ fn mainArgs(
|
|||
const filename = source_path orelse "<STDIN>";
|
||||
const source_bytes: [:0]const u8 = s: {
|
||||
var f = if (source_path) |p| file: {
|
||||
break :file std.fs.cwd().openFile(p, .{}) catch |err| {
|
||||
break :file std.Io.Dir.cwd().openFile(io, p, .{}) catch |err| {
|
||||
fatal("unable to open file '{s}': {s}", .{ p, @errorName(err) });
|
||||
};
|
||||
} else std.fs.File.stdin();
|
||||
defer if (source_path != null) f.close();
|
||||
} else std.Io.File.stdin();
|
||||
defer if (source_path != null) f.close(io);
|
||||
|
||||
var file_reader: std.fs.File.Reader = f.reader(&stdin_buffer);
|
||||
var file_reader: std.Io.File.Reader = f.reader(io, &stdin_buffer);
|
||||
break :s ink.readSourceFileToEndAlloc(arena, &file_reader) catch |err| {
|
||||
fatal("unable to load file '{s}': {s}", .{ filename, @errorName(err) });
|
||||
};
|
||||
};
|
||||
|
||||
const stderr = std.fs.File.stderr();
|
||||
var stderr_writer = stderr.writer(&stderr_buffer);
|
||||
const stderr = std.Io.File.stderr();
|
||||
var stderr_writer = stderr.writer(io, &stderr_buffer);
|
||||
const io_w = &stderr_writer.interface;
|
||||
const stack_size = 128;
|
||||
|
||||
|
|
@ -175,7 +170,7 @@ fn mainArgs(
|
|||
if (dump_trace) {
|
||||
story.dump_writer = io_w;
|
||||
}
|
||||
return if (!compile_only) run(gpa, &story);
|
||||
return if (!compile_only) run(io, gpa, &story);
|
||||
}
|
||||
},
|
||||
.inkc => {
|
||||
|
|
@ -183,16 +178,16 @@ fn mainArgs(
|
|||
.stack_size = stack_size,
|
||||
});
|
||||
defer story.deinit();
|
||||
return if (!compile_only) run(gpa, &story);
|
||||
return if (!compile_only) run(io, gpa, &story);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn run(_: std.mem.Allocator, story: *Story) !void {
|
||||
const stdin = std.fs.File.stdin();
|
||||
var stdin_reader = stdin.reader(&stdin_buffer);
|
||||
const stdout = std.fs.File.stdin();
|
||||
var stdout_writer = stdout.writer(&stdout_buffer);
|
||||
fn run(io: std.Io, _: std.mem.Allocator, story: *Story) !void {
|
||||
const stdin = std.Io.File.stdin();
|
||||
var stdin_reader = stdin.reader(io, &stdin_buffer);
|
||||
const stdout = std.Io.File.stdin();
|
||||
var stdout_writer = stdout.writer(io, &stdout_buffer);
|
||||
const reader = &stdin_reader.interface;
|
||||
const writer = &stdout_writer.interface;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue