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 std::fmt::Display for TreeType {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 write!(
34 f,
35 "{}",
36 match self {
37 Self::Predicate => "predicate",
38 Self::Script => "script",
39 Self::Contract => "contract",
40 Self::Library => "library",
41 }
42 )
43 }
44}
45
46impl ParseProgram {
47 pub(crate) fn exclude_tests(&mut self, engines: &Engines) {
49 self.root.tree.exclude_tests(engines)
50 }
51}