vlib: add a wasm module, implementing a pure V webassembly seralisation library (#17909)

This commit is contained in:
l-m 2023-04-09 14:55:02 +10:00 committed by GitHub
parent 9658d20f03
commit d2f69472b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 1966 additions and 0 deletions

View file

@ -0,0 +1,29 @@
import wasm
fn main() {
mut m := wasm.Module{}
mut pyth := m.new_function('pythagoras', [.f32_t, .f32_t], [
.f32_t,
])
{
pyth.local_get(0)
pyth.local_get(0)
pyth.mul(.f32_t)
pyth.local_get(1)
pyth.local_get(1)
pyth.mul(.f32_t)
pyth.add(.f32_t)
pyth.sqrt(.f32_t)
pyth.cast(.f32_t, true, .f64_t)
}
m.commit(pyth, true)
mut test := m.new_function('test', [.f32_t], [.f64_t])
{
test.local_get(0)
test.f32_const(10.0)
test.call('pythagoras')
test.cast(.f32_t, true, .f64_t)
}
m.commit(test, true)
print(m.compile().bytestr())
}