1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::allocator::{Allocator, NodePtr};
use crate::chia_dialect::ClvmFlags;
use crate::cost::Cost;
use crate::reduction::Response;
/// The set of operators that are available in the dialect.
#[repr(u32)]
#[derive(Clone, Copy, Eq, PartialEq)]
pub enum OperatorSet {
/// Any softfork extensions that are not added yet will be rejected.
Default,
/// Originally added BLS operators when inside softfork extension 0.
/// The operators have since been hardforked into the main operator set.
Bls,
/// The keccak256 operator, which is only available inside the softfork guard.
/// This uses softfork extension 1, which does not conflict with the BLS fork.
Keccak,
}
pub trait Dialect {
fn quote_kw(&self) -> u32;
fn apply_kw(&self) -> u32;
fn softfork_kw(&self) -> u32;
fn softfork_extension(&self, ext: u32) -> OperatorSet;
fn flags(&self) -> ClvmFlags;
fn gc_candidate(&self, allocator: &Allocator, op: NodePtr) -> bool;
fn op(
&self,
allocator: &mut Allocator,
op: NodePtr,
args: NodePtr,
max_cost: Cost,
extensions: OperatorSet,
) -> Response;
fn allow_unknown_ops(&self) -> bool;
}