1use serde::{Deserialize, Serialize};
4
5use super::functions::{Annotation, ForeignFunctionDef, FunctionDef};
6use super::program::Item;
7use super::span::Span;
8use super::types::{EnumDef, InterfaceDef, StructTypeDef, TraitDef};
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct ImportStmt {
12 pub items: ImportItems,
13 pub from: String,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub enum ImportItems {
18 Named(Vec<ImportSpec>),
20 Namespace { name: String, alias: Option<String> },
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct ImportSpec {
26 pub name: String,
27 pub alias: Option<String>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct ExportStmt {
32 pub item: ExportItem,
33 #[serde(default, skip_serializing_if = "Option::is_none")]
36 pub source_decl: Option<super::program::VariableDecl>,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub enum ExportItem {
41 Function(FunctionDef),
43 TypeAlias(super::types::TypeAliasDef),
45 Named(Vec<ExportSpec>),
47 Enum(EnumDef),
49 Struct(StructTypeDef),
51 Interface(InterfaceDef),
53 Trait(TraitDef),
55 ForeignFunction(ForeignFunctionDef),
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct ExportSpec {
61 pub name: String,
62 pub alias: Option<String>,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct ModuleDecl {
67 pub name: String,
68 pub name_span: Span,
69 pub annotations: Vec<Annotation>,
70 pub items: Vec<Item>,
71}