def build_field_model(self, name): # If we have an IntEnum, then collect the values self._int_field_info.name = name self._int_field_info.model = EnumFieldModel( name, self.enum_i.enums, self._int_field_info.is_rand) return self._int_field_info.model
def append(self, v): model = self.get_model() if self.is_enum: ei: EnumInfo = self.t.enum_i enum_m = EnumFieldModel("xxx", ei.enums, self._int_field_info.is_rand) enum_m.set_val(ei.e2v(v)) model.append(enum_m) elif self.is_scalar: # Working with a scalar f = model.add_field() f.set_val(int(v) & (1 << self.t.width) - 1) else: if not issubclass(type(v), type(self.t)): raise Exception( "Attempting to append illegal element to object array") self.backing_arr.append(v) model.append(v.get_model()) # Propagate randomization information v.get_model().is_declared_rand = self.get_model().is_declared_rand
def add_field(self) -> FieldScalarModel: fid = len(self.field_l) if self.is_enum: ret = super().add_field( EnumFieldModel(self.name + "[" + str(fid) + "]", self.enums, self.is_declared_rand)) else: ret = super().add_field( FieldScalarModel(self.name + "[" + str(fid) + "]", self.width, self.is_signed, self.is_declared_rand)) # Update the size self._set_size(len(self.field_l)) return ret
def visit_enum_field(self, f: EnumFieldModel): if self.phase == 0: f.build(self.btor)
def visit_enum_field(self, f:EnumFieldModel): f.dispose()