Fixup: follow compiler.
This commit is contained in:
parent
cfbe5fd3cc
commit
e76d26eb3c
|
@ -2669,6 +2669,7 @@ dependencies = [
|
||||||
"itertools",
|
"itertools",
|
||||||
"k256",
|
"k256",
|
||||||
"num-bigint",
|
"num-bigint",
|
||||||
|
"num-traits",
|
||||||
"pallas-addresses",
|
"pallas-addresses",
|
||||||
"pallas-codec",
|
"pallas-codec",
|
||||||
"pallas-crypto",
|
"pallas-crypto",
|
||||||
|
|
|
@ -34,6 +34,7 @@ indexmap = "1.9.2"
|
||||||
secp256k1 = { version = "0.26.0", optional = true }
|
secp256k1 = { version = "0.26.0", optional = true }
|
||||||
k256 = { version = "0.12.0", optional = true }
|
k256 = { version = "0.12.0", optional = true }
|
||||||
num-bigint = "0.4.3"
|
num-bigint = "0.4.3"
|
||||||
|
num-traits = "0.2.15"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use num_traits::sign::Signed;
|
||||||
use std::{collections::VecDeque, ops::Deref, rc::Rc};
|
use std::{collections::VecDeque, ops::Deref, rc::Rc};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -545,10 +546,10 @@ impl Value {
|
||||||
match self {
|
match self {
|
||||||
Value::Con(c) => match c.as_ref() {
|
Value::Con(c) => match c.as_ref() {
|
||||||
Constant::Integer(i) => {
|
Constant::Integer(i) => {
|
||||||
if *i == 0 {
|
if *i == 0.into() {
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
((i.abs() as f64).log2().floor() as i64 / 64) + 1
|
(i.abs().log2().floor() as i64 / 64) + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Constant::ByteString(b) => {
|
Constant::ByteString(b) => {
|
||||||
|
@ -748,10 +749,10 @@ mod test {
|
||||||
term: Term::Apply {
|
term: Term::Apply {
|
||||||
function: Term::Apply {
|
function: Term::Apply {
|
||||||
function: Term::Builtin(DefaultFunction::AddInteger).into(),
|
function: Term::Builtin(DefaultFunction::AddInteger).into(),
|
||||||
argument: Term::Constant(Constant::Integer(i128::MAX).into()).into(),
|
argument: Term::Constant(Constant::Integer(i128::MAX.into()).into()).into(),
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
argument: Term::Constant(Constant::Integer(i128::MAX).into()).into(),
|
argument: Term::Constant(Constant::Integer(i128::MAX.into()).into()).into(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{rc::Rc, str::FromStr};
|
use std::{ops::Neg, rc::Rc, str::FromStr};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{Constant, Name, Program, Term, Type},
|
ast::{Constant, Name, Program, Term, Type},
|
||||||
|
@ -6,6 +6,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use interner::Interner;
|
use interner::Interner;
|
||||||
|
use num_bigint::BigInt;
|
||||||
use pallas_primitives::{alonzo::PlutusData, Fragment};
|
use pallas_primitives::{alonzo::PlutusData, Fragment};
|
||||||
use peg::{error::ParseError, str::LineCol};
|
use peg::{error::ParseError, str::LineCol};
|
||||||
|
|
||||||
|
@ -157,8 +158,8 @@ peg::parser! {
|
||||||
rule number() -> isize
|
rule number() -> isize
|
||||||
= n:$("-"* ['0'..='9']+) {? n.parse().or(Err("isize")) }
|
= n:$("-"* ['0'..='9']+) {? n.parse().or(Err("isize")) }
|
||||||
|
|
||||||
rule big_number() -> i128
|
rule big_number() -> BigInt
|
||||||
= n:$("-"* ['0'..='9']+) {? n.parse().or(Err("i128")) }
|
= n:$("-"* ['0'..='9']+) {? (if n.starts_with("-") { BigInt::parse_bytes(&n.as_bytes()[1..], 10).map(|i| i.neg()) } else { BigInt::parse_bytes(n.as_bytes(), 10) }).ok_or("BigInt") }
|
||||||
|
|
||||||
rule boolean() -> bool
|
rule boolean() -> bool
|
||||||
= b:$("True" / "False") { b == "True" }
|
= b:$("True" / "False") { b == "True" }
|
||||||
|
@ -277,7 +278,7 @@ mod test {
|
||||||
parameter_name: x.clone().into(),
|
parameter_name: x.clone().into(),
|
||||||
body: Rc::new(Term::Var(x.into())),
|
body: Rc::new(Term::Var(x.into())),
|
||||||
}),
|
}),
|
||||||
argument: Rc::new(Term::Constant(Constant::Integer(0).into()))
|
argument: Rc::new(Term::Constant(Constant::Integer(0.into()).into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -344,7 +345,7 @@ mod test {
|
||||||
super::program(uplc).unwrap(),
|
super::program(uplc).unwrap(),
|
||||||
Program::<Name> {
|
Program::<Name> {
|
||||||
version: (11, 22, 33),
|
version: (11, 22, 33),
|
||||||
term: Term::Constant(Constant::Integer(11).into()),
|
term: Term::Constant(Constant::Integer(11.into()).into()),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -492,7 +493,7 @@ mod test {
|
||||||
term: Term::Apply {
|
term: Term::Apply {
|
||||||
function: Rc::new(Term::Apply {
|
function: Rc::new(Term::Apply {
|
||||||
function: Rc::new(Term::Builtin(DefaultFunction::ConsByteString)),
|
function: Rc::new(Term::Builtin(DefaultFunction::ConsByteString)),
|
||||||
argument: Rc::new(Term::Constant(Constant::Integer(256).into())),
|
argument: Rc::new(Term::Constant(Constant::Integer(256.into()).into())),
|
||||||
}),
|
}),
|
||||||
argument: Rc::new(Term::Constant(Constant::ByteString(vec![]).into()))
|
argument: Rc::new(Term::Constant(Constant::ByteString(vec![]).into()))
|
||||||
}
|
}
|
||||||
|
@ -511,9 +512,9 @@ mod test {
|
||||||
function: Rc::new(Term::Apply {
|
function: Rc::new(Term::Apply {
|
||||||
function: Rc::new(Term::Apply {
|
function: Rc::new(Term::Apply {
|
||||||
function: Rc::new(Term::Builtin(DefaultFunction::SliceByteString)),
|
function: Rc::new(Term::Builtin(DefaultFunction::SliceByteString)),
|
||||||
argument: Rc::new(Term::Constant(Constant::Integer(1).into())),
|
argument: Rc::new(Term::Constant(Constant::Integer(1.into()).into())),
|
||||||
}),
|
}),
|
||||||
argument: Rc::new(Term::Constant(Constant::Integer(2).into())),
|
argument: Rc::new(Term::Constant(Constant::Integer(2.into()).into())),
|
||||||
}),
|
}),
|
||||||
argument: Rc::new(Term::Constant(
|
argument: Rc::new(Term::Constant(
|
||||||
Constant::ByteString(vec![0x00, 0xFF, 0xAA]).into()
|
Constant::ByteString(vec![0x00, 0xFF, 0xAA]).into()
|
||||||
|
@ -553,7 +554,7 @@ mod test {
|
||||||
argument: Rc::new(Term::Constant(Constant::ByteString(vec![0x00]).into()))
|
argument: Rc::new(Term::Constant(Constant::ByteString(vec![0x00]).into()))
|
||||||
}),
|
}),
|
||||||
argument: Rc::new(Term::Constant(
|
argument: Rc::new(Term::Constant(
|
||||||
Constant::Integer(9223372036854775808).into()
|
Constant::Integer(9223372036854775808.into()).into()
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -704,9 +705,12 @@ mod test {
|
||||||
vec![
|
vec![
|
||||||
Constant::ProtoList(
|
Constant::ProtoList(
|
||||||
Type::Integer,
|
Type::Integer,
|
||||||
vec![Constant::Integer(14), Constant::Integer(42)]
|
vec![Constant::Integer(14.into()), Constant::Integer(42.into())]
|
||||||
),
|
),
|
||||||
Constant::ProtoList(Type::Integer, vec![Constant::Integer(1337)])
|
Constant::ProtoList(
|
||||||
|
Type::Integer,
|
||||||
|
vec![Constant::Integer(1337.into())]
|
||||||
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
|
@ -733,7 +737,7 @@ mod test {
|
||||||
term: Term::Constant(
|
term: Term::Constant(
|
||||||
Constant::ProtoList(
|
Constant::ProtoList(
|
||||||
Type::Integer,
|
Type::Integer,
|
||||||
vec![Constant::Integer(14), Constant::Integer(42)],
|
vec![Constant::Integer(14.into()), Constant::Integer(42.into())],
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
)
|
)
|
||||||
|
@ -776,7 +780,7 @@ mod test {
|
||||||
Constant::ProtoPair(
|
Constant::ProtoPair(
|
||||||
Type::Integer,
|
Type::Integer,
|
||||||
Type::ByteString,
|
Type::ByteString,
|
||||||
Constant::Integer(14).into(),
|
Constant::Integer(14.into()).into(),
|
||||||
Constant::ByteString(vec![0x42]).into(),
|
Constant::ByteString(vec![0x42]).into(),
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
|
@ -801,7 +805,7 @@ mod test {
|
||||||
Constant::String(String::from("foo")).into(),
|
Constant::String(String::from("foo")).into(),
|
||||||
Constant::ProtoList(
|
Constant::ProtoList(
|
||||||
Type::Integer,
|
Type::Integer,
|
||||||
vec![Constant::Integer(14), Constant::Integer(42)],
|
vec![Constant::Integer(14.into()), Constant::Integer(42.into())],
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
)
|
)
|
||||||
|
@ -828,8 +832,8 @@ mod test {
|
||||||
Constant::ProtoPair(
|
Constant::ProtoPair(
|
||||||
Type::Integer,
|
Type::Integer,
|
||||||
Type::Integer,
|
Type::Integer,
|
||||||
Constant::Integer(14).into(),
|
Constant::Integer(14.into()).into(),
|
||||||
Constant::Integer(42).into()
|
Constant::Integer(42.into()).into()
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
)
|
)
|
||||||
|
@ -859,9 +863,9 @@ mod test {
|
||||||
term: Term::Apply {
|
term: Term::Apply {
|
||||||
function: Rc::new(Term::Apply {
|
function: Rc::new(Term::Apply {
|
||||||
function: Rc::new(Term::Builtin(default_function)),
|
function: Rc::new(Term::Builtin(default_function)),
|
||||||
argument: Rc::new(Term::Constant(Constant::Integer(x).into())),
|
argument: Rc::new(Term::Constant(Constant::Integer(x.into()).into())),
|
||||||
}),
|
}),
|
||||||
argument: Rc::new(Term::Constant(Constant::Integer(y).into()))
|
argument: Rc::new(Term::Constant(Constant::Integer(y.into()).into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::program_builder::WithTerm;
|
||||||
|
|
||||||
pub trait WithConstant: WithTerm {
|
pub trait WithConstant: WithTerm {
|
||||||
fn with_int(self, int: i128) -> Self::Next {
|
fn with_int(self, int: i128) -> Self::Next {
|
||||||
let term = Term::Constant(Constant::Integer(int).into());
|
let term = Term::Constant(Constant::Integer(int.into()).into());
|
||||||
self.next(term)
|
self.next(term)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue