1pub mod io;
5pub mod ptr;
7pub mod string;
9pub mod wasm_api;
11
12#[cfg(target_arch = "wasm32")]
13mod wasm_abi;
14
15pub fn panic(code: i64) {
17 panic!("runtime panic with code {code}");
18}
19
20#[macro_export]
22macro_rules! runtime_wasm_functions {
23 ($( $symbol:expr => $export:literal ( $( $param:ident ),* ) -> $result:tt ; )* ) => {
24 &[
25 $(
26 $crate::wasm_api::RuntimeFnDescriptor {
27 symbol: $symbol,
28 export_name: $export,
29 params: &[$($crate::wasm_api::WasmValType::$param),*],
30 result: $crate::runtime_wasm_result_ty!($result),
31 lowering: $crate::wasm_api::LoweringMode::Direct,
32 },
33 )*
34 ]
35 };
36}
37
38#[macro_export]
40macro_rules! runtime_wasm_result_ty {
41 (()) => {
42 None
43 };
44 ($result:ident) => {
45 Some($crate::wasm_api::WasmValType::$result)
46 };
47}
48
49#[derive(Debug, Clone, PartialEq)]
51pub enum Value {
52 Unit,
54 Int(i64),
56 Bool(bool),
58 Slice(Vec<Value>),
60}
61
62pub fn kind_name(value: &Value) -> &'static str {
64 match value {
65 Value::Unit => "Unit",
66 Value::Int(_) => "Int",
67 Value::Bool(_) => "Bool",
68 Value::Slice(_) => "Slice",
69 }
70}
71
72#[cfg(test)]
73mod tests;