@@ -209,6 +209,10 @@ def typeMin(cls) -> int:
209209 else :
210210 return 0
211211
212+ @_classproperty
213+ def nLevels (cls ) -> int :
214+ return cls .typeMax - cls .typeMin + 1
215+
212216 @classmethod
213217 def partialOrderUpcast (cls , otherCls : Type [Immediate ]) -> bool :
214218 if issubclass (otherCls , IntegerImmediate ):
@@ -234,6 +238,10 @@ def checkValue(cls, value: Union[int, Iterable[int], np.ndarray], ctxt: Optional
234238 return False
235239 return True
236240
241+ @classmethod
242+ def checkNumLevels (cls , nLevels : int , signed : bool ) -> bool :
243+ return nLevels <= (cls .typeMax - cls .typeMin + 1 )
244+
237245
238246class FloatImmediate (Immediate [Union [float , Iterable [float ]], _ImmediateType ]):
239247 typeMantissa : int #: int: Represents the number of bits reserved for the mantissa part
@@ -353,6 +361,10 @@ def checkPromotion(cls, _value: Union[Optional[str], Pointer], ctxt: Optional[_N
353361 value = _value
354362 return cls .checkValue (value , ctxt )
355363
364+ @classmethod
365+ def checkNumLevels (cls , nLevels : int , signed : bool ) -> bool :
366+ return cls .referencedType .checkNumLevels (nLevels , signed )
367+
356368 def __init__ (self , _value : Union [Optional [str ], Pointer ], ctxt : Optional [_NetworkContext ] = None ):
357369 """Initializes a pointer to a registered object in the NetworkContext
358370
0 commit comments