program: convert value when creating rvalue

This is useful for a few cases:

- We should make sure that the value of an object is actually valid for
  its type
- When casting, the value should be converted to the new type where
  appropriate
- For the upcoming ProgramObject operators
This commit is contained in:
Omar Sandoval 2018-05-01 20:58:37 -07:00
parent c3dbe939ad
commit 90f6913242

View File

@ -66,6 +66,8 @@ class ProgramObject:
self.address_ = address self.address_ = address
self.type_ = type self.type_ = type
self._real_type = type.real_type() self._real_type = type.real_type()
if value is not None:
value = self._real_type.convert(value)
self._value = value self._value = value
def __dir__(self) -> Iterable[str]: def __dir__(self) -> Iterable[str]: