1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

wasm: add basic debuginfo through name section (#18130)

This commit is contained in:
l-m
2023-05-08 06:31:36 +00:00
committed by GitHub
parent 5bdf94a7bc
commit 3a06b55388
13 changed files with 541 additions and 109 deletions

View File

@ -28,15 +28,15 @@ fn main() {
mut ifexpr := m.new_function('if_expr', [.i32_t], [.i64_t])
{
ifexpr.local_get(0)
ifexpr.c_if([], [.i64_t])
if_blk := ifexpr.c_if([], [.i64_t])
{
ifexpr.i64_const(5000)
}
ifexpr.c_else()
ifexpr.c_else(if_blk)
{
ifexpr.i64_const(-5000)
}
ifexpr.c_end_if()
ifexpr.c_end(if_blk)
}
m.commit(ifexpr, true)
print(m.compile().bytestr())

View File

@ -6,11 +6,11 @@ fn main() {
{
fac.local_get(0)
fac.eqz(.i64_t)
fac.c_if([], [.i64_t])
bif := fac.c_if([], [.i64_t])
{
fac.i64_const(1)
}
fac.c_else()
fac.c_else(bif)
{
{
fac.local_get(0)
@ -23,7 +23,7 @@ fn main() {
}
fac.mul(.i64_t)
}
fac.c_end_if()
fac.c_end(bif)
}
m.commit(fac, true)
print(m.compile().bytestr())

View File

@ -2,14 +2,15 @@ import wasm
fn main() {
mut m := wasm.Module{}
m.enable_debug('vlang')
m.new_function_import('wasi_unstable', 'proc_exit', [.i32_t], [])
m.new_function_import('wasi_unstable', 'fd_write', [.i32_t, .i32_t, .i32_t, .i32_t],
[.i32_t])
m.assign_memory('memory', true, 1, none)
m.new_data_segment(0, [u8(8), 0, 0, 0]) // pointer to string
m.new_data_segment(4, [u8(13), 0, 0, 0]) // length of string
m.new_data_segment(8, 'Hello, WASI!\n'.bytes())
m.new_data_segment('CIOVec.str', 0, [u8(8), 0, 0, 0]) // pointer to string
m.new_data_segment('CIOVec.len', 4, [u8(13), 0, 0, 0]) // length of string
m.new_data_segment(none, 8, 'Hello, WASI!\n'.bytes())
mut func := m.new_function('_start', [], [])
{