@@ -13,6 +13,7 @@ use crate::middleware::{
1313 hash_str, Hash , MainPodInputs , NativeOperation , NativePredicate , Params , PodId , PodProver ,
1414 PodSigner , SELF ,
1515} ;
16+ use crate :: middleware:: { OperationType , Predicate } ;
1617
1718mod custom;
1819mod operation;
@@ -254,7 +255,7 @@ impl MainPodBuilder {
254255 for arg in args. iter_mut ( ) {
255256 match arg {
256257 OperationArg :: Statement ( s) => {
257- if s. 0 == NativePredicate :: ValueOf {
258+ if s. 0 == Predicate :: Native ( NativePredicate :: ValueOf ) {
258259 st_args. push ( s. 1 [ 0 ] . clone ( ) )
259260 } else {
260261 panic ! ( "Invalid statement argument." ) ;
@@ -266,7 +267,7 @@ impl MainPodBuilder {
266267 let value_of_st = self . op (
267268 public,
268269 Operation (
269- NativeOperation :: NewEntry ,
270+ OperationType :: Native ( NativeOperation :: NewEntry ) ,
270271 vec ! [ OperationArg :: Entry ( k. clone( ) , v. clone( ) ) ] ,
271272 ) ,
272273 ) ;
@@ -291,36 +292,49 @@ impl MainPodBuilder {
291292
292293 pub fn op ( & mut self , public : bool , mut op : Operation ) -> Statement {
293294 use NativeOperation :: * ;
294- let Operation ( op_type, ref mut args) = op;
295+ let Operation ( op_type, ref mut args) = & mut op;
295296 // TODO: argument type checking
296297 let st = match op_type {
297- None => Statement ( NativePredicate :: None , vec ! [ ] ) ,
298- NewEntry => Statement ( NativePredicate :: ValueOf , self . op_args_entries ( public, args) ) ,
299- CopyStatement => todo ! ( ) ,
300- EqualFromEntries => {
301- Statement ( NativePredicate :: Equal , self . op_args_entries ( public, args) )
302- }
303- NotEqualFromEntries => Statement (
304- NativePredicate :: NotEqual ,
305- self . op_args_entries ( public, args) ,
306- ) ,
307- GtFromEntries => Statement ( NativePredicate :: Gt , self . op_args_entries ( public, args) ) ,
308- LtFromEntries => Statement ( NativePredicate :: Lt , self . op_args_entries ( public, args) ) ,
309- TransitiveEqualFromStatements => todo ! ( ) ,
310- GtToNotEqual => todo ! ( ) ,
311- LtToNotEqual => todo ! ( ) ,
312- ContainsFromEntries => Statement (
313- NativePredicate :: Contains ,
314- self . op_args_entries ( public, args) ,
315- ) ,
316- NotContainsFromEntries => Statement (
317- NativePredicate :: NotContains ,
318- self . op_args_entries ( public, args) ,
319- ) ,
320- RenameContainedBy => todo ! ( ) ,
321- SumOf => todo ! ( ) ,
322- ProductOf => todo ! ( ) ,
323- MaxOf => todo ! ( ) ,
298+ OperationType :: Native ( o) => match o {
299+ None => Statement ( Predicate :: Native ( NativePredicate :: None ) , vec ! [ ] ) ,
300+ NewEntry => Statement (
301+ Predicate :: Native ( NativePredicate :: ValueOf ) ,
302+ self . op_args_entries ( public, args) ,
303+ ) ,
304+ CopyStatement => todo ! ( ) ,
305+ EqualFromEntries => Statement (
306+ Predicate :: Native ( NativePredicate :: Equal ) ,
307+ self . op_args_entries ( public, args) ,
308+ ) ,
309+ NotEqualFromEntries => Statement (
310+ Predicate :: Native ( NativePredicate :: NotEqual ) ,
311+ self . op_args_entries ( public, args) ,
312+ ) ,
313+ GtFromEntries => Statement (
314+ Predicate :: Native ( NativePredicate :: Gt ) ,
315+ self . op_args_entries ( public, args) ,
316+ ) ,
317+ LtFromEntries => Statement (
318+ Predicate :: Native ( NativePredicate :: Lt ) ,
319+ self . op_args_entries ( public, args) ,
320+ ) ,
321+ TransitiveEqualFromStatements => todo ! ( ) ,
322+ GtToNotEqual => todo ! ( ) ,
323+ LtToNotEqual => todo ! ( ) ,
324+ ContainsFromEntries => Statement (
325+ Predicate :: Native ( NativePredicate :: Contains ) ,
326+ self . op_args_entries ( public, args) ,
327+ ) ,
328+ NotContainsFromEntries => Statement (
329+ Predicate :: Native ( NativePredicate :: NotContains ) ,
330+ self . op_args_entries ( public, args) ,
331+ ) ,
332+ RenameContainedBy => todo ! ( ) ,
333+ SumOf => todo ! ( ) ,
334+ ProductOf => todo ! ( ) ,
335+ MaxOf => todo ! ( ) ,
336+ } ,
337+ _ => todo ! ( ) ,
324338 } ;
325339 self . operations . push ( op) ;
326340 if public {
@@ -440,7 +454,7 @@ impl MainPodCompiler {
440454
441455 fn compile_op ( & self , op : & Operation ) -> middleware:: Operation {
442456 // TODO
443- let mop_code: middleware :: NativeOperation = op. 0 . into ( ) ;
457+ let mop_code: OperationType = op. 0 . clone ( ) ;
444458 let mop_args =
445459 op. 1 . iter ( )
446460 . flat_map ( |arg| self . compile_op_arg ( arg) . map ( |s| s. try_into ( ) . unwrap ( ) ) )
@@ -496,22 +510,22 @@ pub mod build_utils {
496510 #[ macro_export]
497511 macro_rules! op {
498512 ( eq, $( $arg: expr) ,+) => { crate :: frontend:: Operation (
499- crate :: middleware:: NativeOperation :: EqualFromEntries ,
513+ crate :: middleware:: OperationType :: Native ( crate :: middleware :: NativeOperation :: EqualFromEntries ) ,
500514 crate :: op_args!( $( $arg) ,* ) ) } ;
501515 ( ne, $( $arg: expr) ,+) => { crate :: frontend:: Operation (
502- crate :: middleware:: NativeOperation :: NotEqualFromEntries ,
516+ crate :: middleware:: OperationType :: Native ( crate :: middleware :: NativeOperation :: NotEqualFromEntries ) ,
503517 crate :: op_args!( $( $arg) ,* ) ) } ;
504518 ( gt, $( $arg: expr) ,+) => { crate :: frontend:: Operation (
505- crate :: middleware:: NativeOperation :: GtFromEntries ,
519+ crate :: middleware:: OperationType :: Native ( crate :: middleware :: NativeOperation :: GtFromEntries ) ,
506520 crate :: op_args!( $( $arg) ,* ) ) } ;
507521 ( lt, $( $arg: expr) ,+) => { crate :: frontend:: Operation (
508- crate :: middleware:: NativeOperation :: LtFromEntries ,
522+ crate :: middleware:: OperationType :: Native ( crate :: middleware :: NativeOperation :: LtFromEntries ) ,
509523 crate :: op_args!( $( $arg) ,* ) ) } ;
510524 ( contains, $( $arg: expr) ,+) => { crate :: frontend:: Operation (
511- crate :: middleware:: NativeOperation :: ContainsFromEntries ,
525+ crate :: middleware:: OperationType :: Native ( crate :: middleware :: NativeOperation :: ContainsFromEntries ) ,
512526 crate :: op_args!( $( $arg) ,* ) ) } ;
513527 ( not_contains, $( $arg: expr) ,+) => { crate :: frontend:: Operation (
514- crate :: middleware:: NativeOperation :: NotContainsFromEntries ,
528+ crate :: middleware:: OperationType :: Native ( crate :: middleware :: NativeOperation :: NotContainsFromEntries ) ,
515529 crate :: op_args!( $( $arg) ,* ) ) } ;
516530 }
517531}
0 commit comments