Skip to content

Commit

Permalink
fix: Value reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
can-keklik committed Sep 29, 2024
1 parent 4f8c26c commit fb66d9f
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion lykiadb-server/src/comm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::engine::{Runtime, RuntimeMode};
use crate::value::types::RV;
use crate::value::RV;
use ::std::time::Instant;
use tcp::TcpConnection;
use tokio::net::TcpStream;
Expand Down
6 changes: 3 additions & 3 deletions lykiadb-server/src/engine/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::plan::planner::Planner;
use crate::util::{alloc_shared, Shared};
use crate::value::callable::{Callable, CallableKind, Function, Stateful};
use crate::value::environment::{EnvId, Environment};
use crate::value::types::{eval_binary, RV};
use crate::value::{RV, types::eval_binary};

use std::sync::Arc;
use std::vec;
Expand Down Expand Up @@ -706,7 +706,7 @@ impl Stateful for Output {
pub mod test_helpers {
use crate::engine::{Runtime, RuntimeMode};
use crate::util::{alloc_shared, Shared};
use crate::value::types::RV;
use crate::value::RV;

use super::Output;

Expand All @@ -725,7 +725,7 @@ pub mod test_helpers {

#[cfg(test)]
mod test {
use crate::value::types::RV;
use crate::value::RV;

use super::test_helpers::get_runtime;

Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use self::stdlib::stdlib;
use crate::engine::interpreter::Interpreter;
use crate::util::{alloc_shared, Shared};
use crate::value::environment::Environment;
use crate::value::types::RV;
use crate::value::RV;
use lykiadb_lang::parser::Parser;
use lykiadb_lang::tokenizer::scanner::Scanner;
use serde_json::Value;
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/src/engine/stdlib/fib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
engine::interpreter::{HaltReason, InterpretError, Interpreter},
value::types::RV,
value::RV,
};

fn _calculate(n: f64) -> f64 {
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/src/engine/stdlib/json.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
engine::interpreter::{HaltReason, InterpretError, Interpreter},
value::types::RV,
value::RV,
};
use serde_json::json;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/src/engine/stdlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc_hash::FxHashMap;

use crate::{
util::{alloc_shared, Shared},
value::{callable::{Callable, CallableKind, Function}, types::RV},
value::{callable::{Callable, CallableKind, Function}, RV},
};

use self::{
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/src/engine/stdlib/out.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
engine::interpreter::{HaltReason, Interpreter},
value::types::RV,
value::RV,
};

pub fn nt_print(_interpreter: &mut Interpreter, args: &[RV]) -> Result<RV, HaltReason> {
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/src/engine/stdlib/time.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::engine::interpreter::{HaltReason, Interpreter};
use crate::value::types::RV;
use crate::value::RV;
use std::time;

pub fn nt_clock(_interpreter: &mut Interpreter, _args: &[RV]) -> Result<RV, HaltReason> {
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/src/value/callable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt::{Debug, Display, Formatter};
use lykiadb_lang::ast::stmt::Stmt;
use crate::{engine::interpreter::{HaltReason, Interpreter}, util::Shared};
use super::environment::EnvId;
use super::types::RV;
use super::RV;

#[derive(Debug, Clone)]
pub enum CallableKind {
Expand Down
4 changes: 2 additions & 2 deletions lykiadb-server/src/value/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use std::borrow::{Borrow, BorrowMut};

use super::types::RV;
use super::RV;

#[repr(transparent)]
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
Expand Down Expand Up @@ -169,7 +169,7 @@ impl Environment {

#[cfg(test)]
mod test {
use crate::value::types::RV;
use crate::value::RV;

#[test]
fn test_read_basic() {
Expand Down
21 changes: 20 additions & 1 deletion lykiadb-server/src/value/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
use std::sync::Arc;

use callable::Callable;
use rustc_hash::FxHashMap;

use crate::util::Shared;

pub mod environment;
pub mod types;
pub mod callable;
pub mod callable;
#[derive(Debug, Clone)]
pub enum RV {
Str(Arc<String>),
Num(f64),
Bool(bool),
Object(Shared<FxHashMap<String, RV>>),
Array(Shared<Vec<RV>>),
Callable(Callable),
Undefined,
NaN,
Null,
}
20 changes: 2 additions & 18 deletions lykiadb-server/src/value/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,10 @@ use lykiadb_lang::ast::expr::Operation;
use rustc_hash::FxHashMap;
use serde::ser::{SerializeMap, SerializeSeq};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
use std::ops;
use std::sync::{Arc, RwLock};

use crate::util::{alloc_shared, Shared};

use super::callable::Callable;

#[derive(Debug, Clone)]
pub enum RV {
Str(Arc<String>),
Num(f64),
Bool(bool),
Object(Shared<FxHashMap<String, RV>>),
Array(Shared<Vec<RV>>),
Callable(Callable),
Undefined,
NaN,
Null,
}
use crate::util::alloc_shared;
use super::RV;

impl Serialize for RV {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/tests/runtime/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use lykiadb_server::{
InterpretError,
},
},
value::types::RV,
value::RV,
};
use std::sync::Arc;

Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/tests/runtime/functions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use lykiadb_server::{
engine::interpreter::test_helpers::{exec_assert, get_runtime},
value::types::RV,
value::RV,
};
use std::sync::Arc;

Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/tests/runtime/ifs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use lykiadb_server::{engine::interpreter::test_helpers::exec_assert, value::types::RV};
use lykiadb_server::{engine::interpreter::test_helpers::exec_assert, value::RV};
use std::sync::Arc;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/tests/runtime/loops.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use lykiadb_server::{engine::interpreter::test_helpers::exec_assert, value::types::RV};
use lykiadb_server::{engine::interpreter::test_helpers::exec_assert, value::RV};

use std::sync::Arc;

Expand Down

0 comments on commit fb66d9f

Please sign in to comment.