[Evaluator]
Refactor GadgetCaller to use acir instead of LowLevelStdLib
// Note that standard library refers to higher level methods that are exposed by the underlying plonk api
// Currently, we do not have a way to import rasa modules, but in the future, the std library will be
// a mixture of useful gadgets from the plonk library and also rasa functions
-use crate::{CallExpression, Environment, Evaluator, Polynomial, Ident};
+use crate::{CallExpression, Environment, Evaluator, Object, Ident};
mod sha256;
pub use sha256::Sha256Gadget;
-pub use low_level_std_lib::{LowLevelStandardLibrary, HashLibrary};
+use acir::OPCODE;
pub trait GadgetCaller {
- fn name() -> LowLevelStandardLibrary;
+ fn name() -> acir::OPCODE;
fn call(
evaluator: &mut Evaluator,
env: &mut Environment,
call_expr: CallExpression,
- ) -> Polynomial;
+ ) -> Object;
}
pub fn call_low_level(
evaluator: &mut Evaluator,
env: &mut Environment,
func_name: &Ident,
- call_expr: CallExpression) -> Polynomial
+ call_expr: CallExpression) -> Object
{
- let std_lib_func = LowLevelStandardLibrary::find(func_name);
-
- let func = match std_lib_func {
- None => panic!("cannot find a function with that name in the low level standard library"),
+ let func = match OPCODE::lookup(&func_name.0) {
+ None => panic!("cannot find a low level function with that name in the low level standard library"),
Some(func) => func
};
match func {
- LowLevelStandardLibrary::Hash(HashLibrary::SHA256) => Sha256Gadget::call(evaluator, env, call_expr),
- LowLevelStandardLibrary::Hash(HashLibrary::AES) => panic!("Currently the compiler does not have an implementation for aes"),
+ OPCODE::SHA256 => Sha256Gadget::call(evaluator, env, call_expr),
+ k => panic!("The OPCODE {} exists, however, currently the compiler does not have a concrete implementation for it", k),
}
}
