Skip to content

Commit

Permalink
Merge pull request #72 from Chia-Network/20240306-try-without-log
Browse files Browse the repository at this point in the history
Try without log
  • Loading branch information
prozacchiwawa authored Mar 7, 2024
2 parents 1c55fdb + 2a7d0bc commit 7aa40d4
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 546 deletions.
29 changes: 0 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions src/classic/bins/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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*"));
Expand Down
5 changes: 0 additions & 5 deletions src/classic/clvm_tools/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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(),
Expand Down
12 changes: 0 additions & 12 deletions src/classic/clvm_tools/log.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/classic/clvm_tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions src/compiler/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions src/compiler/typechia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
}
}
Expand Down
12 changes: 2 additions & 10 deletions src/compiler/types/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -282,17 +281,10 @@ impl<const A: usize> GContext<A> {
.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()))))
}
Expand Down
69 changes: 6 additions & 63 deletions src/compiler/types/context.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) => {
Expand All @@ -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,
Expand Down Expand Up @@ -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<A> = 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::<A>(&t1poly, &t2poly) {
Expand Down Expand Up @@ -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<Polytype>, typ: &Polytype) -> Polytype {
Expand All @@ -318,7 +287,6 @@ impl Context {
return typ.clone();
}

debug!("apply {}", typ.to_sexp().to_string());
visited.insert(typ.clone());

match typ {
Expand Down Expand Up @@ -365,27 +333,15 @@ impl GContext<CONTEXT_INCOMPLETE> {
&self,
v: Vec<ContextElim<CONTEXT_INCOMPLETE>>,
) -> GContext<CONTEXT_INCOMPLETE> {
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<CONTEXT_INCOMPLETE>) -> GContext<CONTEXT_INCOMPLETE> {
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<ContextElim<CONTEXT_INCOMPLETE>>) -> GContext<CONTEXT_INCOMPLETE> {
let ctx = GContext(elems);
if log_enabled!(Debug) && !ctx.wf() {
panic!("not well formed {}", ctx.to_sexp());
}
ctx
GContext(elems)
}

pub fn drop_marker<E, X, F>(
Expand All @@ -399,24 +355,11 @@ impl GContext<CONTEXT_INCOMPLETE> {
{
let marked = self.snoc_wf(m.clone());
let res: GContext<CONTEXT_INCOMPLETE> = 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())))
}
}
Loading

0 comments on commit 7aa40d4

Please sign in to comment.