From 34d3317ea01b698e19dd65a5c5a3ee5425b9af3e Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 7 Aug 2021 10:41:53 +0800 Subject: [PATCH] store operation method signature --- nac3core/src/typecheck/type_inferencer/mod.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nac3core/src/typecheck/type_inferencer/mod.rs b/nac3core/src/typecheck/type_inferencer/mod.rs index a3e16bfb2..e2fdc1727 100644 --- a/nac3core/src/typecheck/type_inferencer/mod.rs +++ b/nac3core/src/typecheck/type_inferencer/mod.rs @@ -182,6 +182,7 @@ impl<'a> Inferencer<'a> { fn build_method_call( &mut self, + location: Location, method: String, obj: Type, params: Vec, @@ -193,6 +194,7 @@ impl<'a> Inferencer<'a> { ret, fun: RefCell::new(None), }); + self.calls.insert(location.into(), call.clone()); let call = self.unifier.add_ty(TypeEnum::TCall(vec![call].into())); let fields = once((method, call)).collect(); let record = self.unifier.add_record(fields); @@ -477,6 +479,7 @@ impl<'a> Inferencer<'a> { let method = binop_name(op); let ret = self.unifier.get_fresh_var().0; self.build_method_call( + left.location, method.to_string(), left.custom.unwrap(), vec![right.custom.unwrap()], @@ -491,7 +494,13 @@ impl<'a> Inferencer<'a> { ) -> InferenceResult { let method = unaryop_name(op); let ret = self.unifier.get_fresh_var().0; - self.build_method_call(method.to_string(), operand.custom.unwrap(), vec![], ret) + self.build_method_call( + operand.location, + method.to_string(), + operand.custom.unwrap(), + vec![], + ret, + ) } fn infer_compare( @@ -504,7 +513,7 @@ impl<'a> Inferencer<'a> { for (a, b, c) in izip!(once(left).chain(comparators), comparators, ops) { let method = comparison_name(c).ok_or_else(|| "unsupported comparator".to_string())?.to_string(); - self.build_method_call(method, a.custom.unwrap(), vec![b.custom.unwrap()], boolean)?; + self.build_method_call(a.location, method, a.custom.unwrap(), vec![b.custom.unwrap()], boolean)?; } Ok(boolean) }