haku2: on the client
resource indicators are currently unimplemented
This commit is contained in:
parent
45c954cb03
commit
e667c6336a
10 changed files with 437 additions and 364 deletions
|
@ -48,7 +48,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
.arg("--cache-dir")
|
||||
.arg(out_path.join("zig-cache"))
|
||||
.arg("--prefix")
|
||||
.arg(out_path.join("zig-out").join(target))
|
||||
.arg(out_path.join("zig-out"))
|
||||
// Build settings
|
||||
.arg(format!("-Doptimize={optimize}"))
|
||||
.arg(format!("-Dtarget={target}"))
|
||||
|
@ -58,7 +58,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
panic!("zig failed to build");
|
||||
}
|
||||
|
||||
println!("cargo::rustc-link-search={out_dir}/zig-out/{target}/lib");
|
||||
println!("cargo::rustc-link-search={out_dir}/zig-out/lib");
|
||||
println!("cargo::rustc-link-lib=haku2");
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -10,7 +10,7 @@ const value = @import("value.zig");
|
|||
const Vm = @import("vm.zig");
|
||||
const log = @import("log.zig");
|
||||
|
||||
const debug_logs = false;
|
||||
const debug_logs = true;
|
||||
|
||||
pub const allocator =
|
||||
if (builtin.cpu.arch == .wasm32)
|
||||
|
@ -23,6 +23,16 @@ pub const std_options: std.Options = .{
|
|||
.logFn = log.logFn,
|
||||
};
|
||||
|
||||
// Allocator
|
||||
|
||||
export fn haku2_alloc(size: usize, alignment: usize) ?[*]u8 {
|
||||
return allocator.rawAlloc(size, mem.Alignment.fromByteUnits(alignment), @returnAddress());
|
||||
}
|
||||
|
||||
export fn haku2_free(alloc: [*]u8, size: usize, alignment: usize) void {
|
||||
allocator.rawFree(alloc[0..size], mem.Alignment.fromByteUnits(alignment), @returnAddress());
|
||||
}
|
||||
|
||||
// Scratch
|
||||
|
||||
export fn haku2_scratch_new(max: usize) ?*Scratch {
|
||||
|
|
|
@ -9,6 +9,8 @@ use std::{
|
|||
|
||||
use log::trace;
|
||||
|
||||
pub static WASM: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/zig-out/bin/haku2.wasm"));
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn __haku2_alloc(size: usize, align: usize) -> *mut u8 {
|
||||
if let Ok(layout) = Layout::from_size_align(size, align) {
|
||||
|
|
|
@ -60,7 +60,7 @@ pub fn reset(vm: *Vm, fuel: u32) void {
|
|||
}
|
||||
|
||||
pub fn throw(vm: *Vm, comptime fmt: []const u8, args: anytype) Error {
|
||||
log.debug("throw: fmt={s}", .{fmt});
|
||||
log.info("throw: fmt={s}", .{fmt});
|
||||
|
||||
const Args = @TypeOf(args);
|
||||
const max_args_size = @sizeOf(@TypeOf(vm.exception.?.args));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue