use serde::{Deserialize, Serialize};
use super::DocComment;
use super::functions::{Annotation, AnnotationDef, ForeignFunctionDef, FunctionDef};
use super::program::Item;
use super::program::{BuiltinFunctionDecl, BuiltinTypeDecl};
use super::span::Span;
use super::types::{EnumDef, InterfaceDef, StructTypeDef, TraitDef};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ImportStmt {
pub items: ImportItems,
pub from: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ImportItems {
Named(Vec<ImportSpec>),
Namespace { name: String, alias: Option<String> },
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ImportSpec {
pub name: String,
pub alias: Option<String>,
#[serde(default)]
pub is_annotation: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExportStmt {
pub item: ExportItem,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub source_decl: Option<super::program::VariableDecl>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ExportItem {
Function(FunctionDef),
BuiltinFunction(BuiltinFunctionDecl),
BuiltinType(BuiltinTypeDecl),
TypeAlias(super::types::TypeAliasDef),
Named(Vec<ExportSpec>),
Enum(EnumDef),
Struct(StructTypeDef),
Interface(InterfaceDef),
Trait(TraitDef),
Annotation(AnnotationDef),
ForeignFunction(ForeignFunctionDef),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExportSpec {
pub name: String,
pub alias: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModuleDecl {
pub name: String,
pub name_span: Span,
#[serde(default)]
pub doc_comment: Option<DocComment>,
pub annotations: Vec<Annotation>,
pub items: Vec<Item>,
}