lang: current state idk try to parallelize

This commit is contained in:
Schrottkatze 2024-06-10 09:47:48 +02:00
parent 3e2c5946c8
commit 37651a83bc
Signed by: schrottkatze
SSH key fingerprint: SHA256:hXb3t1vINBFCiDCmhRABHX5ocdbLiKyCdKI4HK2Rbbc
11 changed files with 522 additions and 15 deletions

47
crates/lang/src/world.rs Normal file
View file

@ -0,0 +1,47 @@
use std::{
fmt::Display,
path::{Path, PathBuf},
};
use crate::world::world_creation_pool::WorldCreationPool;
use self::{files::Files, registry::Registry};
pub mod error;
pub mod files;
pub mod modules;
pub mod nodes;
pub mod registry;
mod world_creation_pool;
pub struct World {}
impl World {
pub fn new(entry_point: &Path) -> Result<Self, WorldCreationError> {
let files = Files::new();
let reg = Registry::new();
let (entry_point_id, errors) = files.add_and_parse(entry_point).map_err(|e| {
WorldCreationError::FailedToOpenEntryPoint(entry_point.to_path_buf(), e)
})?;
let pool = WorldCreationPool::new(files, reg);
todo!()
}
}
#[derive(Debug)]
pub enum WorldCreationError {
FailedToOpenEntryPoint(PathBuf, std::io::Error),
}
impl Display for WorldCreationError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
WorldCreationError::FailedToOpenEntryPoint(entry_path, e) => {
write!(f, "failed to open entry_point '{entry_path:?}': {e}")
}
}
}
}