Add Podlang pretty-printing (#353)
* Add Podlang pretty-printing * Review feedback changes * Formatting * Use Display impl for printing StatementTmplArg
This commit is contained in:
parent
8429cd224d
commit
9f8335756c
5 changed files with 680 additions and 15 deletions
|
|
@ -1,4 +1,7 @@
|
|||
use std::{fmt, iter};
|
||||
use std::{
|
||||
fmt::{self, Display},
|
||||
iter,
|
||||
};
|
||||
|
||||
use plonky2::field::types::Field;
|
||||
use schemars::JsonSchema;
|
||||
|
|
@ -44,6 +47,33 @@ pub enum NativePredicate {
|
|||
Gt = 1006,
|
||||
}
|
||||
|
||||
impl Display for NativePredicate {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let s = match self {
|
||||
NativePredicate::None => "None",
|
||||
NativePredicate::False => "False",
|
||||
NativePredicate::Equal => "Equal",
|
||||
NativePredicate::NotEqual => "NotEqual",
|
||||
NativePredicate::Lt => "Lt",
|
||||
NativePredicate::LtEq => "LtEq",
|
||||
NativePredicate::Gt => "Gt",
|
||||
NativePredicate::GtEq => "GtEq",
|
||||
NativePredicate::Contains => "Contains",
|
||||
NativePredicate::NotContains => "NotContains",
|
||||
NativePredicate::SumOf => "SumOf",
|
||||
NativePredicate::ProductOf => "ProductOf",
|
||||
NativePredicate::MaxOf => "MaxOf",
|
||||
NativePredicate::HashOf => "HashOf",
|
||||
NativePredicate::DictContains => "DictContains",
|
||||
NativePredicate::DictNotContains => "DictNotContains",
|
||||
NativePredicate::ArrayContains => "ArrayContains",
|
||||
NativePredicate::SetContains => "SetContains",
|
||||
NativePredicate::SetNotContains => "SetNotContains",
|
||||
};
|
||||
write!(f, "{}", s)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToFields for NativePredicate {
|
||||
fn to_fields(&self, _params: &Params) -> Vec<F> {
|
||||
vec![F::from_canonical_u64(*self as u64)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue