fix haku-wasm/haku.js errors not resetting properly sometimes

This commit is contained in:
liquidex 2024-08-24 18:40:16 +02:00
parent 59a6bda0ba
commit ba89b6eb04
5 changed files with 10 additions and 4 deletions

2
Cargo.lock generated
View file

@ -1179,7 +1179,7 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
[[package]]
name = "rkgk"
version = "0.1.1"
version = "0.2.0"
dependencies = [
"argon2",
"axum",

View file

@ -410,9 +410,12 @@ unsafe extern "C" fn haku_eval_brush(instance: *mut Instance, brush: *const Brus
return StatusCode::OutOfRefSlots;
};
debug!("resetting exception");
instance.exception = None;
instance.value = match instance.vm.run(&instance.system, closure_id) {
Ok(value) => value,
Err(exn) => {
debug!("setting exception {exn:?}");
instance.exception = Some(exn);
return StatusCode::EvalException;
}
@ -429,6 +432,8 @@ unsafe extern "C" fn haku_render_value(
translation_y: f32,
) -> StatusCode {
let instance = &mut *instance;
debug!("resetting exception");
instance.exception = None;
let pixmap_locked = &mut (*pixmap).pixmap;

View file

@ -1,6 +1,6 @@
[package]
name = "rkgk"
version = "0.1.1"
version = "0.2.0"
edition = "2021"
[dependencies]

View file

@ -7,6 +7,7 @@ use std::{
use api::Api;
use axum::Router;
use color_eyre::owo_colors::OwoColorize;
use config::Config;
use copy_dir::copy_dir;
use eyre::Context;

View file

@ -4,6 +4,8 @@ export class Painter {
}
renderBrushToWall(haku, centerX, centerY, wall) {
haku.resetVm();
let evalResult = haku.evalBrush();
if (evalResult.status != "ok")
return { status: "error", phase: "eval", result: evalResult };
@ -23,12 +25,10 @@ export class Painter {
let renderResult = haku.renderValue(chunk.pixmap, x, y);
if (renderResult.status != "ok") {
haku.resetVm();
return { status: "error", phase: "render", result: renderResult };
}
}
}
haku.resetVm();
for (let y = topChunk; y < bottomChunk; ++y) {
for (let x = leftChunk; x < rightChunk; ++x) {