stack traces in the brush editor
after 35 thousand years it's finally here good erro message
This commit is contained in:
parent
c1612b2a94
commit
e49885c83a
11 changed files with 710 additions and 150 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
extern crate alloc;
|
||||
|
||||
use core::{alloc::Layout, mem, slice};
|
||||
use core::{alloc::Layout, mem, ptr, slice};
|
||||
|
||||
use alloc::{boxed::Box, string::String, vec::Vec};
|
||||
use haku::{
|
||||
|
@ -12,7 +12,7 @@ use haku::{
|
|||
diagnostic::Diagnostic,
|
||||
lexer::{lex, Lexer},
|
||||
parser::{self, IntoAstError, Parser},
|
||||
source::SourceCode,
|
||||
source::{SourceCode, Span},
|
||||
token::Lexis,
|
||||
};
|
||||
use log::{debug, info};
|
||||
|
@ -449,6 +449,22 @@ unsafe extern "C" fn haku_compile_brush(
|
|||
);
|
||||
debug!("compiling: {closure_spec:?}");
|
||||
|
||||
debug!("bytecode: {:?}", chunk.bytecode);
|
||||
{
|
||||
let mut cursor = 0_usize;
|
||||
for info in &chunk.span_info {
|
||||
let slice = &chunk.bytecode[cursor..cursor + info.len as usize];
|
||||
debug!(
|
||||
"{:?} | 0x{:x} {:?} | {:?}",
|
||||
info.span,
|
||||
cursor,
|
||||
slice,
|
||||
info.span.slice(src.code),
|
||||
);
|
||||
cursor += info.len as usize;
|
||||
}
|
||||
}
|
||||
|
||||
instance.compile_result2 = Some(CompileResult {
|
||||
defs_string: instance.defs.serialize_defs(),
|
||||
tags_string: instance.defs.serialize_tags(),
|
||||
|
@ -528,6 +544,25 @@ unsafe extern "C" fn haku_bytecode(instance: *const Instance) -> *const u8 {
|
|||
unwrap_compile_result(instance).chunk.bytecode.as_ptr()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_bytecode_find_span(instance: *const Instance, pc: u16) -> *const Span {
|
||||
let chunk = &unwrap_compile_result(instance).chunk;
|
||||
match chunk.find_span(pc) {
|
||||
Some(r) => r,
|
||||
None => ptr::null(),
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_span_start(span: *const Span) -> u32 {
|
||||
(*span).start
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_span_end(span: *const Span) -> u32 {
|
||||
(*span).end
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_local_count(instance: *const Instance) -> u8 {
|
||||
unwrap_compile_result(instance).closure_spec.local_count
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue