pub struct CompilerImport;Expand description
Import utilities for reverse synchronization.
Implementations§
Source§impl CompilerImport
impl CompilerImport
Sourcepub fn import_domains(
table: &mut SymbolTable,
domains: &HashMap<String, usize>,
) -> Result<()>
pub fn import_domains( table: &mut SymbolTable, domains: &HashMap<String, usize>, ) -> Result<()>
Import domain information from a compiler context back into a symbol table.
This is useful for synchronizing state after compilation.
§Example
use tensorlogic_adapters::{SymbolTable, CompilerImport};
use std::collections::HashMap;
let mut domains = HashMap::new();
domains.insert("Person".to_string(), 100);
domains.insert("Location".to_string(), 50);
let mut table = SymbolTable::new();
CompilerImport::import_domains(&mut table, &domains).unwrap();
assert!(table.get_domain("Person").is_some());
assert!(table.get_domain("Location").is_some());Sourcepub fn import_predicates(
table: &mut SymbolTable,
signatures: &HashMap<String, Vec<String>>,
) -> Result<()>
pub fn import_predicates( table: &mut SymbolTable, signatures: &HashMap<String, Vec<String>>, ) -> Result<()>
Import predicate signatures from a compiler context.
§Example
use tensorlogic_adapters::{SymbolTable, DomainInfo, CompilerImport};
use std::collections::HashMap;
let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
let mut signatures = HashMap::new();
signatures.insert("knows".to_string(), vec!["Person".to_string(), "Person".to_string()]);
CompilerImport::import_predicates(&mut table, &signatures).unwrap();
assert!(table.get_predicate("knows").is_some());Sourcepub fn import_variables(
table: &mut SymbolTable,
bindings: &HashMap<String, String>,
) -> Result<()>
pub fn import_variables( table: &mut SymbolTable, bindings: &HashMap<String, String>, ) -> Result<()>
Import variable bindings from a compiler context.
§Example
use tensorlogic_adapters::{SymbolTable, DomainInfo, CompilerImport};
use std::collections::HashMap;
let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
let mut bindings = HashMap::new();
bindings.insert("x".to_string(), "Person".to_string());
bindings.insert("y".to_string(), "Person".to_string());
CompilerImport::import_variables(&mut table, &bindings).unwrap();
assert_eq!(table.get_variable_domain("x"), Some("Person"));
assert_eq!(table.get_variable_domain("y"), Some("Person"));Sourcepub fn import_all(
table: &mut SymbolTable,
bundle: &CompilerExportBundle,
) -> Result<()>
pub fn import_all( table: &mut SymbolTable, bundle: &CompilerExportBundle, ) -> Result<()>
Import a complete bundle into a symbol table.
Auto Trait Implementations§
impl Freeze for CompilerImport
impl RefUnwindSafe for CompilerImport
impl Send for CompilerImport
impl Sync for CompilerImport
impl Unpin for CompilerImport
impl UnwindSafe for CompilerImport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more