forked from M-Labs/nac3
1
0
Fork 0

typedef: make it send

Rc in calls is not send, so we use Arc instead.
This commit is contained in:
pca006132 2021-08-03 12:38:12 +08:00
parent 52dc112410
commit a3acf09bda
3 changed files with 7 additions and 8 deletions

View File

@ -1,8 +1,7 @@
use std::cell::RefCell;
use std::{cell::RefCell, sync::Arc};
use std::collections::HashMap;
use std::convert::{TryInto, From};
use std::iter::once;
use std::rc::Rc;
use super::magic_methods::*;
use super::symbol_resolver::SymbolResolver;
@ -53,7 +52,7 @@ pub struct Inferencer<'a> {
pub primitives: &'a PrimitiveStore,
pub virtual_checks: &'a mut Vec<(Type, Type)>,
pub variable_mapping: HashMap<String, Type>,
pub calls: &'a mut HashMap<CodeLocation, Rc<Call>>,
pub calls: &'a mut HashMap<CodeLocation, Arc<Call>>,
}
struct NaiveFolder();
@ -192,7 +191,7 @@ impl<'a> Inferencer<'a> {
ret: Type,
) -> InferenceResult {
let call =
Rc::new(Call { posargs: params, kwargs: HashMap::new(), ret, fun: RefCell::new(None) });
Arc::new(Call { posargs: params, kwargs: HashMap::new(), ret, fun: RefCell::new(None) });
let call = self.unifier.add_ty(TypeEnum::TCall(vec![call].into()));
let fields = once((method, call)).collect();
let record = self.unifier.add_record(fields);
@ -389,7 +388,7 @@ impl<'a> Inferencer<'a> {
.map(|v| fold::fold_keyword(self, v))
.collect::<Result<Vec<_>, _>>()?;
let ret = self.unifier.get_fresh_var().0;
let call = Rc::new(Call {
let call = Arc::new(Call {
posargs: args.iter().map(|v| v.custom.unwrap()).collect(),
kwargs: keywords
.iter()

View File

@ -42,7 +42,7 @@ struct TestEnvironment {
pub id_to_name: HashMap<usize, String>,
pub identifier_mapping: HashMap<String, Type>,
pub virtual_checks: Vec<(Type, Type)>,
pub calls: HashMap<CodeLocation, Rc<Call>>,
pub calls: HashMap<CodeLocation, Arc<Call>>,
}
impl TestEnvironment {

View File

@ -1,5 +1,5 @@
use itertools::{chain, zip, Itertools};
use std::borrow::Cow;
use std::{borrow::Cow, sync::Arc};
use std::cell::RefCell;
use std::collections::HashMap;
use std::iter::once;
@ -70,7 +70,7 @@ pub enum TypeEnum {
TVirtual {
ty: Type,
},
TCall(RefCell<Vec<Rc<Call>>>),
TCall(RefCell<Vec<Arc<Call>>>),
TFunc(FunSignature),
}