sway_core/language/parsed/
program.rs1use strum::EnumString;
2
3use crate::Engines;
4
5use super::ParseModule;
6
7#[derive(Debug, Clone)]
11pub struct ParseProgram {
12 pub kind: TreeType,
13 pub root: ParseModule,
14}
15
16#[derive(Copy, Clone, Debug, PartialEq, Eq, EnumString)]
20pub enum TreeType {
21 #[strum(serialize = "predicate")]
22 Predicate,
23 #[strum(serialize = "script")]
24 Script,
25 #[strum(serialize = "contract")]
26 Contract,
27 #[strum(serialize = "library")]
28 Library,
29}
30
31impl TreeType {
32 pub const CFG: &'static [&'static str] = &["contract", "library", "predicate", "script"];
33}
34
35impl std::fmt::Display for TreeType {
36 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37 write!(
38 f,
39 "{}",
40 match self {
41 Self::Predicate => "predicate",
42 Self::Script => "script",
43 Self::Contract => "contract",
44 Self::Library => "library",
45 }
46 )
47 }
48}
49
50impl ParseProgram {
51 pub(crate) fn exclude_tests(&mut self, engines: &Engines) {
53 self.root.tree.exclude_tests(engines)
54 }
55}