Skip to content

Commit 48f2e1f

Browse files
committed
type_check -> _type_check
1 parent 4de470c commit 48f2e1f

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

veriloggen/module.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ class Instance(vtypes.VeriloggenNode):
458458
def __init__(self, module, instname, params=None, ports=None):
459459
if params is None: params = ()
460460
if ports is None: ports = ()
461-
self.type_check_params(params)
462-
self.type_check_ports(ports)
461+
self._type_check_params(params)
462+
self._type_check_ports(ports)
463463
self.module = module
464464
self.instname = instname
465465
if not params:
@@ -475,16 +475,16 @@ def __init__(self, module, instname, params=None, ports=None):
475475
else:
476476
self.ports = [ (None, p) for p in ports ]
477477

478-
def type_check_module(self, module):
478+
def _type_check_module(self, module):
479479
if not isinstance(module, (Module, StubModule)):
480480
raise TypeError("module of Instance must be Module or StubModule, not %s" %
481481
type(module))
482482

483-
def type_check_params(self, params):
483+
def _type_check_params(self, params):
484484
if not isinstance(params, (tuple, list)):
485485
raise TypeError("params of Instance require tuple, not %s." % type(params))
486486

487-
def type_check_ports(self, ports):
487+
def _type_check_ports(self, ports):
488488
if not isinstance(ports, (tuple, list)):
489489
raise TypeError("ports of Instance require tuple, not %s." % type(ports))
490490

@@ -506,7 +506,7 @@ def OutputReg(self, name, width=None, length=None, signed=False, value=None):
506506
def Inout(self, name, width=None, length=None, signed=False, value=None):
507507
raise TypeError("Inout port is not allowed in generate statement")
508508

509-
def type_check_scope(self, scope):
509+
def _type_check_scope(self, scope):
510510
if scope is None: return
511511
if not isinstance(scope, str):
512512
raise TypeError("Scope name should be str, not %s." % type(scope))
@@ -519,7 +519,7 @@ def __init__(self, pre, cond, post, scope=None):
519519
self.cond = cond
520520
self.post = post
521521
self.scope = scope
522-
self.type_check_scope(scope)
522+
self._type_check_scope(scope)
523523

524524
def __getitem__(self, index):
525525
return vtypes.ScopeIndex(self.scope, index)
@@ -530,13 +530,13 @@ def __init__(self, cond, true_scope=None):
530530
self.cond = cond
531531
self.true_scope = true_scope
532532
self.Else = GenerateIfElse()
533-
self.type_check_scope(true_scope)
533+
self._type_check_scope(true_scope)
534534

535535
class GenerateIfElse(Generate):
536536
def __init__(self, false_scope=None):
537537
Generate.__init__(self)
538538
self.false_scope = false_scope
539-
self.type_check_scope(false_scope)
539+
self._type_check_scope(false_scope)
540540

541541
def __call__(self, false_scope):
542542
self.false_scope = false_scope

veriloggen/vtypes.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,12 @@ class Supply(_ParameterVairable): pass
274274
#-------------------------------------------------------------------------------
275275
class _Constant(_Numeric):
276276
def __init__(self, value, width=None, base=None):
277-
self.type_check_value(value)
278-
self.type_check_width(width)
279-
self.type_check_base(base)
280-
def type_check_value(self, value): pass
281-
def type_check_width(self, width): pass
282-
def type_check_base(self, base): pass
277+
self._type_check_value(value)
278+
self._type_check_width(width)
279+
self._type_check_base(base)
280+
def _type_check_value(self, value): pass
281+
def _type_check_width(self, width): pass
282+
def _type_check_base(self, base): pass
283283

284284
def __str__(self):
285285
return str(value)
@@ -292,16 +292,16 @@ def __init__(self, value, width=None, base=None, signed=False):
292292
self.base = base
293293
self.signed = signed
294294

295-
def type_check_value(self, value):
295+
def _type_check_value(self, value):
296296
if not isinstance(value, int):
297297
raise TypeError('value of Int must be int, not %s.' % type(value))
298298

299-
def type_check_width(self, width):
299+
def _type_check_width(self, width):
300300
if width is None: return
301301
if not isinstance(width, int):
302302
raise TypeError('width of Int must be int, not %s.' % type(width))
303303

304-
def type_check_base(self, base):
304+
def _type_check_base(self, base):
305305
if base is None: return
306306
if not isinstance(base, int):
307307
raise TypeError('base of Int must be int, not %s.' % type(base))
@@ -354,7 +354,7 @@ def __init__(self, width=None, base=None, signed=False):
354354
self.base = base
355355
self.signed = signed
356356

357-
def type_check_value(self, value):
357+
def _type_check_value(self, value):
358358
pass
359359

360360
def __str__(self):
@@ -405,7 +405,7 @@ def __init__(self, width=None, base=None, signed=False):
405405
self.base = base
406406
self.signed = False
407407

408-
def type_check_value(self, value):
408+
def _type_check_value(self, value):
409409
pass
410410

411411
def __str__(self):
@@ -453,7 +453,7 @@ def __init__(self, value):
453453
_Constant.__init__(self, value, None, None)
454454
self.value = value
455455

456-
def type_check_value(self, value):
456+
def _type_check_value(self, value):
457457
if not isinstance(value, (float, int)):
458458
raise TypeError('value of Float must be float, not %s.' % type(value))
459459

@@ -465,7 +465,7 @@ def __init__(self, value):
465465
_Constant.__init__(self, value, None, None)
466466
self.value = value
467467

468-
def type_check_value(self, value):
468+
def _type_check_value(self, value):
469469
if not isinstance(value, str):
470470
raise TypeError('value of Str must be str, not %s.' % type(value))
471471

@@ -478,11 +478,11 @@ class _Operator(_Numeric): pass
478478
#-------------------------------------------------------------------------------
479479
class _BinaryOperator(_Operator):
480480
def __init__(self, left, right):
481-
self.type_check(left, right)
481+
self._type_check(left, right)
482482
self.left = left
483483
self.right = right
484484

485-
def type_check(self, left, right):
485+
def _type_check(self, left, right):
486486
if not isinstance(left, (_Numeric, bool, int, float, str)):
487487
raise TypeError('BinaryOperator does not support Type %s' % str(type(left)))
488488
if not isinstance(right, (_Numeric, bool, int, float, str)):
@@ -494,10 +494,10 @@ def __str__(self):
494494

495495
class _UnaryOperator(_Operator):
496496
def __init__(self, right):
497-
self.type_check(right)
497+
self._type_check(right)
498498
self.right = right
499499

500-
def type_check(self, right):
500+
def _type_check(self, right):
501501
if not isinstance(right, (_Numeric, bool, int, float, str)):
502502
raise TypeError('BinaryOperator does not support Type %s' % str(type(right)))
503503

@@ -822,7 +822,7 @@ def __call__(self, *args):
822822
return self.set_statement(*args)
823823
raise ValueError("Case statement list is already assigned.")
824824

825-
def type_check_statement(self, *statement):
825+
def _type_check_statement(self, *statement):
826826
for s in statement:
827827
if not isinstance(s, When):
828828
raise TypeError("Case statement requires When() object as statement list.")
@@ -832,22 +832,22 @@ def type_check_statement(self, *statement):
832832
self.last = True
833833

834834
def set_statement(self, *statement):
835-
self.type_check_statement(*statement)
835+
self._type_check_statement(*statement)
836836
self.statement = tuple(statement)
837837
return self
838838

839839
def add(self, *statement):
840840
if self.statement is None:
841841
return self.set_statement(*statement)
842-
self.type_check_statement(*statement)
842+
self._type_check_statement(*statement)
843843
self.statement = tuple(self.statement + statement)
844844
return self
845845

846846
class Casex(Case): pass
847847

848848
class When(VeriloggenNode) :
849849
def __init__(self, *condition):
850-
self.type_check_condition(*condition)
850+
self._type_check_condition(*condition)
851851
self.condition = None if len(condition) == 0 or condition[0] is None else tuple(condition)
852852
self.statement = None
853853

@@ -856,7 +856,7 @@ def __call__(self, *args):
856856
return self.set_statement(*args)
857857
raise ValueError("Statement body is already assigned.")
858858

859-
def type_check_condition(self, *args):
859+
def _type_check_condition(self, *args):
860860
if len(args) == 0:
861861
return
862862
if len(args) == 1 and args[0] is None:
@@ -867,18 +867,18 @@ def type_check_condition(self, *args):
867867
if isinstance(a, (_Numeric, bool, int, float, str)): continue
868868
raise TypeError("Condition must be _Numeric object, not '%s'" % str(type(a)))
869869

870-
def type_check_statement(self, *args):
870+
def _type_check_statement(self, *args):
871871
pass
872872

873873
def set_statement(self, *statement):
874-
self.type_check_statement(*statement)
874+
self._type_check_statement(*statement)
875875
self.statement = tuple(statement)
876876
return self
877877

878878
def add(self, *statement):
879879
if self.statement is None:
880880
return self.set_statement(*statement)
881-
self.type_check_statement(*statement)
881+
self._type_check_statement(*statement)
882882
self.statement = tuple(self.statement + statement)
883883
return self
884884

0 commit comments

Comments
 (0)