mirror of
https://github.com/Dummi26/mers.git
synced 2025-12-31 09:56:19 +01:00
mers rewrite is starting to be usable
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::{
|
||||
data::{self, Data, Type},
|
||||
data::{Data, Type},
|
||||
info::Local,
|
||||
program,
|
||||
};
|
||||
|
||||
mod with_base;
|
||||
mod with_command_running;
|
||||
mod with_get;
|
||||
mod with_iters;
|
||||
mod with_list;
|
||||
mod with_math;
|
||||
mod with_prints;
|
||||
mod with_multithreading;
|
||||
mod with_stdio;
|
||||
|
||||
/// Usage: create an empty Config using Config::new(), use the methods to customize it, then get the Infos using Config::infos()
|
||||
/// bundle_* for bundles (combines multiple groups or even bundles)
|
||||
@@ -27,23 +28,30 @@ pub struct Config {
|
||||
globals: usize,
|
||||
info_parsed: super::parsed::Info,
|
||||
info_run: super::run::Info,
|
||||
info_check: super::run::CheckInfo,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
/// standard utilitis used in many programs
|
||||
/// `bundle_base()`
|
||||
/// `with_stdio()`
|
||||
/// `with_list()`
|
||||
/// `with_command_running()`
|
||||
/// `with_multithreading()`
|
||||
pub fn bundle_std(self) -> Self {
|
||||
self.with_command_running().with_list().bundle_base()
|
||||
self.with_multithreading()
|
||||
.with_command_running()
|
||||
.with_list()
|
||||
.with_stdio()
|
||||
.bundle_base()
|
||||
}
|
||||
/// base utilities used in most programs
|
||||
/// `with_prints()`
|
||||
/// `with_base()`
|
||||
/// `with_math()`
|
||||
/// `with_get()`
|
||||
/// `with_iters()`
|
||||
pub fn bundle_base(self) -> Self {
|
||||
self.with_iters().with_get().with_math().with_prints()
|
||||
self.with_iters().with_get().with_math().with_base()
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
@@ -51,12 +59,15 @@ impl Config {
|
||||
globals: 0,
|
||||
info_parsed: Default::default(),
|
||||
info_run: Default::default(),
|
||||
info_check: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_var(mut self, name: String, val: Data) -> Self {
|
||||
let t = val.get().as_type();
|
||||
self.info_parsed.scopes[0].init_var(name, (0, self.globals));
|
||||
self.info_run.scopes[0].init_var(self.globals, val);
|
||||
self.info_run.scopes[0].init_var(self.globals, Arc::new(Mutex::new(val)));
|
||||
self.info_check.scopes[0].init_var(self.globals, t);
|
||||
self.globals += 1;
|
||||
self
|
||||
}
|
||||
@@ -65,7 +76,7 @@ impl Config {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn infos(self) -> (super::parsed::Info, super::run::Info) {
|
||||
(self.info_parsed, self.info_run)
|
||||
pub fn infos(self) -> (super::parsed::Info, super::run::Info, super::run::CheckInfo) {
|
||||
(self.info_parsed, self.info_run, self.info_check)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user