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 ext;
10mod gas;
11#[cfg(feature = "cli")]
12pub mod logger;
13mod optimizer;
14mod symbols;
15
16pub mod stack_height;
17
18pub use ext::{
19 externalize, externalize_mem, shrink_unknown_stack, underscore_funcs, ununderscore_funcs,
20};
21pub use gas::inject_gas_counter;
22pub use optimizer::{optimize, Error as OptimizerError};
23
24pub struct TargetSymbols {
25 pub create: &'static str,
26 pub call: &'static str,
27 pub ret: &'static str,
28}
29
30pub enum TargetRuntime {
31 Substrate(TargetSymbols),
32 PWasm(TargetSymbols),
33}
34
35impl TargetRuntime {
36 pub fn substrate() -> TargetRuntime {
37 TargetRuntime::Substrate(TargetSymbols {
38 create: "deploy",
39 call: "call",
40 ret: "ext_return",
41 })
42 }
43
44 pub fn pwasm() -> TargetRuntime {
45 TargetRuntime::PWasm(TargetSymbols {
46 create: "deploy",
47 call: "call",
48 ret: "ret",
49 })
50 }
51
52 pub fn symbols(&self) -> &TargetSymbols {
53 match self {
54 TargetRuntime::Substrate(s) => s,
55 TargetRuntime::PWasm(s) => s,
56 }
57 }
58}
59
60#[cfg(not(feature = "std"))]
61mod std {
62 pub use ::alloc::{borrow, boxed, string, vec};
63 pub use core::*;
64
65 pub mod rc {
66 pub use alloc::rc::Rc;
67 }
68
69 pub mod collections {
70 pub use alloc::collections::{BTreeMap, BTreeSet};
71 }
72}
73
74#[cfg(feature = "std")]
75mod std {
76 pub use std::*;
77}