2023-05-08 09:31:36 +03:00
|
|
|
// 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.
|
2023-04-09 07:55:02 +03:00
|
|
|
module wasm
|
|
|
|
|
|
|
|
struct ImportCallPatch {
|
|
|
|
mod string
|
|
|
|
name string
|
2023-05-08 09:31:36 +03:00
|
|
|
mut:
|
|
|
|
pos int
|
2023-04-09 07:55:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct FunctionCallPatch {
|
|
|
|
name string
|
2023-05-08 09:31:36 +03:00
|
|
|
mut:
|
|
|
|
pos int
|
2023-04-09 07:55:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type CallPatch = FunctionCallPatch | ImportCallPatch
|
|
|
|
|
2023-04-13 20:39:55 +03:00
|
|
|
struct FunctionGlobalPatch {
|
|
|
|
idx GlobalIndex
|
2023-05-08 09:31:36 +03:00
|
|
|
mut:
|
2023-04-13 20:39:55 +03:00
|
|
|
pos int
|
|
|
|
}
|
|
|
|
|
2023-05-08 09:31:36 +03:00
|
|
|
type FunctionPatch = CallPatch | FunctionGlobalPatch
|
|
|
|
|
|
|
|
struct FunctionLocal {
|
|
|
|
typ ValType
|
|
|
|
name ?string
|
|
|
|
}
|
|
|
|
|
2023-04-13 20:39:55 +03:00
|
|
|
pub struct Function {
|
2023-04-09 07:55:02 +03:00
|
|
|
tidx int
|
|
|
|
idx int
|
|
|
|
mut:
|
2023-05-08 09:31:36 +03:00
|
|
|
patches []FunctionPatch // sorted
|
|
|
|
label int
|
|
|
|
export bool
|
|
|
|
mod &Module = unsafe { nil }
|
|
|
|
code []u8
|
|
|
|
locals []FunctionLocal
|
2023-04-09 07:55:02 +03:00
|
|
|
pub:
|
|
|
|
name string
|
|
|
|
}
|