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