add compile_mut and check_mut

This commit is contained in:
Mark 2024-03-22 16:24:10 +01:00
parent f2aad4215c
commit 1e658805d1
2 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "mers_lib" name = "mers_lib"
version = "0.7.1" version = "0.7.2"
edition = "2021" edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
description = "library to use the mers language in other projects" description = "library to use the mers language in other projects"

View File

@ -30,13 +30,25 @@ pub fn compile(
statement: &(impl program::parsed::MersStatement + ?Sized), statement: &(impl program::parsed::MersStatement + ?Sized),
mut info: crate::program::parsed::Info, mut info: crate::program::parsed::Info,
) -> Result<Box<dyn program::run::MersStatement>, CheckError> { ) -> Result<Box<dyn program::run::MersStatement>, CheckError> {
statement.compile(&mut info, CompInfo::default()) compile_mut(statement, &mut info)
}
pub fn compile_mut(
statement: &(impl program::parsed::MersStatement + ?Sized),
info: &mut crate::program::parsed::Info,
) -> Result<Box<dyn program::run::MersStatement>, CheckError> {
statement.compile(info, CompInfo::default())
} }
pub fn check( pub fn check(
statement: &(impl program::run::MersStatement + ?Sized), statement: &(impl program::run::MersStatement + ?Sized),
mut info: crate::program::run::CheckInfo, mut info: crate::program::run::CheckInfo,
) -> Result<Type, CheckError> { ) -> Result<Type, CheckError> {
let o = statement.check(&mut info, None)?; check_mut(statement, &mut info)
}
pub fn check_mut(
statement: &(impl program::run::MersStatement + ?Sized),
info: &mut crate::program::run::CheckInfo,
) -> Result<Type, CheckError> {
let o = statement.check(info, None)?;
let mut err = None; let mut err = None;
for (try_stmt, used) in info.global.unused_try_statements.lock().unwrap().iter() { for (try_stmt, used) in info.global.unused_try_statements.lock().unwrap().iter() {
if used.iter().any(|v| v.is_some()) { if used.iter().any(|v| v.is_some()) {