1use serde::{Deserialize, Serialize};
4
5use super::DocComment;
6use super::functions::{Annotation, AnnotationDef, ForeignFunctionDef, FunctionDef};
7use super::program::Item;
8use super::program::{BuiltinFunctionDecl, BuiltinTypeDecl};
9use super::span::Span;
10use super::types::{EnumDef, InterfaceDef, StructTypeDef, TraitDef};
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct ImportStmt {
14 pub items: ImportItems,
15 pub from: String,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub enum ImportItems {
20 Named(Vec<ImportSpec>),
22 Namespace { name: String, alias: Option<String> },
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct ImportSpec {
28 pub name: String,
29 pub alias: Option<String>,
30 #[serde(default)]
31 pub is_annotation: bool,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct ExportStmt {
36 pub item: ExportItem,
37 #[serde(default, skip_serializing_if = "Option::is_none")]
40 pub source_decl: Option<super::program::VariableDecl>,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub enum ExportItem {
45 Function(FunctionDef),
47 BuiltinFunction(BuiltinFunctionDecl),
49 BuiltinType(BuiltinTypeDecl),
51 TypeAlias(super::types::TypeAliasDef),
53 Named(Vec<ExportSpec>),
55 Enum(EnumDef),
57 Struct(StructTypeDef),
59 Interface(InterfaceDef),
61 Trait(TraitDef),
63 Annotation(AnnotationDef),
65 ForeignFunction(ForeignFunctionDef),
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct ExportSpec {
71 pub name: String,
72 pub alias: Option<String>,
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct ModuleDecl {
77 pub name: String,
78 pub name_span: Span,
79 #[serde(default)]
80 pub doc_comment: Option<DocComment>,
81 pub annotations: Vec<Annotation>,
82 pub items: Vec<Item>,
83}