From 09e76efcf723813d41b7d4f0216821db9977eba3 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Thu, 29 Jul 2021 15:36:19 +0800 Subject: [PATCH] start adding primitive magic methods --- .../src/typecheck/type_inferencer/test.rs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/nac3core/src/typecheck/type_inferencer/test.rs b/nac3core/src/typecheck/type_inferencer/test.rs index 16a5ffff1..fdbf7f259 100644 --- a/nac3core/src/typecheck/type_inferencer/test.rs +++ b/nac3core/src/typecheck/type_inferencer/test.rs @@ -45,6 +45,49 @@ struct TestEnvironment { } impl TestEnvironment { + pub fn basic_test_env() -> Option { + use rustpython_parser::ast::Operator::*; + let mut unifier = Unifier::new(); + // let mut identifier_mapping = HashMap::new(); + + let int32 = unifier.add_ty(TypeEnum::TObj { + obj_id: 0, + fields: HashMap::new(), + params: HashMap::new(), + }); + let int64 = unifier.add_ty(TypeEnum::TObj { + obj_id: 1, + fields: HashMap::new(), + params: HashMap::new(), + }); + let float = unifier.add_ty(TypeEnum::TObj { + obj_id: 2, + fields: HashMap::new(), + params: HashMap::new(), + }); + let bool = unifier.add_ty(TypeEnum::TObj { + obj_id: 3, + fields: HashMap::new(), + params: HashMap::new(), + }); + let none = unifier.add_ty(TypeEnum::TObj { + obj_id: 4, + fields: HashMap::new(), + params: HashMap::new(), + }); + // identifier_mapping.insert("None".into(), none); + let primitives = PrimitiveStore { int32, int64, float, bool, none }; + + // if let TypeEnum::TObj {ref fields, ref params, .. } = *unifier.get_ty(int32) { + // for op in [Add, Sub, Mult, MatMult, Div, Mod, Pow, LShift, RShift, BitOr, BitXor, BitAnd, FloorDiv].into_iter() { + // let call = Rc::new(Call {posargs: vec![int32], kwargs: HashMap::new(), ret: int32, fun: RefCell::new(None)}); + // }; + // None + // } else { + // None + // } + } + fn new() -> TestEnvironment { let mut unifier = Unifier::new(); let mut identifier_mapping = HashMap::new();