From 761f5b2cdd07a9f99f90442658ea95aa87facca2 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 22 Oct 2021 14:26:35 +0100 Subject: [PATCH] create dsl.Module._setAstTypeCastFn to decouple constructor of dsl.Module from setting the context for AST typecasting --- nmigen/hdl/dsl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nmigen/hdl/dsl.py b/nmigen/hdl/dsl.py index 09fa92a..7db499f 100644 --- a/nmigen/hdl/dsl.py +++ b/nmigen/hdl/dsl.py @@ -181,7 +181,10 @@ class Module(_ModuleBuilderRoot, Elaboratable): # to complete the Type 1 (ast.*) nmigen language construct abstraction # from Type 2 (Module - this class) Module must be told what AST type # it may cast m.If/Elif conditions and m.Switch - self._astTypeCast = _astTypeFn or Value.cast + sself._setATypeCastFn(_astTypeFn) + + def _setAstTypeCastFn(self, typefn=None): + self._astTypeCast = typefn or Value.cast def _check_context(self, construct, context): if self._ctrl_context != context: -- 2.30.2