Skip to content

Commit

Permalink
Cleanup/fixup of nested-reference handling
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
  • Loading branch information
mballance committed Jul 21, 2024
1 parent 1061db1 commit ae044cc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/vsc/model/expr_indexed_field_ref_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,24 @@ def get_target(self, root=None):
ret = root
elif isinstance(self.root, ExprArraySubscriptModel):
ret = self.root.subscript()
elif isinstance(self.root, ExprIndexedFieldRefModel):
from vsc.visitors.expr2field_visitor import Expr2FieldVisitor
fm = Expr2FieldVisitor().field(self.root)
ret = fm
else:
ret = self.root.fm

for i in self.idx_t:
ret = ret.get_field(i)

return ret


def build(self, btor, ctx_width=-1):
t = self.get_target()
ret = t.build(btor)
if ret is None:
raise Exception("Expression %s produced null node" % str(t))
return ret

def is_signed(self):
Expand Down
4 changes: 4 additions & 0 deletions src/vsc/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def __getattr__(self, name):
em = object.__getattribute__(self, "em")
fm_t = Expr2FieldTypeVisitor().fieldtype(em)

# This pops 'this expr' off the stack, so we can
# replace it with an extended expression
pop_expr()

if fm_t is not None:
if name in fm_t.field_id_m.keys():
idx = fm_t.field_id_m[name]
Expand Down
2 changes: 1 addition & 1 deletion src/vsc/visitors/expr2fieldtype_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Expr2FieldTypeVisitor(ModelVisitor):
"""Traverses an array-reference expression, returning element-type information"""

DEBUG_EN = True
DEBUG_EN = False

def __init__(self):
super().__init__()
Expand Down
1 change: 1 addition & 0 deletions ve/unit/test_compound_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,3 +571,4 @@ def eq_c(self):


item = Parent()
item.randomize(debug=False)

0 comments on commit ae044cc

Please sign in to comment.