Commit 27943524 authored by Jeff Smits's avatar Jeff Smits

Revert "WIP: using local version of aterm library to see if we can remove most...

Revert "WIP: using local version of aterm library to see if we can remove most copying of constructor strings"

This reverts commit 59f31e06.
parent 4468cbfa
......@@ -2,7 +2,7 @@
name = "strs"
version = "0.1.0"
dependencies = [
"aterm 0.16.0",
"aterm 0.13.0 (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)",
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -28,7 +28,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "aterm"
version = "0.16.0"
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)",
......@@ -294,6 +295,7 @@ 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"
......
......@@ -13,7 +13,7 @@ version = "0.1.0"
phf_codegen = "0.7.21"
[dependencies]
aterm = { path = "../aterm" }#"0.16.0"
aterm = "0.13.0"
linked-hash-map = "0.4.2"
phf = "0.7.21"
rand = "0.3.15"
......
use aterm as a;
use aterm::ATerm;
use aterm::BrokenF32;
use aterm::aterm_match::*;
use try_from::{TryFrom, TryInto};
......@@ -30,7 +29,6 @@ pub enum Module {
impl<'a, A> TryFrom<&'a A> for Module
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -66,7 +64,6 @@ pub enum Decl {
impl<'a, A> TryFrom<&'a A> for Decl
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -104,7 +101,6 @@ pub enum ImportModName {
impl<'a, A> TryFrom<&'a A> for ImportModName
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -137,7 +133,6 @@ pub enum SDecl {
impl<'a, A> TryFrom<&'a A> for SDecl
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -171,7 +166,6 @@ pub enum Sort {
impl<'a, A> TryFrom<&'a A> for Sort
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -214,7 +208,6 @@ pub enum OpDecl {
impl<'a, A> TryFrom<&'a A> for OpDecl
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -268,7 +261,6 @@ pub struct ConstType(pub Sort);
impl<'a, A> TryFrom<&'a A> for ConstType
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -296,7 +288,6 @@ pub enum Type {
impl<'a, A> TryFrom<&'a A> for Type
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -332,7 +323,6 @@ pub enum Def {
impl<'a, A> TryFrom<&'a A> for Def
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -390,7 +380,6 @@ pub struct SVar(pub Id);
impl<'a, A> TryFrom<&'a A> for SVar
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -417,7 +406,6 @@ pub enum StrategyDef {
impl<'a, A> TryFrom<&'a A> for StrategyDef
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -487,7 +475,6 @@ pub enum Anno {
impl<'a, A> TryFrom<&'a A> for Anno
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -523,7 +510,6 @@ pub struct VarDec(pub Id, pub Type);
impl<'a, A> TryFrom<&'a A> for VarDec
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -564,7 +550,6 @@ pub enum Strategy {
impl<'a, A> TryFrom<&'a A> for Strategy
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -695,7 +680,6 @@ pub struct Var(pub Id);
impl<'a, A> TryFrom<&'a A> for Var
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -723,7 +707,6 @@ pub enum Term {
impl<'a, A> TryFrom<&'a A> for Term
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -776,7 +759,6 @@ pub enum PreTerm {
impl<'a, A> TryFrom<&'a A> for PreTerm
where
A: ATerm,
<A as ATerm>::Cons: a::Cons,
{
type Err = Error;
......@@ -846,44 +828,84 @@ where
}
}
#[inline]
fn match_string<A, R>(r: &R) -> Result<String, Error>
where
A: ATerm<Rec = R>,
R: Borrow<A>,
<A as ATerm>::Cons: a::Cons,
{
get_string(r.borrow()).ok_or(Error::CTreeParse("string"))
if let a::Term::Application(ref str, ref r) = r.borrow().as_inner().term {
if r.is_empty() {
return Ok(string_unescape(str));
}
}
Err(Error::CTreeParse("string"))
}
#[inline]
fn match_strings<A, R>(r: &R) -> Result<Vec<String>, Error>
where
A: ATerm<Rec = R>,
R: Borrow<A>,
<A as ATerm>::Cons: a::Cons,
{
get_list(r.borrow()).ok_or(Error::CTreeParse("list")).and_then(|r| r.into_iter().map(match_string).collect())
if let a::Term::List(ref r) = r.borrow().as_inner().term {
return r.into_iter()
.map(match_string)
.collect::<Result<Vec<String>, Error>>();
}
Err(Error::CTreeParse("list"))
}
#[inline]
fn match_list<'a, A, R, T>(r: &'a R) -> Result<Vec<T>, Error>
where
T: TryFrom<&'a A, Err = Error>,
A: 'a + ATerm<Rec = R>,
R: Borrow<A>,
<A as ATerm>::Cons: a::Cons,
{
get_list(r.borrow()).ok_or(Error::CTreeParse("list")).and_then(|r| r.into_iter().map(|a| a.borrow().try_into()).collect())
if let a::Term::List(ref r) = r.borrow().as_inner().term {
return r.iter()
.map(|a| a.borrow().try_into())
.collect::<Result<Vec<T>, Error>>();
}
Err(Error::CTreeParse("list"))
}
#[inline]
fn match_<'a, A, R, T>(r: &'a R) -> Result<T, Error>
where
T: TryFrom<&'a A, Err = Error>,
A: 'a + ATerm<Rec = R>,
R: Borrow<A>,
<A as ATerm>::Cons: a::Cons,
{
r.borrow().try_into()
}
// This function seems more complicated than necessary... Not sure how to simplify though
pub fn string_unescape(string: &str) -> String {
let mut result = String::with_capacity(string.len() - 2);
// copy marks the next chunk to be copied without special handling
let mut copy = true;
for chunk in string[1..string.len() - 1].split('\\') {
if copy {
result.push_str(chunk);
copy = false;
} else if chunk.is_empty() {
// if not copy, then an empty chunk represents two consecutive backslashes
result.push('\\');
// The chunk after doesn't need special handling
copy = true;
} else {
// if not copy, a non-empty chunk was preceded by a backslash, so handle escapes:
match &chunk[0..1] {
// These are the usual C escapes, which Stratego doesn't recognise
// 'b' => result.push('\u{0008}'),
// 'f' => result.push('\u{000C}'),
"n" => result.push('\n'),
"r" => result.push('\r'),
"t" => result.push('\t'),
// This handles cases '\'' '"' and is lenient to everything else
char => result.push_str(char),
}
result.push_str(&chunk[1..])
}
}
result
}
......@@ -7,7 +7,6 @@ use primitives::Primitives;
use aterm::{ATerm as A, Term, ATermFactory as ATF};
use aterm::BrokenF32;
use aterm::aterm_match::*;
use try_from::TryInto;
......@@ -85,7 +84,7 @@ pub fn interpret_main(
program,
libraries,
"main_0_0",
factory.list(iter::once(factory.string("main_0_0"))),
factory.list(iter::once(factory.string("main_0_0".to_owned()))),
)
}
......@@ -156,7 +155,7 @@ impl<'d, 'f : 'd> Eval<'d, 'f> for preprocess::Strategy {
}
CallDynamic(ref term_name, ref sargs, ref targs) => {
let strategy_name = context.get_term(term_name)?;
let strategy_name = get_string(&*b(&strategy_name)).ok_or_else(|| {
let strategy_name = b(&strategy_name).get_string().ok_or_else(|| {
Error::UndefinedStrategy(format!(
"Invocation target is invalid \
(cannot be evaluated): {}",
......@@ -243,8 +242,8 @@ impl<'d, 'f : 'd> Eval<'d, 'f> for preprocess::Strategy {
context,
Vec::new(),
vec![
context.factory.string(modname),
context.factory.string(""),
context.factory.string(modname.clone()),
context.factory.string(String::new()),
],
current,
)?;
......@@ -274,7 +273,8 @@ fn eval_match<'d, 'f : 'd>(
eval_match(context, &*term, current)
}
Int(i) => {
get_int(&**current)
current
.get_int()
.and_then(|i2| if i == i2 { Some(()) } else { None })
.ok_or(Error::StrategyFailed)
}
......@@ -283,17 +283,19 @@ fn eval_match<'d, 'f : 'd>(
"WARNING: Pattern matching against floating point literal: very unlikely to \
match!"
);
get_real(&**current)
current
.get_real()
.and_then(|f2| if f == f2 { Some(()) } else { None })
.ok_or(Error::StrategyFailed)
}
Str(ref s) => {
get_string(&**current)
current
.get_string()
.and_then(|s2| if *s == s2 { Some(()) } else { None })
.ok_or(Error::StrategyFailed)
}
Op(ref cons, ref children) if cons == "Cons" && children.len() == 2 => {
get_list(&**current).ok_or(Error::StrategyFailed).and_then(
current.get_list().ok_or(Error::StrategyFailed).and_then(
|v| {
if v.is_empty() {
Err(Error::StrategyFailed)
......@@ -310,15 +312,17 @@ fn eval_match<'d, 'f : 'd>(
)
}
Op(ref cons, ref children) if cons == "Nil" && children.is_empty() => {
get_list(&**current)
current
.get_list()
.and_then(|v| if v.is_empty() { Some(()) } else { None })
.ok_or(Error::StrategyFailed)
}
Op(ref cons, ref children) => {
get_application(&**current)
current
.get_application()
.ok_or(Error::StrategyFailed)
.and_then(
|(current_cons, current_children)| if cons == Borrow::<str>::borrow(current_cons) &&
|(current_cons, current_children)| if cons == current_cons &&
children.len() == current_children.len()
{
children
......@@ -336,7 +340,7 @@ fn eval_match<'d, 'f : 'd>(
Explode(ref cons, ref children) => {
match b(&current).as_inner().term {
Term::Application(ref current_cons, ref current_children) => {
let current_cons = &context.factory.string(current_cons.borrow());
let current_cons = &context.factory.string(current_cons.to_owned());
eval_match(context, cons, current_cons)?;
let current_children =
context.factory.list(current_children.into_iter().cloned());
......
......@@ -5,7 +5,6 @@ use factory::{ATermFactory, ATermRef};
use aterm::BrokenF32;
use aterm::{ATerm as A, ATermFactory as ATF};
use aterm::aterm_match::*;
use try_from::{TryInto, TryFrom};
......@@ -332,7 +331,7 @@ impl BuildTerm {
}
Str(ref s) => {
Ok(context.factory.with_annos(
context.factory.t_string(s),
context.factory.t_string(s.clone()),
annos.unwrap_or_default(),
))
}
......@@ -341,7 +340,7 @@ impl BuildTerm {
let t = Self::build_vec(context, t)?;
if s == "Cons" && t.len() == 2 {
get_list(&*t[1]).ok_or(Error::StrategyFailed).map(|v| {
t[1].get_list().ok_or(Error::StrategyFailed).map(|v| {
context.factory.list(iter::once(t[0].clone()).chain(
v.iter().cloned(),
))
......@@ -351,7 +350,7 @@ impl BuildTerm {
} else {
Ok(context.factory.with_annos(
context.factory.t_application(
&s.clone().into(),
s.clone(),
t.into_iter(),
),
annos.unwrap_or_default(),
......@@ -361,32 +360,32 @@ impl BuildTerm {
Explode(ref cons, ref children) => {
let cons = cons.build(context)?;
let children = children.build(context)?;
let children = get_list(&*children).ok_or(Error::UnknownBehaviour(
let children = children.get_list().ok_or(Error::UnknownBehaviour(
"Non-list in build of explode pattern (#) second argument",
))?;
if let Some(s) = get_string(&*cons) {
let string = context.factory.application(&s.clone().into(), ::std::iter::empty());
if get_string(&*string).is_some() {
if let Some(s) = cons.get_string() {
let string = context.factory.application(s.clone(), ::std::iter::empty());
if string.get_string().is_some() {
Ok(string)
} else {
let application =
context.factory.t_application(&s.into(), children.iter().cloned());
context.factory.t_application(s, children.iter().cloned());
Ok(context.factory.with_annos(
application,
annos.unwrap_or_default(),
))
}
} else if get_application(&*cons).is_some() {
} else if cons.get_application().is_some() {
Err(Error::StrategyFailed)
} else if get_list(&*cons).is_some() {
} else if cons.get_list().is_some() {
Ok(context.factory.list(children.iter().cloned()))
} else if get_blob(&*cons).is_some() {
} else if cons.get_blob().is_some() {
Err(Error::UnknownBehaviour(
"Blob in build of explode pattern (#) first argument",
))
} else if get_placeholder(&*cons).is_some() {
} else if cons.get_placeholder().is_some() {
Err(Error::UnknownBehaviour(
"ATerm placeholder in build of explode pattern (#) first argument",
))
......@@ -399,7 +398,7 @@ impl BuildTerm {
// 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)?;
if let Some(annos_vec) = get_list(&*annos) {
if let Some(annos_vec) = annos.get_list() {
term.build_with_annos(context, Some(annos_vec.to_vec()))
} else {
term.build_with_annos(context, Some(vec![annos.clone()]))
......
......@@ -4,8 +4,7 @@ use factory::{Blob, HashTable, ATermRef};
use preprocess::StrategyDef;
use interpreter::eval_sdef;
use aterm::ATermFactory as ATF;
use aterm::aterm_match::*;
use aterm::{ATermFactory as ATF, ATerm as A};
use std::cell::RefCell;
use std::rc::Rc;
......@@ -68,9 +67,9 @@ pub fn hashtable_create<'d, 'f: 'd>(
count",
));
}
let capacity = get_int(&*targs[0]).ok_or(Error::StrategyFailed)?;
let capacity = targs[0].get_int().ok_or(Error::StrategyFailed)?;
// We don't have a concept of load_factor, so we check the type and then ignore it
let _load_factor = get_int(&*targs[1]).ok_or(Error::StrategyFailed)?;
let _load_factor = targs[1].get_int().ok_or(Error::StrategyFailed)?;
if capacity < 0 || _load_factor < 0 {
Err(Error::UnknownBehaviour(
......@@ -96,7 +95,8 @@ pub fn hashtable_reset<'d, 'f: 'd>(
count",
));
}
let table: Rc<RefCell<HashTable>> = get_blob(&*targs[0])
let table: Rc<RefCell<HashTable>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -130,7 +130,8 @@ pub fn hashtable_put<'d, 'f: 'd>(
count",
));
}
let table: Rc<RefCell<HashTable>> = get_blob(&*targs[0])
let table: Rc<RefCell<HashTable>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -157,7 +158,8 @@ pub fn hashtable_remove<'d, 'f: 'd>(
count",
));
}
let table: Rc<RefCell<HashTable>> = get_blob(&*targs[0])
let table: Rc<RefCell<HashTable>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -182,7 +184,8 @@ pub fn hashtable_get<'d, 'f: 'd>(
count",
));
}
let table: Rc<RefCell<HashTable>> = get_blob(&*targs[0])
let table: Rc<RefCell<HashTable>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -209,7 +212,8 @@ pub fn hashtable_keys<'d, 'f: 'd>(
count",
));
}
let table: Rc<RefCell<HashTable>> = get_blob(&*targs[0])
let table: Rc<RefCell<HashTable>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -237,7 +241,8 @@ pub fn table_fold<'d, 'f: 'd>(
let mut current = targs[0].clone();
let table: Rc<RefCell<HashTable>> = get_blob(&*targs[1])
let table: Rc<RefCell<HashTable>> = targs[1]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -274,7 +279,8 @@ pub fn table_keys_fold<'d, 'f: 'd>(
let mut current = targs[0].clone();
let table: Rc<RefCell<HashTable>> = get_blob(&*targs[1])
let table: Rc<RefCell<HashTable>> = targs[1]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -305,7 +311,8 @@ pub fn table_values_fold<'d, 'f: 'd>(
let mut current = targs[0].clone();
let table: Rc<RefCell<HashTable>> = get_blob(&*targs[1])
let table: Rc<RefCell<HashTable>> = targs[1]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......
......@@ -4,8 +4,7 @@ use factory::{IndexedSet, ATermRef};
use preprocess::StrategyDef;
use interpreter::eval_sdef;
use aterm::ATermFactory as ATF;
use aterm::aterm_match::*;
use aterm::{ATermFactory as ATF, ATerm as A};
use std::cell::RefCell;
use std::cell::RefMut;
......@@ -23,9 +22,9 @@ pub fn indexedSet_create<'d, 'f: 'd>(
"Primitive indexedSet_create called with wrong argument count",
));
}
let capacity = get_int(&*targs[0]).ok_or(Error::StrategyFailed)?;
let capacity = targs[0].get_int().ok_or(Error::StrategyFailed)?;
// We don't have a concept of load_factor, so we check the type and then ignore it
let _load_factor = get_int(&*targs[1]).ok_or(Error::StrategyFailed)?;
let _load_factor = targs[1].get_int().ok_or(Error::StrategyFailed)?;
if capacity < 0 || _load_factor < 0 {
Err(Error::UnknownBehaviour(
......@@ -50,7 +49,8 @@ pub fn indexedSet_reset<'d, 'f: 'd>(
"Primitive indexedSet_destroy called with wrong argument count",
));
}
let set: Rc<RefCell<IndexedSet>> = get_blob(&*targs[0])
let set: Rc<RefCell<IndexedSet>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -83,7 +83,8 @@ pub fn indexedSet_put<'d, 'f: 'd>(
"Primitive indexedSet_put called with wrong argument count",
));
}
let set: Rc<RefCell<IndexedSet>> = get_blob(&*targs[0])
let set: Rc<RefCell<IndexedSet>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -118,7 +119,8 @@ pub fn indexedSet_remove<'d, 'f: 'd>(
"Primitive indexedSet_remove called with wrong argument count",
));
}
let set: Rc<RefCell<IndexedSet>> = get_blob(&*targs[0])
let set: Rc<RefCell<IndexedSet>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -141,7 +143,8 @@ pub fn indexedSet_getIndex<'d, 'f: 'd>(
"Primitive indexedSet_getIndex called with wrong argument count",
));
}
let set: Rc<RefCell<IndexedSet>> = get_blob(&*targs[0])
let set: Rc<RefCell<IndexedSet>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......@@ -168,7 +171,8 @@ pub fn indexedSet_elements<'d, 'f: 'd>(
"Primitive indexedSet_elements called with wrong argument count",
));
}
let set: Rc<RefCell<IndexedSet>> = get_blob(&*targs[0])
let set: Rc<RefCell<IndexedSet>> = targs[0]
.get_blob()
.cloned()
.ok_or(())
.and_then(TryInto::try_into)
......
......@@ -3,8 +3,7 @@ use error::{Error, Result};
use factory::ATermRef;
use preprocess::StrategyDef;
use aterm::ATermFactory as ATF;
use aterm::aterm_match::*;
use aterm::{ATermFactory as ATF, ATerm as A};
pub fn is_int<'d, 'f: 'd>(
_context: &MutContext<'d, 'f>,
......@@ -17,7 +16,7 @@ pub fn is_int<'d, 'f: 'd>(
"Primitive is_int called with wrong argument count",
));
}
get_int(&*targs[0]).map(|_| current).ok_or(
targs[0].get_int().map(|_| current).ok_or(
Error::StrategyFailed,
)
}
......@@ -33,10 +32,11 @@ pub fn int<'d, 'f: 'd>(
"Primitive int called with wrong argument count",
));
}
get_int(&*targs[0])
targs[0]
.get_int()
.map(|_| targs[0].clone())
.or_else(|| {
get_real(&*targs[0]).map(|r| context.factory.int(r as i32))
targs[0].get_real().map(|r| context.factory.int(r as i32))
})
.ok_or(Error::StrategyFailed)
}
......@@ -52,8 +52,8 @@ pub fn iori<'d, 'f: 'd>(
"Primitive iori called with wrong argument count",
));
}
let i1 = get_int(&*targs[0]).ok_or(Error::StrategyFailed)?;
let i2 = get_int(&*targs[1]).ok_or(Error::StrategyFailed)?;
let i1 = targs[0].get_int().ok_or(Error::StrategyFailed)?;
let i2 = targs[1].get_int().ok_or(Error::StrategyFailed)?;
Ok(context.factory.int(i1 | i2))
}
......@@ -68,8 +68,8 @@ pub fn xori<'d, 'f: 'd>(
"Primitive xori called with wrong argument count",
));
}
let i1 = get_int(&*targs[0]).ok_or(Error::StrategyFailed)?;
let i2 = get_int(&*targs[1]).ok_or(Error::StrategyFailed)?;
let i1 = targs[0].get_int().ok_or(Error::StrategyFailed)?;
let i2 = targs[1].get_int().ok_or(Error::StrategyFailed)?;
Ok(context.factory.int(i1 ^ i2))
}
......@@ -84,8 +84,8 @@ pub fn andi<'d, 'f: 'd>(
"Primitive andi called with wrong argument count",
));
}
let i1 = get_int(&*targs[0]).ok_or(Error::StrategyFailed)?;
let i2 = get_int(&*targs[1]).ok_or(Error::StrategyFailed)?;
let i1 = targs[0].get_int().ok_or(Error::StrategyFailed)?;
let i2 = targs[1].get_int().ok_or(Error::StrategyFailed)?;
Ok(context.factory.int(i1 & i2))
}
......@@ -100,8 +100,8 @@ pub fn shli<'d, 'f: 'd>(
"Primitive shli called with wrong argument count",
));
}
let i1 = get_int(&*targs[0]).ok_or(Error::StrategyFailed)?;
let i2 = get_int(&*targs[1]).ok_or(Error::StrategyFailed)?;
let i1 = targs[0].get_int().ok_or(Error::StrategyFailed)?;
let i2 = targs[1].get_int().ok_or(Error::StrategyFailed)?;
Ok(context.factory.int(i1 << i2))
}
......@@ -116,8 +116,8 @@ pub fn shri<'d, 'f: 'd>(
"Primitive shri called with wrong argument count",
));
}
let i1 = get_int(&*targs[0]).ok_or(Error::StrategyFailed)?;
let i2 = get_int(&*targs[1]).ok_or(Error::StrategyFailed)?;
let i1 = targs[0].get_int().ok_or(Error::StrategyFailed)?;
let i2 = targs[1].get_int().ok_or(Error::StrategyFailed)?;
Ok(context.factory.int(i1 >> i2))
}
......@@ -132,8 +132,8 @@ pub fn addi<'d, 'f: 'd>(
"Primitive addi called with wrong argument count",
));
}
let i1 = get_int(&*targs[0]).ok_or(Error::StrategyFailed)?;
let i2 = get_int(&*targs[1]).ok_or(Error::StrategyFailed)?;
let i1 = targs[0].get_int().ok_or(Error::StrategyFailed)?;
let i2 = targs[1].get_int().ok_or(Error::StrategyFailed)?;
Ok(context.factory.int(i1 + i2))
}
......@@ -148,8 +148,8 @@ pub fn divi<'d, 'f: 'd>(
"Primitive divi called with wrong argument count",
));
}
let i1 = get_int(&*targs[0]).ok_or(Error::StrategyFailed)?;
let i2 = get_int(&*targs[1]).ok_or(Error::StrategyFailed)?;
let i1 = targs[0].get_int().ok_or(Error::StrategyFailed)?;
let i2 = targs[1].get_int().ok_or(Error::StrategyFailed)?;
Ok(context.factory.int(i1 / i2))
}