diff --git a/Cargo.lock b/Cargo.lock index c0bd0a2d4..f3c8028e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -211,7 +211,6 @@ dependencies = [ "derivative", "do-notation", "encoding8", - "env_logger", "getrandom", "hex", "indoc 1.0.9", @@ -219,7 +218,6 @@ dependencies = [ "lazy_static", "lfsr", "linked-hash-map", - "log", "num", "num-bigint", "num-traits", @@ -408,27 +406,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3144e455c7aeda487c72555cac2ef84ccac173b29a57b07382ba27016e57b246" -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" -dependencies = [ - "env_filter", - "humantime", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -551,12 +528,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "indexmap" version = "2.1.0" diff --git a/Cargo.toml b/Cargo.toml index 7c516dfa4..a1fcaf2ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,8 +33,6 @@ serde_json = "1.0" sha2 = "0.9.5" tempfile = "3.10.1" clvmr = { version = "0.3.2", features = ["pre-eval"] } -env_logger = { version = "0.11.3", features = ["humantime","regex"], default-features=false } -log = "0.4.17" binascii = "0.1.4" yaml-rust = "0.4" linked-hash-map = "0.5.6" diff --git a/src/classic/bins/repl.rs b/src/classic/bins/repl.rs index 0126ef2a4..c29ff1fe1 100644 --- a/src/classic/bins/repl.rs +++ b/src/classic/bins/repl.rs @@ -8,12 +8,9 @@ use clvm_rs::allocator::Allocator; use clvm_tools_rs::compiler::compiler::DefaultCompilerOpts; use clvm_tools_rs::compiler::repl::Repl; -use clvm_tools_rs::classic::clvm_tools::log; use clvm_tools_rs::classic::clvm_tools::stages::stage_0::DefaultProgramRunner; fn main() { - log::init(); - let mut allocator = Allocator::new(); let runner = Rc::new(DefaultProgramRunner::new()); let opts = Rc::new(DefaultCompilerOpts::new("*program*")); diff --git a/src/classic/clvm_tools/cmds.rs b/src/classic/clvm_tools/cmds.rs index 0b791f9e3..6db9f4c3c 100644 --- a/src/classic/clvm_tools/cmds.rs +++ b/src/classic/clvm_tools/cmds.rs @@ -36,7 +36,6 @@ use crate::classic::clvm_tools::debug::{ trace_to_text, }; use crate::classic::clvm_tools::ir::reader::read_ir; -use crate::classic::clvm_tools::log; use crate::classic::clvm_tools::sha256tree::sha256tree; use crate::classic::clvm_tools::stages; use crate::classic::clvm_tools::stages::stage_0::{ @@ -319,8 +318,6 @@ impl ArgumentValueConv for OperatorsVersion { } pub fn run(args: &[String]) { - log::init(); - let mut s = Stream::new(None); launch_tool(&mut s, args, "run", 2); io::stdout() @@ -503,8 +500,6 @@ pub fn cldb_hierarchy( } pub fn cldb(args: &[String]) { - log::init(); - let tool_name = "cldb".to_string(); let props = TArgumentParserProps { description: "Execute a clvm script.".to_string(), diff --git a/src/classic/clvm_tools/log.rs b/src/classic/clvm_tools/log.rs deleted file mode 100644 index 5af0327c8..000000000 --- a/src/classic/clvm_tools/log.rs +++ /dev/null @@ -1,12 +0,0 @@ -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering; - -lazy_static! { - pub static ref LOG_INIT: AtomicUsize = AtomicUsize::new(0); -} - -pub fn init() { - if LOG_INIT.fetch_add(1, Ordering::SeqCst) == 0 { - env_logger::init(); - } -} diff --git a/src/classic/clvm_tools/mod.rs b/src/classic/clvm_tools/mod.rs index 35a18b6ab..a5bd88464 100644 --- a/src/classic/clvm_tools/mod.rs +++ b/src/classic/clvm_tools/mod.rs @@ -4,7 +4,6 @@ pub mod cmds; pub mod curry; pub mod debug; pub mod ir; -pub mod log; pub mod node_path; pub mod pattern_match; pub mod sha256tree; diff --git a/src/compiler/frontend.rs b/src/compiler/frontend.rs index 4c5115ea1..bd199dfed 100644 --- a/src/compiler/frontend.rs +++ b/src/compiler/frontend.rs @@ -3,7 +3,6 @@ use std::collections::HashMap; use std::collections::HashSet; use std::rc::Rc; -use log::debug; use num_bigint::ToBigInt; use crate::classic::clvm::__type_compatibility__::{bi_one, bi_zero}; @@ -1239,7 +1238,6 @@ pub fn compile_helperform( } else if matched.op_name == "deftype".as_bytes().to_vec() { let parsed_chia = parse_chia_type(matched.orig)?; let mut helpers = generate_type_helpers(&parsed_chia); - debug!("parsed_chia {:?}", parsed_chia); let new_form = match &parsed_chia { ChiaType::Abstract(l, n) => HelperForm::Deftype(DeftypeData { kw: matched.opl, @@ -1327,7 +1325,6 @@ impl ModCompileForms for ModAccum { let mut mc = self.clone(); if let Some(helpers) = compile_helperform(opts.clone(), body.clone())? { for form in helpers.new_helpers.iter() { - debug!("process helper {}", decode_string(form.name())); mc = mc.add_helper(form.clone()); } Ok(mc) diff --git a/src/compiler/typechia.rs b/src/compiler/typechia.rs index 0ca45741e..60e419df7 100644 --- a/src/compiler/typechia.rs +++ b/src/compiler/typechia.rs @@ -2,8 +2,6 @@ use std::borrow::Borrow; use std::collections::HashMap; use std::rc::Rc; -use log::debug; - use num_bigint::ToBigInt; use clvmr::allocator::Allocator; @@ -827,10 +825,6 @@ impl Context { } let exists_solved = ContextElim::CExistsSolved(TypeVar(tname.clone(), deft.loc.clone()), result_ty); - debug!( - "struct exists_solved {}", - exists_solved.to_sexp().to_string() - ); context = context.appends_wf(vec![exists_solved]); } } diff --git a/src/compiler/types/ast.rs b/src/compiler/types/ast.rs index 304b5543e..8b502b45f 100644 --- a/src/compiler/types/ast.rs +++ b/src/compiler/types/ast.rs @@ -5,7 +5,6 @@ use std::borrow::Borrow; use std::hash::{Hash, Hasher}; use std::rc::Rc; -use log::debug; use serde::Serialize; use crate::compiler::srcloc::{HasLoc, Srcloc}; @@ -282,17 +281,10 @@ impl GContext { .iter() .position(|e| *e == m) .map(|idx| { - let res = ( + ( GContext(res.0[..idx].to_vec()), GContext(res.0[idx + 1..].to_vec()), - ); - debug!( - "break_marker {} {} from {}", - m.to_sexp().to_string(), - res.0.to_sexp().to_string(), - res.1.to_sexp().to_string() - ); - res + ) }) .unwrap_or_else(|| (GContext(Vec::new()), GContext(res.0.clone())))) } diff --git a/src/compiler/types/context.rs b/src/compiler/types/context.rs index c261c449a..28dd3cc99 100644 --- a/src/compiler/types/context.rs +++ b/src/compiler/types/context.rs @@ -1,8 +1,6 @@ // Based on MIT licensed code from // https://github.com/kwanghoon/bidi -use log::Level::Debug; -use log::{debug, log_enabled}; use std::borrow::Borrow; use std::collections::HashSet; use std::rc::Rc; @@ -153,11 +151,6 @@ impl Context { // If tau is a simple recursive definition then alpha should // appear in it. Backstop alpha free in tau. gamma.0.insert(0, ContextElim::CExists(alpha)); - debug!( - "gonna check typewf on {} in {}", - tau.to_sexp().to_string(), - gamma.to_sexp().to_string() - ); no_existentials && gamma.typewf(&tau) } ContextElim::CMarker(alpha) => { @@ -184,7 +177,6 @@ impl Context { unrecurse(&new_tvar, t1, t2, &finished_type_rec) .and_then(|finished_type| monotype(&finished_type)) .map(|tmono| { - debug!("tabls unrecurse"); let new_ctx = self.appends_wf(vec![ContextElim::CExistsSolved( new_tvar.clone(), tmono, @@ -214,25 +206,14 @@ impl Context { Type::TForall(alpha, a) => self.snoc_wf(ContextElim::CForall(alpha.clone())).typewf(a), Type::TExists(alpha) => self.existentials().elem(alpha), Type::TAbs(s, t) => { - debug!( - "typewf {} {}?", - s.to_sexp().to_string(), - t.to_sexp().to_string() - ); let checktype: Type = Type::TForall(s.clone(), Rc::new(polytype(t.borrow()))); self.typewf(&checktype) } Type::TApp(t1, t2) => { - debug!("check well formed {}", t1.to_sexp().to_string()); if !self.typewf(t1.borrow()) { return false; } - debug!( - "check_newtype {} {}", - t1.to_sexp().to_string(), - t2.to_sexp().to_string() - ); let t1poly = polytype(t1.borrow()); let t2poly = polytype(t2.borrow()); if let Some((nt, ctx)) = self.newtype::(&t1poly, &t2poly) { @@ -292,24 +273,12 @@ impl Context { pub fn insert_at(&self, c: &TypeVar, theta: Context) -> Context { let (gamma_l, gamma_r) = self.inspect_context(c); - debug!( - "insert_at {} left {}", - c.to_sexp().to_string(), - gamma_l.to_sexp().to_string() - ); - debug!( - "insert_at {} right {}", - c.to_sexp().to_string(), - gamma_r.to_sexp().to_string() - ); let mut result_list = gamma_r.0; let mut theta_copy = theta.0; let mut gamma_l_copy = gamma_l.0; result_list.append(&mut theta_copy); result_list.append(&mut gamma_l_copy); - let res = Context::new_wf(result_list); - debug!("insert_at {}", res.to_sexp().to_string()); - res + Context::new_wf(result_list) } pub fn apply_(&self, visited: &mut HashSet, typ: &Polytype) -> Polytype { @@ -318,7 +287,6 @@ impl Context { return typ.clone(); } - debug!("apply {}", typ.to_sexp().to_string()); visited.insert(typ.clone()); match typ { @@ -365,27 +333,15 @@ impl GContext { &self, v: Vec>, ) -> GContext { - let gamma = self.appends(v); - if log_enabled!(Debug) && !gamma.wf() { - panic!("not well formed {}", gamma.to_sexp()); - } - gamma + self.appends(v) } pub fn snoc_wf(&self, c: ContextElim) -> GContext { - let gamma = self.snoc(c); - if log_enabled!(Debug) && !gamma.wf() { - panic!("not well formed {}", gamma.to_sexp()); - } - gamma + self.snoc(c) } pub fn new_wf(elems: Vec>) -> GContext { - let ctx = GContext(elems); - if log_enabled!(Debug) && !ctx.wf() { - panic!("not well formed {}", ctx.to_sexp()); - } - ctx + GContext(elems) } pub fn drop_marker( @@ -399,24 +355,11 @@ impl GContext { { let marked = self.snoc_wf(m.clone()); let res: GContext = f(marked).map(|x| x.extract())?; - debug!("drop_marker, got back {}", res.to_sexp().to_string()); Ok(res .0 .iter() .position(|e| *e == m) - .map(|idx| { - let out = GContext(res.0[idx + 1..].to_vec()); - debug!( - "drop_marker, index {} D {} K {}", - idx, - GContext(res.0[..idx].to_vec()).to_sexp().to_string(), - out.to_sexp().to_string() - ); - out - }) - .unwrap_or_else(|| { - debug!("drop_marker; not found: {}", m.to_sexp().to_string()); - GContext(Vec::new()) - })) + .map(|idx| GContext(res.0[idx + 1..].to_vec())) + .unwrap_or_else(|| GContext(Vec::new()))) } } diff --git a/src/compiler/types/theory.rs b/src/compiler/types/theory.rs index 589be4daa..79d3b0da9 100644 --- a/src/compiler/types/theory.rs +++ b/src/compiler/types/theory.rs @@ -1,10 +1,8 @@ // Based on MIT licensed code from // https://github.com/kwanghoon/bidi -use log::debug; use std::borrow::Borrow; use std::rc::Rc; -use std::sync::atomic::{AtomicUsize, Ordering}; use num_bigint::ToBigInt; @@ -21,27 +19,8 @@ use crate::compiler::types::context::subst; use crate::compiler::types::context::HasElem; use crate::compiler::types::namegen::{fresh_tvar, fresh_var}; -lazy_static! { - pub static ref INDENT_LEVEL: AtomicUsize = AtomicUsize::new(0); -} - const ORIGINAL: bool = true; -fn indented(f: F) -> R -where - F: FnOnce() -> R, -{ - INDENT_LEVEL.fetch_add(1, Ordering::SeqCst); - let res = f(); - INDENT_LEVEL.fetch_add(usize::MAX, Ordering::SeqCst); - res -} - -fn i() -> String { - let count = INDENT_LEVEL.fetch_add(0, Ordering::SeqCst); - " ".repeat(count * 3) -} - pub trait TypeTheory { fn solve(&self, alpha: &TypeVar, tau: &Monotype) -> Result, CompileErr>; fn subtype(&self, typ1: &Polytype, typ2: &Polytype) -> Result, CompileErr>; @@ -60,14 +39,8 @@ impl Context { old: &Monotype, tau: &Monotype, ) -> Result<(Monotype, Box), CompileErr> { - debug!( - "combine {} and {} to increase information", - old.to_sexp().to_string(), - tau.to_sexp().to_string() - ); match (&old, tau) { (Type::TNullable(a), Type::TNullable(b)) => { - debug!("check nullable nullable"); let (ty, ctx) = self.increase_type_specificity(a.borrow(), b.borrow())?; Ok((Type::TNullable(Rc::new(ty)), ctx)) } @@ -82,17 +55,13 @@ impl Context { (_, Type::TExists(_)) => { let r1 = self.reify(&polytype(old), None); let r2 = self.reify(&polytype(tau), None); - debug!("do subtype"); let ctx = self.subtype(&polytype(&r2), &polytype(&r1))?; - debug!("done subtype {}", ctx.to_sexp().to_string()); Ok((old.clone(), ctx)) } (Type::TExists(_), _) => { let r1 = self.reify(&polytype(old), None); let r2 = self.reify(&polytype(tau), None); - debug!("do subtype"); let ctx = self.subtype(&polytype(&r2), &polytype(&r1))?; - debug!("done subtype {}", ctx.to_sexp().to_string()); Ok((tau.clone(), ctx)) } (Type::TUnit(_), _) => Ok(( @@ -135,7 +104,6 @@ impl Context { if let Some(old) = self.find_solved(alpha) { self.increase_type_specificity(&old, tau) } else { - debug!("not solved {}, no increase", tau.to_sexp().to_string()); Ok((tau.clone(), Box::new(self.clone()))) } } @@ -144,18 +112,9 @@ impl Context { // We must respect the extensionality rules in bidir section 4. // This means "increasing information" in the combined context. pub fn solve_(&self, alpha: &TypeVar, tau: &Monotype) -> Result, CompileErr> { - debug!( - "{}solve increase {} for {}", - i(), - alpha.to_sexp().to_string(), - tau.to_sexp().to_string() - ); let (new_tau, gamma1) = self.increase_specificity(alpha, tau)?; - debug!("{}now figure out", i()); let (gamma_l, gamma_r) = gamma1.inspect_context(alpha); let fa: ContextElim = ContextElim::CForall(alpha.clone()); - debug!("{}gamma_l {}", i(), gamma_l.to_sexp().to_string()); - debug!("{}gamma_r {}", i(), gamma_r.to_sexp().to_string()); if gamma_l.typewf(tau) { let mut gammaprime: Vec> = gamma_r.0.iter().filter(|x| *x != &fa).cloned().collect(); @@ -163,12 +122,6 @@ impl Context { gammaprime.push(ContextElim::CExistsSolved(alpha.clone(), new_tau)); gammaprime.append(&mut gamma_l_copy); let ctx = Context::new_wf(gammaprime.clone()); - debug!( - "{}solve {} context {}", - i(), - fa.to_sexp().to_string(), - ctx.to_sexp().to_string() - ); Ok(Some(ctx)) } else { Ok(None) @@ -189,7 +142,6 @@ impl Context { self.checkwftype(typ2)?; match (typ1, typ2) { (Type::TVar(alpha), Type::TVar(alphaprime)) => { - debug!("case 1"); if alpha == alphaprime { return Ok(Box::new(self.clone())); } @@ -203,27 +155,22 @@ impl Context { return Ok(Box::new(self.clone())); } (Type::TUnit(_), Type::TUnit(_)) => { - debug!("case 2"); return Ok(Box::new(self.clone())); } (Type::TAtom(_, _), Type::TAtom(_, None)) => { - debug!("case Atom"); return Ok(Box::new(self.clone())); } (Type::TAtom(_, x), Type::TAtom(_, y)) => { - debug!("case Atom with sizes"); if x == y { return Ok(Box::new(self.clone())); } } (Type::TFun(a1, a2), Type::TFun(b1, b2)) => { - debug!("case 5"); let theta = self.subtype(b1, a1)?; return theta.subtype(&theta.apply(a2), &theta.apply(b2)); } (Type::TNullable(a), Type::TNullable(b)) => { - debug!("case nullable"); return self.subtype(a, b); } @@ -236,12 +183,10 @@ impl Context { } (Type::TExec(a), Type::TExec(b)) => { - debug!("exec"); return self.subtype(a, b); } (Type::TPair(a1, a2), Type::TPair(b1, b2)) => { - debug!("case 6"); let theta = self.subtype(a1, b1)?; return theta.subtype(a2, b2); } @@ -250,7 +195,6 @@ impl Context { (a, Type::TForall(alpha, b)) => { let alphaprime = fresh_tvar(typ2.loc()); let subst_res = type_subst(&Type::TVar(alphaprime.clone()), &alpha.clone(), b); - debug!("case 7 a' = {}", alphaprime.to_sexp().to_string()); return self .drop_marker(ContextElim::CForall(alphaprime), |gamma| { gamma.subtype(a, &subst_res) @@ -260,7 +204,6 @@ impl Context { // <:forallL (Type::TForall(alpha, a), b) => { - debug!("case 8"); let alphaprime = fresh_tvar(typ1.loc()); let subst_res = type_subst( &Type::TExists(alphaprime.clone()), @@ -277,24 +220,19 @@ impl Context { } (a, Type::TApp(t1, t2)) => { - debug!("case TApp"); if let Some((t, ctx)) = self.newtype::(t1.borrow(), t2.borrow()) { - debug!("new context {}", ctx.to_sexp().to_string()); return ctx.subtype(a, &t); } } (Type::TApp(t1, t2), a) => { - debug!("case reflected TApp"); if let Some((t, ctx)) = self.newtype::(t1.borrow(), t2.borrow()) { - debug!("new context {}", ctx.to_sexp().to_string()); return ctx.subtype(&t, a); } } // <:instantiateL (Type::TExists(alpha), a) => { - debug!("TExists instantiateL"); // Type.hs line 34 if let Type::TExists(alphaprime) = a { let exi = self.existentials(); @@ -323,11 +261,6 @@ impl Context { // <:instantiateR (a, Type::TExists(alpha)) => { // Original code: Type.hs line 29 uses a guard - debug!( - "right hand TExists {} {}", - a.to_sexp().to_string(), - alpha.to_sexp().to_string() - ); if !texists_guard(a, alpha) { return Err(CompileErr(a.loc(), "instantiateR TExists".to_string())); } @@ -335,9 +268,7 @@ impl Context { return self.instantiate_r(a, alpha); } - _ => { - debug!("subtype, didn't match"); - } + _ => {} } Err(CompileErr( @@ -367,12 +298,10 @@ impl Context { return Ok(Box::new(gammaprime)); } None => { - debug!("L match {}", a.to_sexp().to_string()); match a { // InstLReach Type::TExists(beta) => { if self.ordered(alpha, beta) { - debug!("InstLReach AB"); return self .solve(beta, &Type::TExists(alpha.clone()))? .map(|x| Ok(Box::new(x))) @@ -388,7 +317,6 @@ impl Context { )) }); } else { - debug!("InstLReach BA"); return self .solve(alpha, &Type::TExists(beta.clone()))? .map(|x| Ok(Box::new(x))) @@ -407,7 +335,6 @@ impl Context { } // InstLArr Type::TFun(a1, a2) => { - debug!("InstLArr"); let alpha1 = fresh_tvar(a1.loc()); let alpha2 = fresh_tvar(a2.loc()); let rcontext = Context::new_wf(vec![ @@ -426,7 +353,6 @@ impl Context { } // InstLAIIR Type::TForall(beta, b) => { - debug!("InstLArrR"); let betaprime = fresh_tvar(beta.loc()); let subst_res = type_subst(&Type::TVar(betaprime.clone()), &beta.clone(), b.borrow()); @@ -438,7 +364,6 @@ impl Context { } Type::TExec(t) => { - debug!("instL TExec"); let alpha1 = fresh_tvar(t.loc()); let rcontext = Context::new_wf(vec![ ContextElim::CExistsSolved( @@ -464,18 +389,7 @@ impl Context { ContextElim::CExists(alpha1.clone()), ContextElim::CExists(beta1.clone()), ]); - debug!( - "{}have pair with context {}", - i(), - self.to_sexp().to_string() - ); let ctx0 = self.insert_at(alpha, rcontext); - debug!( - "{}about to instantiate_r {} with pair elaborated {}", - i(), - alpha.to_sexp().to_string(), - ctx0.to_sexp().to_string() - ); let ctx1 = ctx0.instantiate_r(x.borrow(), &alpha1)?; return ctx1.instantiate_r(y.borrow(), &beta1); } @@ -504,50 +418,41 @@ impl Context { if let Some(mta) = monotype(a) { if let Some(gammaprime) = self.solve(alpha, &mta)? { - debug!("just gamma'"); return Ok(Box::new(gammaprime)); } } // InstRReach - debug!("match {:?}", a); match a { - Type::TNullable(a1) => { - debug!("case 1"); - match monotype(a1) { - Some(mta) => { - return Ok(Box::new(self.appends_wf(vec![ - ContextElim::CForall(alpha.clone()), - ContextElim::CExistsSolved(alpha.clone(), mta), - ]))); - } - _ => { - return Err(CompileErr( - a.loc(), - format!("no monotype: {}", a1.to_sexp()), - )); - } + Type::TNullable(a1) => match monotype(a1) { + Some(mta) => { + return Ok(Box::new(self.appends_wf(vec![ + ContextElim::CForall(alpha.clone()), + ContextElim::CExistsSolved(alpha.clone(), mta), + ]))); } - } - Type::TExec(a1) => { - debug!("case 2"); - match monotype(a1) { - Some(mta) => { - return Ok(Box::new(self.appends_wf(vec![ - ContextElim::CForall(alpha.clone()), - ContextElim::CExistsSolved(alpha.clone(), mta), - ]))); - } - _ => { - return Err(CompileErr( - a.loc(), - format!("no monotype: {}", a1.to_sexp()), - )); - } + _ => { + return Err(CompileErr( + a.loc(), + format!("no monotype: {}", a1.to_sexp()), + )); } - } + }, + Type::TExec(a1) => match monotype(a1) { + Some(mta) => { + return Ok(Box::new(self.appends_wf(vec![ + ContextElim::CForall(alpha.clone()), + ContextElim::CExistsSolved(alpha.clone(), mta), + ]))); + } + _ => { + return Err(CompileErr( + a.loc(), + format!("no monotype: {}", a1.to_sexp()), + )); + } + }, Type::TPair(a1, a2) => { - debug!("case 3"); let alpha1 = fresh_tvar(a1.loc()); let alpha2 = fresh_tvar(a2.loc()); match monotype(a1).and_then(|mta| monotype(a2).map(|mtb| (mta, mtb))) { @@ -566,7 +471,6 @@ impl Context { } } Type::TExists(beta) => { - debug!("texists {}", beta.to_sexp().to_string()); if self.ordered(alpha, beta) { match self.solve(beta, &Type::TExists(alpha.clone()))? { Some(res) => { @@ -604,7 +508,6 @@ impl Context { } } Type::TFun(a1, a2) => { - debug!("case 4"); let alpha1 = fresh_tvar(a1.loc()); let alpha2 = fresh_tvar(a2.loc()); let rcontext = Context::new_wf(vec![ @@ -623,12 +526,10 @@ impl Context { return theta.instantiate_r(&theta.apply(a2.borrow()), &alpha2); } Type::TForall(beta, b) => { - debug!("case 5"); let betaprime = fresh_tvar(beta.loc()); let subst_res = type_subst(&Type::TExists(betaprime.clone()), &beta.clone(), b); return self .drop_marker(ContextElim::CMarker(betaprime.clone()), |gamma| { - debug!("instantate_r from drop_marker"); gamma .appends_wf(vec![ContextElim::CExists(betaprime.clone())]) .instantiate_r(&subst_res, alpha) @@ -658,7 +559,6 @@ impl Context { (Expr::EUnit(_), Type::TUnit(_)) => Ok(Box::new(self.clone())), // ForallI (e, Type::TForall(alpha, a)) => { - debug!("tforall"); let alphaprime = fresh_tvar(typ.loc()); let subst_res = type_subst(&Type::TVar(alphaprime.clone()), &alpha.clone(), a); self.drop_marker(ContextElim::CForall(alphaprime), |gamma| { @@ -671,7 +571,6 @@ impl Context { // ->I (Expr::EAbs(x, e), Type::TFun(a, b)) => { - debug!("eabs tfun"); let xprime = fresh_var(expr.loc()); let a_borrowed: &Polytype = a.borrow(); let b_borrowed: &Polytype = b.borrow(); @@ -685,14 +584,8 @@ impl Context { } // Sub (e, b) => { - debug!("// Sub"); let (a, theta) = self.typesynth(e)?; let aprime = theta.reify(&a, None); - debug!( - "typesynth {} = {}", - e.to_sexp().to_string(), - aprime.to_sexp().to_string() - ); theta.subtype(&theta.apply(&aprime), &theta.apply(b)) } } @@ -745,24 +638,15 @@ impl Context { let subst_res = subst(&Expr::EVar(xprime.clone()), x.clone(), e_borrowed); - debug!( - "eabs {} {}", - x.to_sexp().to_string(), - e.to_sexp().to_string() - ); self.appends_wf(vec![ ContextElim::CExists(beta.clone()), ContextElim::CExists(alpha.clone()), ]) .drop_marker( ContextElim::CVar(xprime, Type::TExists(alpha.clone())), - |gamma| { - debug!("gamma is {}", gamma.to_sexp().to_string()); - gamma.typecheck(&subst_res, &Type::TExists(beta.clone())) - }, + |gamma| gamma.typecheck(&subst_res, &Type::TExists(beta.clone())), ) .map(|delta| { - debug!("delta is {}", delta.to_sexp().to_string()); ( Type::TFun(Rc::new(Type::TExists(alpha)), Rc::new(Type::TExists(beta))), Box::new(delta), @@ -785,29 +669,16 @@ impl Context { gamma.typecheck(&subst_res, &Type::TExists(beta.clone())) })?; - debug!("delta {}", delta.to_sexp().to_string()); - debug!("delta' {}", deltaprime.to_sexp().to_string()); - let tau = deltaprime.apply(&Type::TFun( Rc::new(Type::TExists(alpha)), Rc::new(Type::TExists(beta)), )); - debug!("tau {}", tau.to_sexp().to_string()); - let evars = deltaprime.unsolved(); - debug!("unsolved:"); let uvars: Vec<(Polytype, TypeVar)> = evars .iter() .map(|e| (Type::TVar(e.clone()), fresh_tvar(x.loc()))) .collect(); - for e in uvars.iter() { - debug!( - " - {} = {}", - e.1.to_sexp().to_string(), - e.0.to_sexp().to_string() - ); - } let tfa = tforalls(evars, type_substs(uvars, tau)); Ok((tfa, Box::new(delta))) } @@ -838,7 +709,6 @@ impl Context { None }; - debug!("do match"); match typ { // ForallApp Type::TForall(alpha, a) => { @@ -930,197 +800,27 @@ impl Context { impl TypeTheory for Context { fn solve(&self, alpha: &TypeVar, tau: &Monotype) -> Result, CompileErr> { - indented(|| { - debug!( - "{}solve {} {} in {}", - i(), - alpha.to_sexp().to_string(), - tau.to_sexp().to_string(), - self.to_sexp().to_string() - ); - let res = self.solve_(alpha, tau); - match &res { - Ok(Some(v)) => { - debug!("{}solve => {}", i(), v.to_sexp().to_string()); - } - Ok(None) => { - debug!("{}solve => None", i()); - } - Err(e) => { - debug!("{}solve => {:?}", i(), e); - } - } - res - }) + self.solve_(alpha, tau) } fn subtype(&self, typ1: &Polytype, typ2: &Polytype) -> Result, CompileErr> { - indented(|| { - debug!( - "{}subtype {} {}", - i(), - typ1.to_sexp().to_string(), - typ2.to_sexp().to_string() - ); - let res = self.subtype_(typ1, typ2); - match &res { - Ok(v) => { - debug!( - "{}subtype => {}", - i(), - /*self.to_sexp().to_string(),*/ v.to_sexp().to_string() - ); - } - Err(e) => { - debug!( - "{}subtype {} {} in {} => {:?}", - i(), - typ1.to_sexp().to_string(), - typ2.to_sexp().to_string(), - self.to_sexp().to_string(), - e - ); - } - } - res - }) + self.subtype_(typ1, typ2) } fn instantiate_l(&self, alpha: &TypeVar, a: &Polytype) -> Result, CompileErr> { - indented(|| { - debug!( - "{}instantiate_l {} {} in {}", - i(), - alpha.to_sexp().to_string(), - a.to_sexp().to_string(), - self.to_sexp().to_string() - ); - let res = self.instantiate_l_(alpha, a); - match &res { - Ok(v) => { - debug!( - "{}instantiate_l {} {} => {}", - i(), - alpha.to_sexp().to_string(), - a.to_sexp().to_string(), - /*self.to_sexp().to_string(),*/ v.to_sexp().to_string() - ); - } - Err(e) => { - debug!( - "{}instantiate_l {} {} in {} => {:?}", - i(), - alpha.to_sexp().to_string(), - a.to_sexp().to_string(), - self.to_sexp().to_string(), - e - ); - } - } - res - }) + self.instantiate_l_(alpha, a) } fn instantiate_r(&self, a: &Polytype, alpha: &TypeVar) -> Result, CompileErr> { - indented(|| { - debug!( - "{}instantiate_r {} {} in {}", - i(), - a.to_sexp().to_string(), - alpha.to_sexp().to_string(), - self.to_sexp().to_string() - ); - let res = self.instantiate_r_(a, alpha); - match &res { - Ok(v) => { - debug!( - "{}instantiate_r {} {} => {}", - i(), - a.to_sexp().to_string(), - alpha.to_sexp().to_string(), - /*self.to_sexp().to_string(),*/ v.to_sexp().to_string() - ); - } - Err(e) => { - debug!( - "{}instantiate_r {} {} in {} => {:?}", - i(), - a.to_sexp().to_string(), - alpha.to_sexp().to_string(), - self.to_sexp().to_string(), - e - ); - } - } - res - }) + self.instantiate_r_(a, alpha) } fn typecheck(&self, expr: &Expr, typ: &Polytype) -> Result, CompileErr> { - indented(|| { - debug!( - "{}typecheck {} {}", - i(), - expr.to_sexp().to_string(), - typ.to_sexp().to_string() - ); - let res = self.typecheck_(expr, typ); - match &res { - Ok(v) => { - debug!( - "{}typecheck {} {} => {}", - i(), - expr.to_sexp().to_string(), - typ.to_sexp().to_string(), - /*self.to_sexp().to_string(),*/ v.to_sexp().to_string() - ); - } - Err(e) => { - debug!( - "{}typecheck {} {} in {} => {:?}", - i(), - expr.to_sexp().to_string(), - typ.to_sexp().to_string(), - self.to_sexp().to_string(), - e - ); - } - } - res - }) + self.typecheck_(expr, typ) } fn typesynth(&self, expr: &Expr) -> Result<(Polytype, Box), CompileErr> { - indented(|| { - debug!( - "{}typesynth {} in {}", - i(), - expr.to_sexp().to_string(), - self.to_sexp().to_string() - ); - let res = self.typesynth_(expr); - match &res { - Ok((t, v)) => { - debug!( - "{}typesynth {} => ({} {})", - i(), - expr.to_sexp().to_string(), - /*self.to_sexp().to_string(),*/ t.to_sexp().to_string(), - v.to_sexp().to_string() - ); - } - Err(e) => { - debug!( - "{}typesynth {} in {} => {:?}", - i(), - expr.to_sexp().to_string(), - self.to_sexp().to_string(), - e - ); - } - } - res - }) + self.typesynth_(expr) } fn typeapplysynth( @@ -1128,39 +828,7 @@ impl TypeTheory for Context { typ: &Polytype, e: &Expr, ) -> Result<(Polytype, Box), CompileErr> { - indented(|| { - debug!( - "{}typeapplysynth {} {} in {}", - i(), - typ.to_sexp().to_string(), - e.to_sexp().to_string(), - self.to_sexp().to_string() - ); - let res = self.typeapplysynth_(typ, e); - match &res { - Ok((t, v)) => { - debug!( - "{}typeapplysynth {} {} => ({} {})", - i(), - typ.to_sexp().to_string(), - e.to_sexp().to_string(), - /*self.to_sexp().to_string(),*/ t.to_sexp().to_string(), - v.to_sexp().to_string() - ); - } - Err(err) => { - debug!( - "{}typeapplysynth {} {} in {} => {:?}", - i(), - typ.to_sexp().to_string(), - e.to_sexp().to_string(), - self.to_sexp().to_string(), - err - ); - } - } - res - }) + self.typeapplysynth_(typ, e) } // Perform all available substitutions diff --git a/src/compiler/untype.rs b/src/compiler/untype.rs index 37029416d..fa0fb29d5 100644 --- a/src/compiler/untype.rs +++ b/src/compiler/untype.rs @@ -5,8 +5,6 @@ use std::rc::Rc; use clvmr::allocator::{Allocator, NodePtr}; use clvmr::reduction::EvalErr; -use log::debug; - use crate::classic::clvm::sexp::proper_list; use crate::compiler::clvm::{convert_from_clvm_rs, convert_to_clvm_rs}; use crate::compiler::compiler::DefaultCompilerOpts; @@ -112,11 +110,9 @@ fn process_helper( let head = lst[0].atomize(); if let SExp::Atom(_, n) = &head { if n == &"deftype".as_bytes().to_vec() { - debug!("deftype"); let result = compile_helperform(opts.clone(), form.clone()) .map_err(|e| EvalErr(sexp, format!("{}: {}", e.0, e.1)))?; if let Some(result) = result { - debug!("result {:?}", result.new_helpers); let mut result_forms = Vec::new(); for f in result.new_helpers.iter() { if matches!(f, HelperForm::Defun(_, _)) { @@ -132,7 +128,6 @@ fn process_helper( } } else if n == &"defun".as_bytes().to_vec() || n == &"defun-inline".as_bytes().to_vec() { - debug!("defun {}", form.to_string()); let def = untype_definition(opts.clone(), form.loc(), sexp, &lst, 2)? .unwrap_or_else(|| form.clone()); Ok(vec![def]) @@ -246,7 +241,6 @@ pub fn untype_code( } if let Some(reformed) = matches_mod(opts, loc.clone(), sexp, &converted)? { - debug!("reformed {}", reformed.to_string()); return convert_to_clvm_rs(allocator, reformed) .map_err(|e| run_failure_to_eval_err(sexp, &e)); } diff --git a/src/py/api.rs b/src/py/api.rs index d3202f1d1..63a69dffb 100644 --- a/src/py/api.rs +++ b/src/py/api.rs @@ -23,7 +23,6 @@ use crate::classic::clvm::__type_compatibility__::{ use crate::classic::clvm::serialize::sexp_to_stream; use crate::classic::clvm_tools::clvmc; use crate::classic::clvm_tools::cmds; -use crate::classic::clvm_tools::log; use crate::classic::clvm_tools::stages::stage_0::DefaultProgramRunner; use crate::compiler::cldb::{ hex_to_modern_sexp, CldbOverrideBespokeCode, CldbRun, CldbRunEnv, CldbSingleBespokeOverride, @@ -495,8 +494,6 @@ pub fn compose_run_function( #[pymodule] fn clvm_tools_rs(py: Python, m: &PyModule) -> PyResult<()> { - log::init(); - m.add_submodule(create_cmds_module(py)?)?; m.add("CldbError", py.get_type::())?; diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 82f947090..ed0d311e9 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,10 +1,3 @@ mod classic; mod compiler; mod util; - -use crate::classic::clvm_tools::log; - -#[ctor::ctor] -fn init() { - log::init(); -} diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index cb74cc0c0..35f6b7e19 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -204,14 +204,12 @@ dependencies = [ "derivative", "do-notation", "encoding8", - "env_logger", "getrandom", "hex", "indoc", "js-sys", "lazy_static", "linked-hash-map", - "log", "num", "num-bigint", "num-traits", @@ -394,27 +392,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3144e455c7aeda487c72555cac2ef84ccac173b29a57b07382ba27016e57b246" -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" -dependencies = [ - "env_filter", - "humantime", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -531,12 +508,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "indexmap" version = "2.1.0"