Skip to main content

vm/compiler/source_loader/
model.rs

1use std::collections::{HashMap, HashSet};
2use std::path::PathBuf;
3
4use super::super::linker::ParsedUnit;
5
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum FrontendImportSyntax {
8    RustScript,
9    JavaScript,
10    Lua,
11}
12
13#[derive(Clone, Debug)]
14pub struct NamedImport {
15    pub imported: String,
16    pub local: String,
17}
18
19#[derive(Clone, Debug)]
20pub enum ImportClause {
21    AllPublic,
22    Named(Vec<NamedImport>),
23    Namespace(String),
24    Prefix(String),
25}
26
27#[derive(Clone, Debug)]
28pub struct ModuleImport {
29    pub spec: String,
30    pub clause: ImportClause,
31    pub line: usize,
32}
33
34#[derive(Clone, Debug, PartialEq, Eq)]
35pub(super) struct ExportedFunctionSignature {
36    pub(super) arity: u8,
37    pub(super) type_params: Vec<String>,
38}
39
40#[derive(Default)]
41pub(super) struct ModuleCollectState {
42    pub(super) visiting: Vec<PathBuf>,
43    pub(super) seen: HashSet<PathBuf>,
44    pub(super) units: Vec<ParsedUnit>,
45    pub(super) module_exports: HashMap<PathBuf, HashMap<String, ExportedFunctionSignature>>,
46}
47pub(super) struct ImportRewriteResult {
48    pub(super) source: String,
49}