use crate::ns::*; use serde::{Serialize, Deserialize}; use std::rc::Rc; #[derive(Clone, Serialize, Deserialize)] pub struct SwitchStatement { pub location: Location, pub discriminant: Rc, pub cases: Vec, } #[derive(Clone, Serialize, Deserialize)] pub struct Case { pub location: Location, pub labels: Vec, pub directives: Vec>, } #[derive(Clone, Serialize, Deserialize)] pub enum CaseLabel { Case((Rc, Location)), Default(Location), } impl CaseLabel { pub fn location(&self) -> Location { match self { Self::Case((_, l)) => l.clone(), Self::Default(l) => l.clone(), } } } #[derive(Clone, Serialize, Deserialize)] pub struct SwitchTypeStatement { pub location: Location, pub discriminant: Rc, pub cases: Vec, } #[derive(Clone, Serialize, Deserialize)] pub struct TypeCase { pub location: Location, /// Case parameter. If `None`, designates a `default {}` case. pub parameter: Option, pub block: Rc, }