Skip to content

Commit

Permalink
rem
Browse files Browse the repository at this point in the history
  • Loading branch information
ludns committed Oct 27, 2024
1 parent 05d4429 commit a1492af
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 18 deletions.
9 changes: 0 additions & 9 deletions pex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,29 +650,23 @@ impl Expr {
// Given we don't copy entries from previous PODs unless explicitly instructed with 'keep' (TODO: this doesn't exit yet)
let mut builder_guard = builder.lock().unwrap();

// First ensure the referenced pod is registered as an input pod
if let Some(source_pod) = builder_guard.input_pods.get(&pod_id) {
// Check if statement exists in source pod
if let Some(statement_value) =
source_pod.payload.statements_map.get(&statement)
{
// Create a new entry with the target key
if let Ok(value_of) = statement_value.value() {
// Create an entry with the new key and same value
let new_entry = Entry {
key: key.clone(),
value: value_of,
};

let new_statement_id =
builder_guard.next_statement_id();
// Add NewEntry operation
builder_guard.add_operation(
Op::NewEntry(new_entry),
new_statement_id.clone(),
);

// Add EqualityFromEntries operation using SRef
let next_statement_id =
builder_guard.next_statement_id();
builder_guard.add_operation(
Expand Down Expand Up @@ -709,7 +703,6 @@ impl Expr {
_ => return Err(anyhow!("Expected key-value pair")),
}
}
// Finalize pod
let pod = builder.lock().unwrap().finalize()?;
Ok(Value::PodRef(pod))
}
Expand Down Expand Up @@ -920,7 +913,6 @@ mod tests {
let pod_store = Arc::new(Mutex::new(MyPods::default()));
let env = Env::new("test_user".to_string(), shared, pod_store);

// Create a pod with two scalar values
let result = eval("[createpod test_pod x [+ 40 2] y 123]", env).await?;

match result {
Expand Down Expand Up @@ -1054,7 +1046,6 @@ mod tests {
)
.await;

// Verify that the operation failed
assert!(result.is_err());
if let Err(e) = result {
assert!(e.to_string().contains("No pod found matching statements"));
Expand Down
3 changes: 0 additions & 3 deletions pex/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use reedline::{

#[tokio::main]
async fn main() -> Result<()> {
// Initialize environment
let shared = Arc::new(Mutex::new(HashMap::new()));
let pod_store = Arc::new(Mutex::new(MyPods::default()));
let env = Env::new("repl_user".to_string(), shared, pod_store.clone());
Expand All @@ -40,7 +39,6 @@ async fn main() -> Result<()> {
let completer = Box::new(LispCompleter::new(commands.clone()));
let completion_menu = Box::new(ColumnarMenu::default().with_name("completion_menu"));

// Set up keybindings
let mut keybindings = default_emacs_keybindings();
keybindings.add_binding(
KeyModifiers::NONE,
Expand All @@ -53,7 +51,6 @@ async fn main() -> Result<()> {

let edit_mode = Box::new(Emacs::new(keybindings));

// Create line editor with both highlighting and completion
let mut line_editor = Reedline::create()
.with_highlighter(Box::new(LispHighlighter::new(commands.clone())))
.with_completer(completer)
Expand Down
6 changes: 1 addition & 5 deletions pex/src/repl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn get_pod_info(pod: &POD) -> HashMap<String, Vec<String>> {
Statement::SumOf(_, op1, op2)
| Statement::ProductOf(_, op1, op2)
| Statement::MaxOf(_, op1, op2)
| Statement::Equal(op1, op2) => vec![op1, op2] // Added Equal here
| Statement::Equal(op1, op2) => vec![op1, op2]
.into_iter()
.filter(|r| !r.0.is_self())
.map(|r| (statement_id.clone(), r))
Expand Down Expand Up @@ -141,7 +141,6 @@ pub fn print_pod_details(pod: &POD, pod_store: &MyPods) {
let origin_refs = get_pod_info(pod);

if !origin_refs.is_empty() {
// Print matched pods
print_section_header("Matched PODs", None);

for (origin, _) in origin_refs.iter() {
Expand All @@ -159,15 +158,13 @@ pub fn print_pod_details(pod: &POD, pod_store: &MyPods) {
matched_pod.proof_type.to_string().bright_cyan()
);

// Print all statements in the matched pod
for (stmt_id, stmt) in matched_pod.payload.statements_map.iter() {
print_statement(stmt_id, stmt, " ");
}
println!();
}
}

// Print dependencies
print_section_header("Dependencies", None);
for (origin, statements) in origin_refs.iter() {
let gadget_id = pod_store
Expand Down Expand Up @@ -227,7 +224,6 @@ pub fn print_pod_details(pod: &POD, pod_store: &MyPods) {
}
}

// Print new pod's statements
print_section_header("POD Statements", Some(&pod.proof_type.to_string()));
for (statement_id, statement) in pod.payload.statements_map.iter() {
print_statement(statement_id, statement, " ");
Expand Down
2 changes: 1 addition & 1 deletion pex/src/repl/reedline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl Completer for LispCompleter {
.filter(|cmd| cmd.starts_with(&current_word))
.map(|cmd| Suggestion {
value: cmd.clone(),
description: None, // We could add descriptions for commands here
description: None,
extra: None,
span: Span::new(start, pos),
style: None,
Expand Down

0 comments on commit a1492af

Please sign in to comment.