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