1#![cfg_attr(not(feature = "std"), no_std)]
2
3#[cfg(not(feature = "std"))]
4#[macro_use]
5extern crate alloc;
6
7pub mod rules;
8
9mod build;
10#[cfg(feature = "std")]
11mod export_globals;
12mod ext;
13mod gas;
14mod graph;
15#[cfg(feature = "cli")]
16pub mod logger;
17mod optimizer;
18mod pack;
19mod ref_list;
20mod runtime_type;
21mod symbols;
22
23pub mod stack_height;
24
25pub use build::{build, Error as BuildError, SourceTarget};
26#[cfg(feature = "std")]
27pub use export_globals::export_mutable_globals;
28pub use ext::{
29 externalize, externalize_mem, shrink_unknown_stack, underscore_funcs, ununderscore_funcs,
30};
31pub use gas::inject_gas_counter;
32pub use graph::{generate as graph_generate, parse as graph_parse, Module};
33pub use optimizer::{optimize, Error as OptimizerError};
34pub use pack::{pack_instance, Error as PackingError};
35pub use parity_wasm;
36pub use ref_list::{DeleteTransaction, Entry, EntryRef, RefList};
37pub use runtime_type::inject_runtime_type;
38
39pub struct TargetSymbols {
40 pub create: &'static str,
41 pub call: &'static str,
42 pub ret: &'static str,
43}
44
45pub enum TargetRuntime {
46 Substrate(TargetSymbols),
47 PWasm(TargetSymbols),
48}
49
50impl TargetRuntime {
51 pub fn substrate() -> TargetRuntime {
52 TargetRuntime::Substrate(TargetSymbols {
53 create: "deploy",
54 call: "call",
55 ret: "ext_return",
56 })
57 }
58
59 pub fn pwasm() -> TargetRuntime {
60 TargetRuntime::PWasm(TargetSymbols { create: "deploy", call: "call", ret: "ret" })
61 }
62
63 pub fn symbols(&self) -> &TargetSymbols {
64 match self {
65 TargetRuntime::Substrate(s) => s,
66 TargetRuntime::PWasm(s) => s,
67 }
68 }
69}
70
71#[cfg(not(feature = "std"))]
72mod std {
73 pub use ::alloc::{borrow, boxed, string, vec};
74 pub use core::*;
75
76 pub mod rc {
77 pub use alloc::rc::Rc;
78 }
79
80 pub mod collections {
81 pub use alloc::collections::{BTreeMap, BTreeSet};
82 }
83}
84
85#[cfg(feature = "std")]
86mod std {
87 pub use std::*;
88}