diff --git a/lykiadb-server/src/engine/interpreter.rs b/lykiadb-server/src/engine/interpreter.rs index 4121623..0d7b696 100644 --- a/lykiadb-server/src/engine/interpreter.rs +++ b/lykiadb-server/src/engine/interpreter.rs @@ -15,7 +15,7 @@ use super::error::ExecutionError; use crate::plan::planner::Planner; use crate::util::{alloc_shared, Shared}; -use crate::value::callable::{Callable, CallableType, Function, Stateful}; +use crate::value::callable::{Callable, CallableKind, Function, Stateful}; use crate::value::environment::{EnvId, Environment}; use crate::value::types::{eval_binary, RV}; @@ -466,7 +466,7 @@ impl VisitorMut for Interpreter { closure: self.env, }; - let callable = RV::Callable(Callable::new(Some(parameters.len()), CallableType::Any, fun.into())); + let callable = RV::Callable(Callable::new(Some(parameters.len()), CallableKind::Generic, fun.into())); if name.is_some() { // TODO(vck): Callable shouldn't be cloned here diff --git a/lykiadb-server/src/engine/stdlib/mod.rs b/lykiadb-server/src/engine/stdlib/mod.rs index f0e77bc..908b732 100644 --- a/lykiadb-server/src/engine/stdlib/mod.rs +++ b/lykiadb-server/src/engine/stdlib/mod.rs @@ -1,10 +1,8 @@ -use std::sync::Arc; - use rustc_hash::FxHashMap; use crate::{ util::{alloc_shared, Shared}, - value::{callable::{Callable, CallableType, Function}, types::RV}, + value::{callable::{Callable, CallableKind, Function}, types::RV}, }; use self::{ @@ -30,7 +28,7 @@ pub fn stdlib(out: Option>) -> FxHashMap { benchmark_namespace.insert( "fib".to_owned(), - RV::Callable(Callable::new(Some(1), CallableType::Any, Function::Lambda { function: nt_fib })), + RV::Callable(Callable::new(Some(1), CallableKind::Generic, Function::Lambda { function: nt_fib })), ); json_namespace.insert( @@ -38,7 +36,7 @@ pub fn stdlib(out: Option>) -> FxHashMap { RV::Callable( Callable::new( Some(1), - CallableType::Any, + CallableKind::Generic, Function::Lambda { function: nt_json_encode, } @@ -50,7 +48,7 @@ pub fn stdlib(out: Option>) -> FxHashMap { "parse".to_owned(), RV::Callable(Callable::new( Some(1), - CallableType::Any, + CallableKind::Generic, Function::Lambda { function: nt_json_decode, }), @@ -61,7 +59,7 @@ pub fn stdlib(out: Option>) -> FxHashMap { "clock".to_owned(), RV::Callable(Callable::new( Some(0), - CallableType::Any, + CallableKind::Generic, Function::Lambda { function: nt_clock } )), ); @@ -71,7 +69,7 @@ pub fn stdlib(out: Option>) -> FxHashMap { test_namespace.insert( "out".to_owned(), - RV::Callable(Callable::new(None, CallableType::Any, Function::Stateful(out.unwrap().clone()))), + RV::Callable(Callable::new(None, CallableKind::Generic, Function::Stateful(out.unwrap().clone()))), ); std.insert( @@ -88,7 +86,7 @@ pub fn stdlib(out: Option>) -> FxHashMap { std.insert("Time".to_owned(), RV::Object(alloc_shared(time_namespace))); std.insert( "print".to_owned(), - RV::Callable(Callable::new(None, CallableType::Any, Function::Lambda { function: nt_print })), + RV::Callable(Callable::new(None, CallableKind::Generic, Function::Lambda { function: nt_print })), ); std diff --git a/lykiadb-server/src/value/callable.rs b/lykiadb-server/src/value/callable.rs index c58c7e2..65137f3 100644 --- a/lykiadb-server/src/value/callable.rs +++ b/lykiadb-server/src/value/callable.rs @@ -6,23 +6,23 @@ use super::environment::EnvId; use super::types::RV; #[derive(Debug, Clone)] -pub enum CallableType { - Any, +pub enum CallableKind { + Generic, Aggregator, } #[derive(Clone, Debug)] pub struct Callable { pub arity: Option, - pub call_type: CallableType, + pub kind: CallableKind, pub function: Arc, } impl Callable { - pub fn new(arity: Option, call_type: CallableType, function: Function) -> Self { + pub fn new(arity: Option, call_type: CallableKind, function: Function) -> Self { Callable { arity, - call_type, + kind: call_type, function: Arc::new(function), } }