2018-05-15 08:22:29 +08:00
|
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
|
|
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
|
|
|
|
|
|
|
#[cfg(not(feature = "std"))]
|
|
|
|
#[macro_use]
|
|
|
|
extern crate alloc;
|
|
|
|
|
2017-05-04 15:59:22 +03:00
|
|
|
extern crate parity_wasm;
|
2017-09-25 20:14:46 +03:00
|
|
|
extern crate byteorder;
|
2017-05-05 15:51:08 +03:00
|
|
|
#[macro_use] extern crate log;
|
2017-05-04 15:59:22 +03:00
|
|
|
|
2017-07-27 13:38:21 +03:00
|
|
|
pub mod rules;
|
|
|
|
|
2018-08-01 17:26:22 +03:00
|
|
|
mod build;
|
2017-05-04 16:08:57 +03:00
|
|
|
mod optimizer;
|
2017-05-04 17:38:09 +03:00
|
|
|
mod gas;
|
|
|
|
mod symbols;
|
2017-05-05 16:05:21 +03:00
|
|
|
mod ext;
|
2017-06-09 18:33:05 +03:00
|
|
|
mod pack;
|
2017-09-25 20:14:46 +03:00
|
|
|
mod runtime_type;
|
2017-05-04 16:08:57 +03:00
|
|
|
|
2018-02-27 16:52:37 +03:00
|
|
|
pub mod stack_height;
|
|
|
|
|
2018-08-01 17:26:22 +03:00
|
|
|
pub use build::{build, SourceTarget, Error as BuildError};
|
2017-05-09 12:54:16 +03:00
|
|
|
pub use optimizer::{optimize, Error as OptimizerError};
|
2017-05-05 15:51:08 +03:00
|
|
|
pub use gas::inject_gas_counter;
|
2018-02-05 18:20:34 +03:00
|
|
|
pub use ext::{externalize, externalize_mem, underscore_funcs, ununderscore_funcs, shrink_unknown_stack};
|
2018-03-27 17:11:00 +03:00
|
|
|
pub use pack::{pack_instance, Error as PackingError};
|
2017-09-25 20:14:46 +03:00
|
|
|
pub use runtime_type::inject_runtime_type;
|
2018-05-15 08:22:29 +08:00
|
|
|
|
2018-09-30 18:24:36 +01:00
|
|
|
pub struct TargetRuntime {
|
|
|
|
pub create_symbol: &'static str,
|
|
|
|
pub call_symbol: &'static str,
|
|
|
|
pub return_symbol: &'static str,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TargetRuntime {
|
|
|
|
pub fn substrate() -> TargetRuntime {
|
|
|
|
TargetRuntime {
|
|
|
|
create_symbol: "deploy",
|
|
|
|
call_symbol: "call",
|
|
|
|
return_symbol: "ext_return",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn pwasm() -> TargetRuntime {
|
|
|
|
TargetRuntime {
|
|
|
|
create_symbol: "deploy",
|
|
|
|
call_symbol: "call",
|
|
|
|
return_symbol: "ret",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-15 08:22:29 +08:00
|
|
|
#[cfg(not(feature = "std"))]
|
|
|
|
mod std {
|
|
|
|
pub use core::*;
|
|
|
|
pub use alloc::{vec, string, boxed, borrow};
|
|
|
|
|
|
|
|
pub mod collections {
|
2018-07-09 12:32:38 +03:00
|
|
|
pub use alloc::collections::{BTreeMap, BTreeSet};
|
2018-05-15 08:22:29 +08:00
|
|
|
}
|
|
|
|
}
|