susy_susy_pwasm_utils/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
2#![cfg_attr(not(feature = "std"), feature(alloc))]
3
4#[cfg(not(feature = "std"))]
5#[macro_use]
6extern crate alloc;
7
8extern crate byteorder;
9extern crate susy_wasm;
10#[macro_use] extern crate log;
11#[cfg(test)] #[macro_use] extern crate indoc;
12
13
14pub mod rules;
15
16mod build;
17mod ext;
18mod gas;
19mod optimizer;
20mod pack;
21mod runtime_type;
22mod graph;
23mod ref_list;
24mod symbols;
25
26pub mod stack_height;
27
28pub use build::{build, Error as BuildError, SourceTarget};
29pub use ext::{
30 externalize, externalize_mem, shrink_unknown_stack, underscore_funcs, ununderscore_funcs,
31};
32pub use gas::inject_gas_counter;
33pub use optimizer::{optimize, Error as OptimizerError};
34pub use pack::{pack_instance, Error as PackingError};
35pub use runtime_type::inject_runtime_type;
36pub use graph::{Module, parse as graph_parse, generate as graph_generate};
37pub use ref_list::{RefList, Entry, EntryRef, DeleteTransaction};
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
52 pub fn substrate() -> TargetRuntime {
53 TargetRuntime::Substrate(TargetSymbols {
54 create: "deploy",
55 call: "call",
56 ret: "ext_return",
57 })
58 }
59
60 pub fn pwasm() -> TargetRuntime {
61 TargetRuntime::PWasm(TargetSymbols {
62 create: "deploy",
63 call: "call",
64 ret: "ret",
65 })
66 }
67
68 pub fn symbols(&self) -> &TargetSymbols {
69 match self {
70 TargetRuntime::Substrate(s) => s,
71 TargetRuntime::PWasm(s) => s,
72 }
73 }
74
75}
76
77#[cfg(not(feature = "std"))]
78mod std {
79 pub use alloc::{borrow, boxed, string, vec};
80 pub use core::*;
81
82 pub mod rc {
83 pub use alloc::rc::Rc;
84 }
85
86 pub mod collections {
87 pub use alloc::collections::{BTreeMap, BTreeSet};
88 }
89}