summaryrefslogtreecommitdiff
path: root/python/m5/convert.py
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2005-11-01 14:11:54 -0500
committerSteve Reinhardt <stever@eecs.umich.edu>2005-11-01 14:11:54 -0500
commitfb4f83809fd8a427503b109848ca7c8f3c179e8c (patch)
tree3b3719cd3529e704d3821e1e0edd5d623e77cbb0 /python/m5/convert.py
parent76843fc2649a4081d2e8c4bfbd4f7b5929ff5886 (diff)
downloadgem5-fb4f83809fd8a427503b109848ca7c8f3c179e8c.tar.xz
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
Diffstat (limited to 'python/m5/convert.py')
-rw-r--r--python/m5/convert.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/python/m5/convert.py b/python/m5/convert.py
index 9d9f4efa7..73181e985 100644
--- a/python/m5/convert.py
+++ b/python/m5/convert.py
@@ -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