mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 12:14:43 +00:00
chore(els): let FileCache: Send + Sync
This commit is contained in:
parent
591440333a
commit
c84294fc11
15 changed files with 101 additions and 88 deletions
|
@ -7,7 +7,7 @@ use erg_common::log;
|
|||
use erg_common::set::Set;
|
||||
use erg_common::traits::{Locational, Stream};
|
||||
use erg_common::{dict, fmt_vec, fn_name, option_enum_unwrap, set};
|
||||
use erg_common::{RcArray, Str};
|
||||
use erg_common::{ArcArray, Str};
|
||||
use OpKind::*;
|
||||
|
||||
use erg_parser::ast::Dict as AstDict;
|
||||
|
@ -374,7 +374,7 @@ impl Context {
|
|||
let elem = self.eval_const_expr(&elem.expr)?;
|
||||
elems.push(elem);
|
||||
}
|
||||
Ok(ValueObj::Array(RcArray::from(elems)))
|
||||
Ok(ValueObj::Array(ArcArray::from(elems)))
|
||||
}
|
||||
_ => Err(EvalErrors::from(EvalError::not_const_expr(
|
||||
self.cfg.input.clone(),
|
||||
|
@ -434,7 +434,7 @@ impl Context {
|
|||
}
|
||||
}
|
||||
}
|
||||
Ok(ValueObj::Tuple(RcArray::from(elems)))
|
||||
Ok(ValueObj::Tuple(ArcArray::from(elems)))
|
||||
}
|
||||
|
||||
fn eval_const_record(&self, record: &Record) -> EvalResult<ValueObj> {
|
||||
|
|
|
@ -9,7 +9,7 @@ use erg_common::python_util::PythonVersion;
|
|||
use erg_common::serialize::DataTypePrefix;
|
||||
use erg_common::traits::ExitStatus;
|
||||
use erg_common::{fn_name, switch_lang};
|
||||
use erg_common::{RcArray, Str};
|
||||
use erg_common::{ArcArray, Str};
|
||||
|
||||
use super::codeobj::CodeObj;
|
||||
use super::constructors::array_t;
|
||||
|
@ -282,7 +282,7 @@ impl Deserializer {
|
|||
&mut self,
|
||||
v: &mut Vec<u8>,
|
||||
python_ver: PythonVersion,
|
||||
) -> DeserializeResult<RcArray<ValueObj>> {
|
||||
) -> DeserializeResult<ArcArray<ValueObj>> {
|
||||
match self.deserialize_const(v, python_ver)? {
|
||||
ValueObj::Array(arr) => Ok(arr),
|
||||
other => Err(DeserializeError::type_error(&Type::Str, other.ref_t())),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
use std::ops::{Add, Div, Mul, Neg, Range, RangeInclusive, Sub};
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use erg_common::dict::Dict;
|
||||
use erg_common::set;
|
||||
|
@ -522,14 +522,14 @@ impl TryFrom<TyParam> for ValueObj {
|
|||
for tp in tps {
|
||||
vals.push(ValueObj::try_from(tp)?);
|
||||
}
|
||||
Ok(ValueObj::Array(Rc::from(vals)))
|
||||
Ok(ValueObj::Array(Arc::from(vals)))
|
||||
}
|
||||
TyParam::Tuple(tps) => {
|
||||
let mut vals = vec![];
|
||||
for tp in tps {
|
||||
vals.push(ValueObj::try_from(tp)?);
|
||||
}
|
||||
Ok(ValueObj::Tuple(Rc::from(vals)))
|
||||
Ok(ValueObj::Tuple(Arc::from(vals)))
|
||||
}
|
||||
TyParam::Dict(tps) => {
|
||||
let mut vals = dict! {};
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::cmp::Ordering;
|
|||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::ops::Neg;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use erg_common::config::Input;
|
||||
use erg_common::dict::Dict;
|
||||
|
@ -15,7 +15,7 @@ use erg_common::python_util::PythonVersion;
|
|||
use erg_common::serialize::*;
|
||||
use erg_common::set::Set;
|
||||
use erg_common::{dict, fmt_iter, impl_display_from_debug, log, switch_lang};
|
||||
use erg_common::{RcArray, Str};
|
||||
use erg_common::{ArcArray, Str};
|
||||
use erg_parser::ast::{ConstArgs, ConstExpr};
|
||||
|
||||
use crate::context::eval::type_from_token_kind;
|
||||
|
@ -436,10 +436,10 @@ pub enum ValueObj {
|
|||
Float(f64),
|
||||
Str(Str),
|
||||
Bool(bool),
|
||||
Array(Rc<[ValueObj]>),
|
||||
Array(ArcArray<ValueObj>),
|
||||
Set(Set<ValueObj>),
|
||||
Dict(Dict<ValueObj, ValueObj>),
|
||||
Tuple(Rc<[ValueObj]>),
|
||||
Tuple(ArcArray<ValueObj>),
|
||||
Record(Dict<Field, ValueObj>),
|
||||
DataClass {
|
||||
name: Str,
|
||||
|
@ -659,7 +659,7 @@ impl From<CodeObj> for ValueObj {
|
|||
|
||||
impl<V: Into<ValueObj>> From<Vec<V>> for ValueObj {
|
||||
fn from(item: Vec<V>) -> Self {
|
||||
ValueObj::Array(RcArray::from(
|
||||
ValueObj::Array(ArcArray::from(
|
||||
&item.into_iter().map(Into::into).collect::<Vec<_>>()[..],
|
||||
))
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ impl<V: Into<ValueObj>> From<Vec<V>> for ValueObj {
|
|||
|
||||
impl<const N: usize, V: Into<ValueObj>> From<[V; N]> for ValueObj {
|
||||
fn from(item: [V; N]) -> Self {
|
||||
ValueObj::Array(RcArray::from(&item.map(Into::into)[..]))
|
||||
ValueObj::Array(ArcArray::from(&item.map(Into::into)[..]))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -912,7 +912,7 @@ impl ValueObj {
|
|||
}
|
||||
|
||||
pub fn tuple_from_const_args(args: ConstArgs) -> Self {
|
||||
Self::Tuple(Rc::from(&Self::vec_from_const_args(args)[..]))
|
||||
Self::Tuple(Arc::from(&Self::vec_from_const_args(args)[..]))
|
||||
}
|
||||
|
||||
pub fn vec_from_const_args(args: ConstArgs) -> Vec<Self> {
|
||||
|
@ -1012,7 +1012,7 @@ impl ValueObj {
|
|||
(Self::Float(l), Self::Int(r)) => Some(Self::Float(l - r as f64)),
|
||||
(Self::Str(l), Self::Str(r)) => Some(Self::Str(Str::from(format!("{l}{r}")))),
|
||||
(Self::Array(l), Self::Array(r)) => {
|
||||
let arr = Rc::from([l, r].concat());
|
||||
let arr = Arc::from([l, r].concat());
|
||||
Some(Self::Array(arr))
|
||||
}
|
||||
(Self::Dict(l), Self::Dict(r)) => Some(Self::Dict(l.concat(r))),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue