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

@@ -1,3 +1,6 @@
// Copyright (c) 2023 l-m.dev. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module wasm
import encoding.leb128
@@ -21,6 +24,34 @@ pub fn constexpr_value[T](v T) ConstExpression {
return expr
}
// constexpr_value_zero returns a constant expression that evaluates to zero.
pub fn constexpr_value_zero(v ValType) ConstExpression {
mut expr := ConstExpression{}
match v {
.i32_t {
expr.i32_const(0)
}
.i64_t {
expr.i64_const(0)
}
.f32_t {
expr.f32_const(0.0)
}
.f64_t {
expr.f64_const(0.0)
}
.funcref_t, .externref_t {
expr.ref_null(RefType(v))
}
.v128_t {
panic('type `v128_t` not permitted in a constant expression')
}
}
return expr
}
// constexpr_ref_null returns a constant expression that evaluates to a null reference.
pub fn constexpr_ref_null(rt RefType) ConstExpression {
mut expr := ConstExpression{}