1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#![cfg_attr(target_arch = "wasm32", no_std)]
#![cfg_attr(all(target_arch = "wasm32", feature = "oom-handler"), feature(alloc_error_handler))]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![deny(dead_code, unused_imports, unused_mut)]
#![warn(missing_docs)]
pub mod env;
pub mod sys;
mod types;
pub use self::types::{Balance, Gas};
#[cfg(all(feature = "wee_alloc", target_arch = "wasm32"))]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[cfg(all(feature = "oom-handler", target_arch = "wasm32"))]
#[alloc_error_handler]
fn oom(_: core::alloc::Layout) -> ! {
unsafe { core::arch::wasm32::unreachable() }
}
#[cfg(target_arch = "wasm32")]
#[panic_handler]
#[allow(unused_variables)]
fn panic(info: &core::panic::PanicInfo) -> ! {
if cfg!(feature = "panic-message") {
if let Some(s) = info.payload().downcast_ref::<&str>() {
env::panic_str(s);
} else {
env::panic_str("unexpected panic occurred");
}
} else {
unsafe { core::arch::wasm32::unreachable() }
}
}