Exemple #1
0
 def getAttr(self, node):
     self.visit(node.value)
     node.obj = None
     if isinstance(node.value, ast.Name):
         n = node.value.id
         if (n not in self.tree.vardict) and (n not in self.tree.symdict):
             raise AssertionError("attribute target: %s" % n)
     obj = node.value.obj
     if isinstance(obj, _Signal):
         if node.attr == 'posedge':
             node.obj = obj.posedge
         elif node.attr == 'negedge':
             node.obj = obj.negedge
         elif node.attr in ('val', 'next'):
             node.obj = obj.val
     if isinstance(obj, (intbv, _Signal)):
         if node.attr == 'min':
             node.obj = obj.min
         elif node.attr == 'max':
             node.obj = obj.max
         elif node.attr == 'signed':
             node.obj = intbv.signed
     if isinstance(obj, EnumType):
         assert hasattr(obj, node.attr), node.attr
         node.obj = getattr(obj, node.attr)
         if obj not in _enumTypeSet:
             _enumTypeSet.add(obj)
             suf = _genUniqueSuffix.next()
             obj._setName(n + suf)
     if node.obj is None:  # attribute lookup failed
         self.raiseError(node, _error.UnsupportedAttribute, node.attr)
Exemple #2
0
 def getAttr(self, node):
     self.visit(node.value)
     node.obj = None
     if isinstance(node.value, ast.Name):
         n = node.value.id
         if (n not in self.tree.vardict) and (n not in self.tree.symdict):
             raise AssertionError("attribute target: %s" % n)
     obj = node.value.obj
     if isinstance(obj, _Signal):
         if node.attr == 'posedge':
             node.obj = obj.posedge
         elif node.attr == 'negedge':
             node.obj = obj.negedge
         elif node.attr in ('val', 'next'):
             node.obj = obj.val
     if isinstance(obj, (intbv, _Signal)):
         if node.attr == 'min':
             node.obj = obj.min
         elif node.attr == 'max':
             node.obj = obj.max
         elif node.attr == 'signed':
             node.obj = intbv.signed
     if isinstance(obj, EnumType):
         assert hasattr(obj, node.attr), node.attr
         node.obj = getattr(obj, node.attr)
         if obj not in _enumTypeSet:
             _enumTypeSet.add(obj)
             suf = _genUniqueSuffix.next()
             obj._setName(n+suf)
     if node.obj is None: # attribute lookup failed
         self.raiseError(node, _error.UnsupportedAttribute, node.attr)