Allow math on CheckedInt-derived ParamValue classes w/o
losing type information.
python/m5/config.py:
Allow math on CheckedInt-derived ParamValue classes w/o
losing type information.
- Make CheckedInt derive from NumericParamValue, and *not*
multiply inherit from long
- Move CheckedInt bounds check to _check() hook so we can
call it when value is updated (not just in constructor)
python/m5/convert.py:
- make toInteger() return a long, making toLong() unnecessary
- toMemorySize should return long rather than float
--HG--
extra : convert_revision : c1cf5e15b9ff35d9b573dd545e076fe68afef989
This commit is contained in:
@@ -89,17 +89,9 @@ def toFloat(value):
|
||||
else:
|
||||
return float(value)
|
||||
|
||||
def toLong(value):
|
||||
value = toFloat(value)
|
||||
result = int(value)
|
||||
if value != result:
|
||||
raise ValueError, "cannot convert '%s' to long" % value
|
||||
|
||||
return result
|
||||
|
||||
def toInteger(value):
|
||||
value = toFloat(value)
|
||||
result = int(value)
|
||||
result = long(value)
|
||||
if value != result:
|
||||
raise ValueError, "cannot convert '%s' to integer" % value
|
||||
|
||||
@@ -220,16 +212,16 @@ def toMemorySize(value):
|
||||
raise TypeError, "wrong type '%s' should be str" % type(value)
|
||||
|
||||
if value.endswith('PB'):
|
||||
return float(value[:-2]) * pebi
|
||||
return long(value[:-2]) * pebi
|
||||
elif value.endswith('TB'):
|
||||
return float(value[:-2]) * tebi
|
||||
return long(value[:-2]) * tebi
|
||||
elif value.endswith('GB'):
|
||||
return float(value[:-2]) * gibi
|
||||
return long(value[:-2]) * gibi
|
||||
elif value.endswith('MB'):
|
||||
return float(value[:-2]) * mebi
|
||||
return long(value[:-2]) * mebi
|
||||
elif value.endswith('kB'):
|
||||
return float(value[:-2]) * kibi
|
||||
return long(value[:-2]) * kibi
|
||||
elif value.endswith('B'):
|
||||
return float(value[:-1])
|
||||
return long(value[:-1])
|
||||
|
||||
raise ValueError, "cannot convert '%s' to memory size" % value
|
||||
|
||||
Reference in New Issue
Block a user