Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cruft. #184

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ anyhow = {version = "1.0.66", features = ["backtrace"] }
serde = {version = "1.0.150", features = ["derive", "rc"] }
serde_json = {version = "1.0.89", features = ["arbitrary_precision"] }
serde_yaml = {version = "0.9.16", optional = true }
log = "0.4.17"
env_logger="0.11.1"
lazy_static = "1.4.0"
rand = "0.8.5"
num = "0.4.1"
Expand Down
4 changes: 0 additions & 4 deletions examples/regorus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ struct Cli {

fn main() -> Result<()> {
use clap::Parser;
env_logger::builder()
.format_level(false)
.format_timestamp(None)
.init();

// Parse and dispatch command.
let cli = Cli::parse();
Expand Down
28 changes: 1 addition & 27 deletions src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use crate::Rc;
use crate::{Expression, Extension, Location, QueryResult, QueryResults};

use anyhow::{anyhow, bail, Result};
use log::info;
use std::collections::btree_map::Entry as BTreeMapEntry;
use std::collections::{hash_map::Entry, BTreeMap, BTreeSet, HashMap};
use std::ops::Bound::*;
Expand Down Expand Up @@ -230,7 +229,6 @@ impl Interpreter {

pub fn set_input(&mut self, input: Value) {
self.input = input;
info!("input: {:#?}", self.input);
}

pub fn init_with_document(&mut self) -> Result<()> {
Expand Down Expand Up @@ -725,11 +723,6 @@ impl Interpreter {
// TODO: optimize this
self.variables_assignment(&name, &value)?;

info!(
"eval_assign_expr before, op: {:?}, lhs: {:?}, rhs: {:?}",
op, lhs, rhs
);

Ok(Value::Bool(true))
}

Expand Down Expand Up @@ -1317,13 +1310,6 @@ impl Interpreter {
}

fn eval_stmt(&mut self, stmt: &LiteralStmt, stmts: &[&LiteralStmt]) -> Result<bool> {
debug_new_group!(
"eval_stmt {}:{} {}",
stmt.span.line,
stmt.span.col,
stmt.span.text()
);

let (saved_state, skip_exec) = self.apply_with_modifiers(stmt)?;
let r = if !skip_exec {
self.eval_stmt_impl(stmt, stmts)
Expand Down Expand Up @@ -2525,7 +2511,6 @@ impl Interpreter {

fn lookup_var(&mut self, span: &Span, fields: &[&str], no_error: bool) -> Result<Value> {
let name = span.source_str();
debug_new_group!("lookup_var: name={name}, fields={fields:?}, no_error={no_error}");

// Return local variable/argument.
if let Some(v) = self.lookup_local_var(&name) {
Expand Down Expand Up @@ -2630,13 +2615,6 @@ impl Interpreter {
}

fn eval_expr(&mut self, expr: &ExprRef) -> Result<Value> {
debug_new_group!(
"eval_expr: {}:{} {}",
expr.span().line,
expr.span().col,
expr.span().text()
);

#[cfg(feature = "coverage")]
if self.enable_coverage {
let span = expr.span();
Expand Down Expand Up @@ -3386,12 +3364,8 @@ impl Interpreter {
}

pub fn create_rule_prefixes(&mut self) -> Result<()> {
debug_new_group!("create_rule_prefixes");
debug!("data before: {}", self.data);

for module in self.modules.clone() {
let module_path = Self::get_rule_path_components(&module.package.refr)?;
debug!("processing module {module_path:?}");

for rule in &module.policy {
let rule_refr = Self::get_rule_refr(rule);
Expand Down Expand Up @@ -3427,7 +3401,7 @@ impl Interpreter {
}
}
}
debug!("data after: {}", self.data);

Ok(())
}

Expand Down
72 changes: 0 additions & 72 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,78 +8,6 @@ use crate::lexer::*;
use std::collections::BTreeMap;

use anyhow::{bail, Result};

#[cfg(debug_assertions)]
macro_rules! debug {
($($arg:tt)+) => {
{
if log::log_enabled!(log::Level::Debug) {
print!("{}:{}:", file!(), line!());
crate::utils::NESTING.with(|f| {
print!("{}", " ".repeat(*f.borrow() as usize));
});
println!($($arg)+);
}
}
}

}

#[cfg(not(debug_assertions))]
macro_rules! debug {
($($arg:tt)+) => {};
}

#[allow(unused)]
pub(crate) use debug;

#[cfg(debug_assertions)]
#[allow(unused)]
macro_rules! debug_new_group {
($($arg:tt)+) => {
debug!($($arg)+);
let _group = DebugNesting::new();
};
}

#[cfg(not(debug_assertions))]
macro_rules! debug_new_group {
($($arg:tt)+) => {};
}

#[allow(unused)]
pub(crate) use debug_new_group;

#[allow(unused)]
pub struct DebugNesting {}

#[cfg(debug_assertions)]
thread_local!(pub static NESTING: std::cell::RefCell<u32> = std::cell::RefCell::new(1));

impl DebugNesting {
#[cfg(debug_assertions)]
#[allow(unused)]
pub fn new() -> DebugNesting {
NESTING.with(|f| {
*f.borrow_mut() += 1;
});
DebugNesting {}
}
}

#[allow(unused)]
impl Drop for DebugNesting {
#[cfg(debug_assertions)]
fn drop(&mut self) {
NESTING.with(|f| {
*f.borrow_mut() -= 1;
});
}

#[cfg(not(debug_assertions))]
fn drop(&mut self) {}
}

pub fn get_path_string(refr: &Expr, document: Option<&str>) -> Result<String> {
let mut comps: Vec<&str> = vec![];
let mut expr = Some(refr);
Expand Down
Loading