Commit 1c472b1d authored by Jeff Smits's avatar Jeff Smits

Fixed bugs in explode related primitives

parent 647ed7f2
......@@ -2,7 +2,7 @@
name = "strs"
version = "0.1.0"
dependencies = [
"aterm 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"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,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "aterm"
version = "0.12.3"
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)",
......@@ -295,7 +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.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e038f20085acb20b753ceda45738def153204af6fba40f77ec8ddcca84af9e8c"
"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 = "0.12.3"
aterm = "0.13.0"
linked-hash-map = "0.4.2"
phf = "0.7.21"
rand = "0.3.15"
......
......@@ -24,24 +24,20 @@ pub fn get_constructor<'a>(context: &MutContext<'a>,
return Err(Error::UnknownBehaviour("Primitive get_constructor called with wrong argument \
count"));
}
targs[0]
.get_string()
.map(|s| context.factory.string(s))
.ok_or(Error::StrategyFailed)
.or_else(|_| match b(&targs[0]).as_inner().term {
Term::Int(_) |
Term::Long(_) |
Term::List(_) |
Term::Placeholder(_) |
Term::Real(_) => Ok(targs[0].clone()),
Term::Application(ref v, _) => Ok(context.factory.string(v.clone())),
Term::Blob(ref b) => {
match b(&targs[0]).as_inner().term {
Term::Int(_) |
Term::Long(_) |
Term::List(_) |
Term::Placeholder(_) |
Term::Real(_) => Ok(targs[0].clone()),
Term::Application(ref v, _) => Ok(context.factory.string(v.clone())),
Term::Blob(ref b) => {
let mut str_repr = String::from("BLOB_");
b.to_ascii(&mut str_repr)
.map_err(|_| Error::StrategyFailed)?;
Ok(context.factory.string(str_repr))
}
})
}
}
pub fn mkterm<'a>(context: &MutContext<'a>,
......@@ -100,7 +96,7 @@ pub fn get_arguments<'a>(context: &MutContext<'a>,
return Err(Error::UnknownBehaviour("Primitive get_arguments called with wrong argument \
count"));
}
let empty_list = context.factory.list(::std::iter::empty());
let empty_list = context.factory.application(String::from("Nil"), ::std::iter::empty());
// filter out strings first as we'll match on application later
targs[0]
.get_string()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment