Commit 7581e405 authored by Jeff Smits's avatar Jeff Smits

WIP: new aterm version

parent 90076d94
......@@ -2,7 +2,7 @@
name = "strs"
version = "0.1.0"
dependencies = [
"aterm 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aterm 0.13.0",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -30,10 +30,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "aterm"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"typed-arena 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -250,6 +250,11 @@ name = "try_from"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "typed-arena"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-segmentation"
version = "1.1.0"
......@@ -301,7 +306,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"
"checksum aterm 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a239eea0367b4e6aecc626d45cfc9a893e24398c9837124a3ea2a1606d0ac033"
"checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159"
"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
"checksum clap 2.23.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f57e9b63057a545ad2ecd773ea61e49422ed1b1d63d74d5da5ecaee55b3396cd"
......@@ -330,6 +334,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4437c97558c70d129e40629a5b385b3fb1ffac301e63941335e4d354081ec14a"
"checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7"
"checksum try_from 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "48eb1fb21b59755547de28b0d7c0d67ab0b3f504efae762e2478663665965f53"
"checksum typed-arena 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5934776c3ac1bea4a9d56620d6bf2d483b20d394e49581db40f187e1118ff667"
"checksum unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18127285758f0e2c6cf325bb3f3d138a12fee27de4f23e146cd6a179f26c2cf3"
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
......
......@@ -13,7 +13,6 @@ version = "0.1.0"
phf_codegen = "0.7.21"
[dependencies]
aterm = "0.13.0"
fnv = "1.0.5"
linked-hash-map = "0.4.2"
phf = "0.7.21"
......@@ -23,6 +22,9 @@ structopt = "0.0.3"
structopt-derive = "0.0.3"
try_from = "0.2.1"
[dependencies.aterm]
path = "../aterm"
[profile]
[profile.release]
......
......@@ -202,9 +202,9 @@ fn write_primitive_libs(
pub fn eval_prim_ref<'d, 'f : 'd>(prim_ref: (Libs, usize),
context: &MutContext<'d, 'f>,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef)
-> Result<ATermRef>
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>)
-> Result<ATermRef<'f>>
{{
match prim_ref.0 {{\
"
......@@ -269,9 +269,9 @@ fn write_primitives(
fn {}<'d, 'f : 'd>(offset: usize,
context: &MutContext<'d, 'f>,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef)
-> Result<ATermRef>
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>)
-> Result<ATermRef<'f>>
{{
match offset {{
\
......
......@@ -15,16 +15,16 @@ use std::cell::RefCell;
/// thing, there is observable effect, so the name of the context includes `Mut`.
pub struct MutContext<'d, 'f : 'd> {
pub stack_tracer: RefCell<StackTracer>,
pub scopes: RefCell<Vec<Scope<'d, ATermRef>>>,
pub factory: &'f ATermFactory,
pub scopes: RefCell<Vec<Scope<'d, ATermRef<'f>>>>,
pub factory: &'f ATermFactory<'f>,
pub primitives: Vec<&'static Primitives>,
pub ssl_state: RefCell<State>,
pub ssl_state: RefCell<State<'f>>,
}
impl<'d, 'f : 'd> MutContext<'d, 'f> {
pub fn new(
factory: &'f ATermFactory,
scopes: Vec<Scope<'d, ATermRef>>,
factory: &'f ATermFactory<'f>,
scopes: Vec<Scope<'d, ATermRef<'f>>>,
primitives: Vec<&'static Primitives>,
) -> MutContext<'d, 'f> {
MutContext {
......@@ -40,9 +40,9 @@ impl<'d, 'f : 'd> MutContext<'d, 'f> {
&self,
prim_name: &str,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
let prim_ref = self.primitives
.iter()
.flat_map(|prims| prims.get(prim_name))
......@@ -71,17 +71,17 @@ impl<'d, 'f : 'd> MutContext<'d, 'f> {
.ok_or_else(|| Error::UndefinedStrategy(strat_name.to_owned()))
}
pub fn get_term(&self, term_name: &str) -> Result<ATermRef> {
pub fn get_term(&self, term_name: &str) -> Result<ATermRef<'f>> {
Scopes::get_term_option(&self.scopes.borrow(), term_name).and_then(|(_, o)| {
o.ok_or(Error::StrategyFailed)
})
}
pub fn match_term(&self, term_name: &'d str, current: &ATermRef) -> Result<()> {
pub fn match_term(&self, term_name: &'d str, current: &ATermRef<'f>) -> Result<()> {
Scopes::match_term(&mut self.scopes.borrow_mut(), term_name, current)
}
pub fn push_scope(&self, scope: Scope<'d, ATermRef>) {
pub fn push_scope(&self, scope: Scope<'d, ATermRef<'f>>) {
self.scopes.borrow_mut().push(scope);
}
......@@ -95,7 +95,7 @@ impl<'d, 'f : 'd> MutContext<'d, 'f> {
self.push_scope(overlay);
}
fn _apply_overlay(&self, scope: Scope<'d, ATermRef>) {
fn _apply_overlay(&self, scope: Scope<'d, ATermRef<'f>>) {
debug_assert!(
scope.strategy.is_empty(),
"_apply_overlay: Interpreter bug, overlay is leaking a strategy definition"
......@@ -263,10 +263,10 @@ impl<'a, ATerm> Scope<'a, ATerm> {
pub mod Scopes {
use super::*;
pub fn get_term_option(
scopes: &Vec<Scope<ATermRef>>,
pub fn get_term_option<'f>(
scopes: &Vec<Scope<ATermRef<'f>>>,
term_name: &str,
) -> Result<(usize, Option<ATermRef>)> {
) -> Result<(usize, Option<ATermRef<'f>>)> {
let mut offset = None;
for (n,scope) in scopes.iter().enumerate().rev() {
if offset == None && scope.is_overlay {
......@@ -280,10 +280,10 @@ pub mod Scopes {
Err(Error::UndefinedVariable(term_name.to_owned()))
}
pub fn match_term<'a>(
scopes: &mut Vec<Scope<'a, ATermRef>>,
pub fn match_term<'a, 'f>(
scopes: &mut Vec<Scope<'a, ATermRef<'f>>>,
term_name: &'a str,
current: &ATermRef,
current: &ATermRef<'f>,
) -> Result<()> {
let term = get_term_option(scopes, term_name)?;
match term {
......@@ -307,10 +307,5 @@ pub mod Scopes {
}
}
}
unreachable!(format!(
"match_term: First we could find {} unbound, then we couldn't \
anymore?!",
term_name
))
}
}
This diff is collapsed.
......@@ -4,8 +4,7 @@ use linked_hash_map::LinkedHashMap;
use try_from::TryInto;
use fnv::FnvHashMap;
use fnv::FnvHasher;
use fnv::{FnvHashMap, FnvBuildHasher, FnvHasher};
use std::collections::hash_map;
use std::cell::RefCell;
......@@ -15,11 +14,11 @@ use std::fmt;
use std::rc::Rc;
use std::borrow::Borrow;
pub type HashTable = LinkedHashMap<ATermRef, ATermRef, ::fnv::FnvBuildHasher>;
pub type HashTable<'s> = LinkedHashMap<ATermRef<'s>, ATermRef<'s>, ::fnv::FnvBuildHasher>;
#[derive(Debug, Eq, Clone, Default)]
pub struct IndexedSet(FnvHashMap<ATermRef, u16>, u16);
pub struct IndexedSet<'s>(FnvHashMap<ATermRef<'s>, u16>, u16);
impl IndexedSet {
impl<'s> IndexedSet<'s> {
pub fn with_capacity(capacity: usize) -> Self {
IndexedSet(FnvHashMap::with_capacity_and_hasher(capacity, ::fnv::FnvBuildHasher::default()), 0)
}
......@@ -31,13 +30,13 @@ impl IndexedSet {
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&u16>
where
ATermRef: Borrow<Q>,
ATermRef<'s>: Borrow<Q>,
Q: Eq + Hash,
{
self.0.get(key)
}
pub fn insert(&mut self, key: ATermRef) -> u16 {
pub fn insert(&mut self, key: ATermRef<'s>) -> u16 {
self.1 += 1;
let _ = self.0.insert(key, self.1);
self.1
......@@ -45,24 +44,24 @@ impl IndexedSet {
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<u16>
where
ATermRef: Borrow<Q>,
ATermRef<'s>: Borrow<Q>,
Q: Eq + Hash,
{
self.0.remove(key)
}
pub fn keys(&self) -> hash_map::Keys<ATermRef, u16> {
pub fn keys(&self) -> hash_map::Keys<ATermRef<'s>, u16> {
self.0.keys()
}
}
impl PartialEq for IndexedSet {
fn eq(&self, other: &IndexedSet) -> bool {
impl<'s> PartialEq for IndexedSet<'s> {
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
}
impl Hash for IndexedSet {
impl<'s> Hash for IndexedSet<'s> {
fn hash<H: Hasher>(&self, state: &mut H) {
for t in &self.0 {
t.hash(state);
......@@ -71,9 +70,9 @@ impl Hash for IndexedSet {
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Blob {
HashTable(Rc<RefCell<HashTable>>),
IndexedSet(Rc<RefCell<IndexedSet>>),
pub enum Blob<'s> {
HashTable(Rc<RefCell<HashTable<'s>>>),
IndexedSet(Rc<RefCell<IndexedSet<'s>>>),
}
/// This is an evil `Hash` implementation that will just go through the `RefCell`. Since the
......@@ -81,7 +80,7 @@ pub enum Blob {
/// where hashing is used. This situation is similar to the one with `aterm::Term::Real`.
#[allow(unknown_lints)]
#[allow(derive_hash_xor_eq)]
impl Hash for Blob {
impl<'s> Hash for Blob<'s> {
fn hash<H: Hasher>(&self, state: &mut H) {
match *self {
Blob::HashTable(ref htrc) => {
......@@ -96,22 +95,22 @@ impl Hash for Blob {
}
}
impl From<HashTable> for Blob {
impl<'s> From<HashTable<'s>> for Blob<'s> {
fn from(table: HashTable) -> Blob {
Blob::HashTable(Rc::new(RefCell::new(table)))
}
}
impl From<IndexedSet> for Blob {
impl<'s> From<IndexedSet<'s>> for Blob<'s> {
fn from(set: IndexedSet) -> Blob {
Blob::IndexedSet(Rc::new(RefCell::new(set)))
}
}
impl TryInto<Rc<RefCell<HashTable>>> for Blob {
impl<'s> TryInto<Rc<RefCell<HashTable<'s>>>> for Blob<'s> {
type Err = ();
fn try_into(self) -> Result<Rc<RefCell<HashTable>>, Self::Err> {
fn try_into(self) -> Result<Rc<RefCell<HashTable<'s>>>, Self::Err> {
match self {
Blob::HashTable(htrc) => Ok(htrc),
Blob::IndexedSet(_) => Err(()),
......@@ -119,10 +118,10 @@ impl TryInto<Rc<RefCell<HashTable>>> for Blob {
}
}
impl TryInto<Rc<RefCell<IndexedSet>>> for Blob {
impl<'s> TryInto<Rc<RefCell<IndexedSet<'s>>>> for Blob<'s> {
type Err = ();
fn try_into(self) -> Result<Rc<RefCell<IndexedSet>>, Self::Err> {
fn try_into(self) -> Result<Rc<RefCell<IndexedSet<'s>>>, Self::Err> {
match self {
Blob::HashTable(_) => Err(()),
Blob::IndexedSet(isrc) => Ok(isrc),
......@@ -130,32 +129,32 @@ impl TryInto<Rc<RefCell<IndexedSet>>> for Blob {
}
}
pub trait StrTerm<'s>: aterm::ATerm<'s> {
fn get_string(&self) -> Option<&'s str>;
}
// TODO: Support annotations on sublists (not support by the aterm format)
pub type ATermFactory = aterm::rc::ATermFactory<Blob>;
pub type ATerm = aterm::rc::ATerm<Blob>;
pub type ATermRef = Rc<aterm::rc::ATerm<Blob>>;
pub type ATermFactory<'s> = aterm::rc::ATermFactory<Blob<'s>, FnvBuildHasher>;
pub type ATerm<'s> = aterm::rc::ATerm<'s, Blob<'s>>;
pub type ATermRef<'s> = Rc<aterm::rc::ATerm<'s, Blob<'s>>>;
impl aterm::print::ATermWrite for Blob {
impl<'s> aterm::print::ATermWrite for Blob<'s> {
fn to_ascii<W: fmt::Write>(&self, writer: &mut W) -> fmt::Result {
let mut hasher = FnvHasher::default();
self.hash(&mut hasher);
writer.write_str(&hasher.finish().to_string())
}
}
#[allow(unused_variables)]
fn to_taf<W: fmt::Write>(&self, writer: &mut W) -> fmt::Result {
unimplemented!()
}
#[allow(unused_variables)]
fn to_baf<W: fmt::Write>(&self, writer: &mut W) -> fmt::Result {
unimplemented!()
}
#[allow(unused_variables)]
fn to_saf<W: fmt::Write>(&self, writer: &mut W) -> fmt::Result {
unimplemented!()
impl<'s> StrTerm<'s> for ATerm<'s> {
fn get_string(&self) -> Option<&'s str> {
use aterm::rc::Term::*;
match self.term {
Application(s, ref c) if c.is_empty() && s.starts_with('"') && s.ends_with('"') => Some(s),
_ => None,
}
}
}
This diff is collapsed.
......@@ -21,17 +21,17 @@ pub fn read_input<P: AsRef<Path>>(path: &P) -> io::Result<String> {
Ok(ctree)
}
pub fn read_aterm<P: AsRef<Path>>(f: &ATermFactory, path: &P) -> Result<ATermRef> {
pub fn read_aterm<'f, P: AsRef<Path>>(f: &'f ATermFactory<'f>, path: &P) -> Result<ATermRef<'f>> {
let file_contents = read_input(path)?;
let (aterm, _) = f.read_ascii(&file_contents)?;
let (aterm, _) = f.read_ascii_string(&file_contents)?;
Ok(aterm)
}
pub fn read_lib(
f: &ATermFactory,
pub fn read_lib<'f>(
f: &'f ATermFactory<'f>,
str_path: &Path,
path: &str,
) -> Result<(ATermRef, Option<&'static Primitives>)> {
) -> Result<(ATermRef<'f>, Option<&'static Primitives>)> {
if let Some(&(path, prim)) = primitives::LIBS.get(path) {
Ok((read_aterm(f, &Path::new(&str_path).join(path))?, prim))
} else {
......
......@@ -83,17 +83,21 @@ fn exec(
stack_space: usize,
) -> result::Result<String, TracedError> {
use std::thread;
use aterm::utils::extend_lifetime;
thread::Builder::new()
.name("Main execution thread".into())
.stack_size(stack_space * 1024 * 1024)
.spawn(move || {
let f = ATermFactory::new();
// Dear borrow checker, let's just agree to disagree here, ok?
let fref = unsafe { extend_lifetime(&f) };
let libraries = library_paths
.into_iter()
.map(|lib_path| io::read_lib(&f, str_path.as_ref(), &lib_path))
.map(|lib_path| io::read_lib(fref, str_path.as_ref(), &lib_path))
.collect::<Result<_>>()?;
let program = io::read_aterm(&f, &program_path)?;
let term = interpret_main(&f, program, libraries)?;
let program = io::read_aterm(fref, &program_path)?;
let term = interpret_main(fref, program, libraries)?;
let mut result = String::new();
term.to_ascii(&mut result)?;
Ok(result)
......
use context::{MutContext, Scope};
use ctree;
use error::{Result, Error};
use factory::{ATermFactory, ATermRef};
use factory::{StrTerm, ATermFactory, ATermRef};
use aterm::BrokenF32;
use aterm::{ATerm as A, ATermFactory as ATF};
......@@ -385,23 +385,22 @@ impl TryFrom<ctree::PreTerm> for BuildTerm {
}
impl BuildTerm {
pub fn build<'d, 'f : 'd>(&self, context: &MutContext<'d, 'f>) -> Result<ATermRef> {
pub fn build<'d, 'f : 'd>(&self, context: &MutContext<'d, 'f>) -> Result<ATermRef<'f>> {
self.build_with_annos(context, None)
}
fn build_with_annos<'d, 'f : 'd>(
&self,
context: &MutContext<'d, 'f>,
annos: Option<Vec<ATermRef>>,
) -> Result<ATermRef> {
annos: Option<Vec<ATermRef<'f>>>,
) -> Result<ATermRef<'f>> {
use self::BuildTerm::*;
match *self {
Var(ref s) => {
use interpreter::b;
if let Some(annos) = annos {
let term = context.get_term(s)?;
Ok(context.factory.with_annos(
b(&term).as_inner().term.clone(),
Ok(context.factory.set_annos(
term,
annos,
))
} else {
......@@ -409,20 +408,20 @@ impl BuildTerm {
}
}
Int(i) => {
Ok(context.factory.with_annos(
context.factory.t_int(i),
Ok(context.factory.set_annos(
context.factory.int(i),
annos.unwrap_or_default(),
))
}
Real(BrokenF32(f)) => {
Ok(context.factory.with_annos(
context.factory.t_real(f),
Ok(context.factory.set_annos(
context.factory.real(f),
annos.unwrap_or_default(),
))
}
Str(ref s) => {
Ok(context.factory.with_annos(
context.factory.t_string(s.clone()),
Ok(context.factory.set_annos(
context.factory.string(s.clone()),
annos.unwrap_or_default(),
))
}
......@@ -439,8 +438,8 @@ impl BuildTerm {
} else if s == "Nil" && t.is_empty() {
Ok(context.factory.list(iter::empty()))
} else {
Ok(context.factory.with_annos(
context.factory.t_application(
Ok(context.factory.set_annos(
context.factory.application(
s.clone(),
t.into_iter(),
),
......@@ -461,9 +460,9 @@ impl BuildTerm {
Ok(string)
} else {
let application =
context.factory.t_application(s, children.iter().cloned());
context.factory.application(s, children.iter().cloned());
Ok(context.factory.with_annos(
Ok(context.factory.set_annos(
application,
annos.unwrap_or_default(),
))
......@@ -488,7 +487,7 @@ impl BuildTerm {
// NOTE: `str '!((1{2}){3})'` gives `1{2}`, so the innermost `annos` list in a build is
// used! Therefore we just shadow the input `annos` with the annotations in this `Anno`
Anno(ref term, ref annos) => {
let annos: ATermRef = (**annos).build(context)?;
let annos: ATermRef<'f> = (**annos).build(context)?;
if let Some(annos_vec) = annos.get_list() {
term.build_with_annos(context, Some(annos_vec.to_vec()))
} else {
......@@ -499,12 +498,12 @@ impl BuildTerm {
}
/// Lifts `build` over a vector
fn build_vec<'d, 'f : 'd>(context: &MutContext<'d, 'f>, vec: &[BuildTerm]) -> Result<Vec<ATermRef>> {
fn build_vec<'d, 'f : 'd>(context: &MutContext<'d, 'f>, vec: &[BuildTerm]) -> Result<Vec<ATermRef<'f>>> {
vec.into_iter().map(|t| t.build(context)).collect()
}
#[allow(dead_code)]
pub fn build_static(&self, f: &ATermFactory) -> Result<ATermRef> {
pub fn build_static<'f>(&self, f: &'f ATermFactory<'f>) -> Result<ATermRef<'f>> {
let dummy_context = MutContext::new(f, Vec::new(), Vec::new());
self.build(&dummy_context).map_err(|e| match e {
Error::UndefinedVariable(_) => Error::CTreeParse(
......
This diff is collapsed.
......@@ -14,9 +14,9 @@ use std::borrow::Borrow;
pub fn indexedSet_create<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
if targs.len() < 2 {
return Err(Error::UnknownBehaviour(
"Primitive indexedSet_create called with wrong argument count",
......@@ -40,9 +40,9 @@ pub fn indexedSet_create<'d, 'f: 'd>(
pub fn indexedSet_reset<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
use try_from::TryInto;
if targs.len() < 1 {
return Err(Error::UnknownBehaviour(
......@@ -65,18 +65,18 @@ pub fn indexedSet_reset<'d, 'f: 'd>(
pub fn indexedSet_destroy<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
indexedSet_reset(context, sargs, targs, current)
}
pub fn indexedSet_put<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
use try_from::TryInto;
if sargs.len() < 1 || targs.len() < 2 {
return Err(Error::UnknownBehaviour(
......@@ -110,9 +110,9 @@ pub fn indexedSet_put<'d, 'f: 'd>(
pub fn indexedSet_remove<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
use try_from::TryInto;
if targs.len() < 2 {
return Err(Error::UnknownBehaviour(
......@@ -134,9 +134,9 @@ pub fn indexedSet_remove<'d, 'f: 'd>(
pub fn indexedSet_getIndex<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
use try_from::TryInto;
if targs.len() < 2 {
return Err(Error::UnknownBehaviour(
......@@ -162,9 +162,9 @@ pub fn indexedSet_getIndex<'d, 'f: 'd>(
pub fn indexedSet_elements<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
use try_from::TryInto;
if targs.len() < 1 {
return Err(Error::UnknownBehaviour(
......
use context::MutContext;
use error::{Error, Result};
use factory::ATermRef;
use factory::{StrTerm, ATermRef};
use preprocess::StrategyDef;
use aterm::{ATermFactory as ATF, ATerm as A};
......@@ -8,9 +8,9 @@ use aterm::{ATermFactory as ATF, ATerm as A};
pub fn is_int<'d, 'f: 'd>(
_context: &MutContext<'d, 'f>,
_sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
if targs.len() < 1 {
return Err(Error::UnknownBehaviour(
"Primitive is_int called with wrong argument count",
......@@ -24,9 +24,9 @@ pub fn is_int<'d, 'f: 'd>(
pub fn int<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
_sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
if targs.len() < 1 {
return Err(Error::UnknownBehaviour(
"Primitive int called with wrong argument count",
......@@ -44,9 +44,9 @@ pub fn int<'d, 'f: 'd>(
pub fn iori<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
_sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
if targs.len() < 2 {
return Err(Error::UnknownBehaviour(
"Primitive iori called with wrong argument count",
......@@ -60,9 +60,9 @@ pub fn iori<'d, 'f: 'd>(
pub fn xori<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
_sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
if targs.len() < 2 {
return Err(Error::UnknownBehaviour(
"Primitive xori called with wrong argument count",
......@@ -76,9 +76,9 @@ pub fn xori<'d, 'f: 'd>(
pub fn andi<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
_sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {
if targs.len() < 2 {
return Err(Error::UnknownBehaviour(
"Primitive andi called with wrong argument count",
......@@ -92,9 +92,9 @@ pub fn andi<'d, 'f: 'd>(
pub fn shli<'d, 'f: 'd>(
context: &MutContext<'d, 'f>,
_sargs: Vec<StrategyDef<'d>>,
targs: Vec<ATermRef>,
current: ATermRef,
) -> Result<ATermRef> {
targs: Vec<ATermRef<'f>>,
current: ATermRef<'f>,
) -> Result<ATermRef<'f>> {