Introducing a trait for running compares.

This should enable us to invoke compares without needing a reference ast node type.
This commit is contained in:
Tom Alexander 2023-12-27 12:38:21 -05:00
parent 36b80dc093
commit e83417b243
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 33 additions and 26 deletions

View File

@ -1,5 +1,6 @@
use std::borrow::Cow;
use super::elisp_compare::WasmElispCompare;
use crate::compare::Token;
use crate::wasm::WasmAstNode;
use crate::wasm::WasmDocument;
@ -9,8 +10,7 @@ pub fn wasm_compare_document<'b, 's, 'p>(
emacs: &'b Token<'s>,
wasm: WasmDocument<'s, 'p>,
) -> Result<WasmDiffEntry<'b, 's>, Box<dyn std::error::Error>> {
// wasm_compare_ast_node(
todo!()
wasm.compare_ast_node(source, emacs)
}
#[derive(Debug)]
@ -153,33 +153,29 @@ fn wasm_compare_ast_node<'b, 's, 'p>(
todo!()
}
// fn wasm_compare_list<'b, 's, EI, WI, WC>(
// source: &'s str,
// emacs: EI,
// wasm: WI,
// // emacs: &'b Token<'s>,
// // wasm: WasmDocument<'s>,
// ) -> Result<WasmDiffEntry<'b, 's>, Box<dyn std::error::Error>>
// where
// EI: Iterator<Item = &'b Token<'s>> + ExactSizeIterator,
// WI: Iterator<Item = WC>,
// WasmAstNode<'b, 's>: From<WC>,
// {
// let mut this_status = WasmDiffStatus::Good;
// let mut child_status = Vec::new();
// let mut message = None;
// todo!()
// }
fn impl_wasm_compare_document<'b, 's, 'p>(
fn wasm_compare_list<'b, 's, 'p, EI, WI, WC>(
source: &'s str,
emacs: &'b Token<'s>,
wasm: WasmDocument<'s, 'p>,
) -> Result<WasmDiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = WasmDiffStatus::Good;
emacs: EI,
wasm: WI,
) -> Result<WasmDiffEntry<'b, 's>, Box<dyn std::error::Error>>
where
EI: Iterator<Item = &'b Token<'s>> + ExactSizeIterator,
WI: Iterator<Item = WC> + ExactSizeIterator,
WC: WasmElispCompare<'s, 'p>,
{
// let mut this_status = WasmDiffStatus::Good;
// let mut child_status = Vec::new();
// let mut message = None;
todo!()
}
impl<'s, 'p> WasmElispCompare<'s, 'p> for WasmDocument<'s, 'p> {
fn compare_ast_node<'b>(
&self,
source: &'s str,
emacs: &'b Token<'s>,
) -> Result<WasmDiffEntry<'b, 's>, Box<dyn std::error::Error>> {
todo!()
}
}

View File

@ -0,0 +1,10 @@
use super::compare::WasmDiffEntry;
use crate::compare::Token;
pub trait WasmElispCompare<'s, 'p> {
fn compare_ast_node<'b>(
&'p self,
source: &'s str,
emacs: &'b Token<'s>,
) -> Result<WasmDiffEntry<'b, 's>, Box<dyn std::error::Error>>;
}

View File

@ -1,4 +1,5 @@
mod compare;
mod elisp_compare;
mod runner;
pub use runner::wasm_run_anonymous_compare;