Skip to content

Commit

Permalink
Merge branch 'main' into fix-fixmes
Browse files Browse the repository at this point in the history
  • Loading branch information
vsbogd authored Nov 28, 2024
2 parents 190619e + f69a717 commit 9f2562a
Show file tree
Hide file tree
Showing 13 changed files with 2,603 additions and 2,435 deletions.
2 changes: 1 addition & 1 deletion lib/src/metta/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::atom::matcher::*;
use crate::space::*;
use crate::metta::*;
use crate::metta::types::*;
use crate::metta::runner::stdlib::IfEqualOp;
use crate::metta::runner::stdlib::core::IfEqualOp;
use crate::common::collections::CowArray;

use std::fmt::{Debug, Display, Formatter};
Expand Down
27 changes: 1 addition & 26 deletions lib/src/metta/runner/arithmetics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,34 +308,9 @@ macro_rules! def_binary_bool_op {
def_binary_bool_op!(AndOp, and, &&);
def_binary_bool_op!(OrOp, or, ||);

// NOTE: xor and flip are absent in Python intentionally for conversion testing
// NOTE: xor is absent in Python intentionally for conversion testing
def_binary_bool_op!(XorOp, xor, ^);

#[derive(Clone, PartialEq, Debug)]
pub struct FlipOp{}

impl Display for FlipOp {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "flip")
}
}

impl Grounded for FlipOp {
fn type_(&self) -> Atom {
Atom::expr([ARROW_SYMBOL, ATOM_TYPE_BOOL])
}

fn as_execute(&self) -> Option<&dyn CustomExecute> {
Some(self)
}
}

impl CustomExecute for FlipOp {
fn execute(&self, _args: &[Atom]) -> Result<Vec<Atom>, ExecError> {
Ok(vec![Atom::gnd(Bool(rand::random()))])
}
}


#[derive(Clone, PartialEq, Debug)]
pub struct NotOp{}
Expand Down
8 changes: 5 additions & 3 deletions lib/src/metta/runner/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use regex::Regex;
use super::interpreter::interpret;
use super::stdlib::*;

use std::mem;

mod mod_names;
pub(crate) use mod_names::{ModNameNode, mod_name_from_path, normalize_relative_module_name, mod_name_remove_prefix, ModNameNodeDisplayWrapper};
#[cfg(feature = "pkg_mgmt")]
Expand Down Expand Up @@ -237,7 +239,7 @@ impl MettaMod {
pub(crate) fn remap_imported_deps(&self, mapping: &HashMap<ModId, ModId>) {
let mut deps = self.imported_deps.lock().unwrap();
let mut temp = HashMap::with_capacity(deps.len());
core::mem::swap(&mut temp, &mut *deps);
mem::swap(&mut temp, &mut *deps);
for (dep_mod_id, space) in temp.into_iter() {
let new_mod_id = match mapping.get(&dep_mod_id) {
Some(mapped_id) => *mapped_id,
Expand Down Expand Up @@ -394,8 +396,8 @@ impl ModuleInitState {
match self {
Self::Root(cell) => {
let mut insides_ref = cell.borrow_mut();
let frames = core::mem::take(&mut insides_ref.frames);
let descriptors = core::mem::take(&mut insides_ref.module_descriptors);
let frames = mem::take(&mut insides_ref.frames);
let descriptors = mem::take(&mut insides_ref.module_descriptors);
(frames, descriptors)
},
_ => unreachable!()
Expand Down
Loading

0 comments on commit 9f2562a

Please sign in to comment.