def is_fn(self, argno: int, argc: int) -> '_Checker': """Checks arg argno is a function with argc parameters.""" t = self.arg_types[argno] if not isinstance(t, FunctionType): raise xls_type_error.XlsTypeError( self.span, t, None, 'Want argument {} to be a function; got {}'.format(argno, t)) if len(t.get_function_params()) != argc: raise xls_type_error.XlsTypeError( self.span, t, None, 'Want argument {} to be a function with {} parameters; got {}'. format(argno, argc, t)) return self
def is_array(self, argno: int) -> '_Checker': t = self.arg_types[argno] if not isinstance(t, ArrayType): raise xls_type_error.XlsTypeError( self.span, t, None, 'Want argument {} to be an array; got {}'.format(argno, t)) return self
def is_bits(self, argno: Union[int, Tuple[int, ...]]) -> '_Checker': """Checks all args identified by argno are bits types.""" if isinstance(argno, tuple): for a in argno: self.is_bits(a) return self t = self.arg_types[argno] if not isinstance(t, BitsType): raise xls_type_error.XlsTypeError( self.span, t, None, 'Want argument {} to be bits; got {}'.format(argno, t)) return self
def is_uN(self, argno: Union[int, Tuple[int, ...]]) -> '_Checker': # pylint: disable=invalid-name """Checks all args identified by argno are uN types.""" if isinstance(argno, tuple): for a in argno: self.is_uN(a) return self assert isinstance(argno, int), argno t = self.arg_types[argno] if not isinstance(t, BitsType) or t.signed: raise xls_type_error.XlsTypeError( self.span, t, None, 'Want argument {} to be unsigned bits; got {}'.format(argno, t)) return self
def check_is_same(self, t: ConcreteType, u: ConcreteType, fmt: Text) -> '_Checker': if t != u: raise xls_type_error.XlsTypeError(self.span, t, u, fmt.format(t, u)) return self
def check_is_len(self, t: ArrayType[int], target: int, fmt: str) -> '_Checker': if t.size != target: raise xls_type_error.XlsTypeError(self.span, t, None, fmt.format(t=t, target=target)) return self
def check_is_bits(self, t: ConcreteType, fmt: Text) -> '_Checker': if not isinstance(t, BitsType): raise xls_type_error.XlsTypeError(self.span, t, None, fmt.format(t)) return self
def eq(self, lhs: ConcreteType, rhs: ConcreteType, fmt: Text) -> '_Checker': if lhs != rhs: raise xls_type_error.XlsTypeError(self.span, lhs, rhs, fmt.format(lhs, rhs)) return self