From 9e12ce442fafe271b130f22e58e8b61b0725dc62 Mon Sep 17 00:00:00 2001 From: Siddhangana Date: Tue, 24 Dec 2024 13:13:16 +0800 Subject: [PATCH] Add basic test --- nac3artiq/demo/mangling_test.py | 37 ++++++++++++++++++++++++++++++++ nac3artiq/src/symbol_resolver.rs | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 nac3artiq/demo/mangling_test.py diff --git a/nac3artiq/demo/mangling_test.py b/nac3artiq/demo/mangling_test.py new file mode 100644 index 0000000..9087a5d --- /dev/null +++ b/nac3artiq/demo/mangling_test.py @@ -0,0 +1,37 @@ +from min_artiq import * +from numpy import int32 + +@nac3 +class NameManglingTest: + core: KernelInvariant[Core] + __var1: int32 + __var2__: int32 + __: int32 + + def __init__(self): + self.core = Core() + self.__var1 = 42 + self.__var2__ = 10 + self.__ = 99 + + @rpc + def get_var1(self) -> int32: + return self.__var1 + + @rpc + def get_var2(self) -> int32: + return self.__var2__ + + @rpc + def get_var3(self) -> int32: + return self.__ + + @kernel + def run(self): + assert self.get_var1() == 42 + assert self.get_var2() == 10 + assert self.get_var3() == 99 + + +if __name__ == "__main__": + NameManglingTest().run() diff --git a/nac3artiq/src/symbol_resolver.rs b/nac3artiq/src/symbol_resolver.rs index 261e92a..a552aa8 100644 --- a/nac3artiq/src/symbol_resolver.rs +++ b/nac3artiq/src/symbol_resolver.rs @@ -1538,7 +1538,7 @@ impl SymbolResolver for Resolver { ctx: &mut CodeGenContext<'ctx, '_>, _: &mut dyn CodeGenerator, ) -> Option> { - let (resolved_id, is_dunder) = if id.to_string().starts_with("__") && !id.to_string().ends_with("__") && !id.to_string().contains('.') { + let (resolved_id, _is_dunder) = if id.to_string().starts_with("__") && !id.to_string().ends_with("__") && !id.to_string().contains('.') { let inner_resolver = &self.0; if let Some(class_name) = inner_resolver.get_class_name(id, &ctx.top_level.definitions.read()) {