ellie_engine/
utils.rs

1use alloc::string::String;
2#[cfg(feature = "compiler")]
3use alloc::vec::Vec;
4#[cfg(feature = "compiler")]
5use ellie_core::defs::Version;
6#[cfg(feature = "compiler")]
7use ellie_core::warning::Warning;
8#[cfg(feature = "compiler")]
9use ellie_parser::parser::Module;
10#[cfg(feature = "compiler")]
11use ellie_tokenizer::tokenizer::ResolvedImport;
12
13#[cfg(feature = "compiler")]
14/// Compiler output
15/// * warnings `[Vec<Warning>]`
16/// * module `[Module]`
17pub struct CompileOutput {
18    pub warnings: Vec<Warning>,
19    pub module: Module,
20}
21
22/// Main program struct
23pub struct MainProgram {
24    /// Main file content
25    pub file_content: String,
26    /// Main file name
27    pub file_name: String,
28    /// Main file hash
29    pub file_hash: usize,
30    /// Program's main directory
31    pub start_directory: String,
32}
33
34#[cfg(feature = "compiler")]
35#[derive(Clone)]
36/// EllieC settings
37pub struct CompilerSettings {
38    /// Module name
39    pub name: String,
40    /// Main file name
41    pub file_name: String,
42    /// Check module is library
43    pub is_lib: bool,
44    /// Module description
45    pub description: String,
46    /// Enable experimental features for Compiler
47    pub experimental_features: bool,
48    /// Module version
49    pub version: Version,
50    /// ByteCode architecture
51    pub byte_code_architecture: ellie_core::defs::PlatformArchitecture,
52}
53
54/// Repository interface is channel for communication between compiler and code
55#[cfg(feature = "compiler")]
56pub trait ProgramRepository {
57    /// Return main program and its hash
58    /// ## Returns
59    /// [`MainProgram`]
60    fn read_main(&mut self) -> MainProgram;
61
62    /// Read module by name and return ResolvedImport
63    /// ## Parameters
64    /// * `link_module` - Is import a link to module? [`bool`]
65    /// * `current_path` - Current path [`String`]
66    /// * `requested_path` - Requested path [`String`]
67    /// ## Return
68    /// [`ResolvedImport`]
69    fn read_module(
70        &mut self,
71        link_module: bool,
72        current_path: String,
73        requested_path: String,
74    ) -> ResolvedImport;
75}
76
77pub struct ModuleMap {
78    pub module_name: String,
79    pub module_path: Option<String>,
80}