from nir_opcodes import opcodes
if sys.version_info < (3, 0):
+ integer_types = (int, long)
string_type = unicode
else:
+ integer_types = (int, )
string_type = str
_type_re = re.compile(r"(?P<type>int|uint|bool|float)?(?P<bits>\d+)?")
return val
elif isinstance(val, string_type):
return Variable(val, name_base, varset)
- elif isinstance(val, (bool, int, long, float)):
+ elif isinstance(val, (bool, float) + integer_types):
return Constant(val, name_base)
__template = mako.template.Template("""
def hex(self):
if isinstance(self.value, (bool)):
return 'NIR_TRUE' if self.value else 'NIR_FALSE'
- if isinstance(self.value, (int, long)):
+ if isinstance(self.value, integer_types):
return hex(self.value)
elif isinstance(self.value, float):
i = struct.unpack('Q', struct.pack('d', self.value))[0]
def type(self):
if isinstance(self.value, (bool)):
return "nir_type_bool32"
- elif isinstance(self.value, (int, long)):
+ elif isinstance(self.value, integer_types):
return "nir_type_int"
elif isinstance(self.value, float):
return "nir_type_float"
from __future__ import division, print_function
+import sys
+
from u_format_parse import *
+if sys.version_info < (3, 0):
+ integer_types = (int, long)
+
+else:
+ integer_types = (int, )
+
+
def inv_swizzles(swizzles):
'''Return an array[4] of inverse swizzle terms'''
'''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha'''
'''Truncate an integer so it can be represented exactly with a floating
point mantissa'''
- assert isinstance(x, (int, long))
+ assert isinstance(x, integer_types)
s = 1
if x < 0:
'''Get the value of unity for this type.'''
if type.type == FLOAT:
if type.size <= 32 \
- and isinstance(value, (int, long)):
+ and isinstance(value, integer_types):
return truncate_mantissa(value, 23)
return value
if type.type == FIXED: