def visit_Constant(self, node): if node.value is None: ret = 'pythonic::builtins::None' elif isinstance(node.value, bool): ret = str(node.value).lower() elif isinstance(node.value, str): quoted = node.value.replace('"', r'\"').replace('\n', r'\n') if len(node.value) == 1: quoted = quoted.replace("'", r"\'") ret = 'pythonic::types::chr(\'' + quoted + '\')' else: ret = 'pythonic::types::str("' + quoted + '")' elif isinstance(node.value, complex): ret = "{0}({1}, {2})".format(PYTYPE_TO_CTYPE_TABLE[complex], node.value.real, node.value.imag) elif isnan(node.value): ret = 'pythonic::numpy::nan' elif isinf(node.value): ret = ('+' if node.value >= 0 else '-') + 'pythonic::numpy::inf' else: ret = repr(node.value) + TYPE_TO_SUFFIX.get(type(node.value), "") if node in self.immediates: assert isinstance(node.value, int) return "std::integral_constant<%s, %s>{}" % ( PYTYPE_TO_CTYPE_TABLE[type(node.value)], node.value) return ret
def visit_Num(self, node): if isinstance(node.n, complex): return "{0}({1}, {2})".format(PYTYPE_TO_CTYPE_TABLE[complex], node.n.real, node.n.imag) elif isnan(node.n): return 'pythonic::numpy::nan' elif isinf(node.n): return ('+' if node.n >= 0 else '-') + 'pythonic::numpy::inf' else: return repr(node.n) + TYPE_TO_SUFFIX.get(type(node.n), "")
def visit_Num(self, node): if isinstance(node.n, complex): return "{0}({1}, {2})".format(PYTYPE_TO_CTYPE_TABLE[complex], repr(node.n.real), repr(node.n.imag)) elif isinstance(node.n, long): return "pythran_long({0})".format(node.n) elif isnan(node.n): return "pythonic::numpy::nan" elif isinf(node.n): return ("+" if node.n > 0 else "-") + "pythonic::numpy::inf" else: return repr(node.n) + TYPE_TO_SUFFIX.get(type(node.n), "")
def visit_Num(self, node): if type(node.n) == complex: return "{0}({1}, {2})".format(PYTYPE_TO_CTYPE_TABLE[complex], repr(node.n.real), repr(node.n.imag)) elif type(node.n) == long: return 'pythran_long({0})'.format(node.n) elif isnan(node.n): return 'pythonic::numpy::nan' elif isinf(node.n): return ('+' if node.n > 0 else '-') + 'pythonic::numpy::inf' else: return repr(node.n) + TYPE_TO_SUFFIX.get(type(node.n), "")
def visit_Num(self, node): if type(node.n) == complex: return "{0}({1}, {2})".format( PYTYPE_TO_CTYPE_TABLE[complex], repr(node.n.real), repr(node.n.imag)) elif type(node.n) == long: return 'pythran_long({0})'.format(node.n) elif isnan(node.n): return 'pythonic::numpy::nan' elif isinf(node.n): return ('+' if node.n > 0 else '-') + 'pythonic::numpy::inf' else: return repr(node.n) + TYPE_TO_SUFFIX.get(type(node.n), "")
def visit_Num(self, node): if isinstance(node.n, complex): ret = "{0}({1}, {2})".format(PYTYPE_TO_CTYPE_TABLE[complex], node.n.real, node.n.imag) elif isnan(node.n): ret = 'pythonic::numpy::nan' elif isinf(node.n): ret = ('+' if node.n >= 0 else '-') + 'pythonic::numpy::inf' else: ret = repr(node.n) + TYPE_TO_SUFFIX.get(type(node.n), "") if node in self.immediates: assert isinstance(node.n, int) return "std::integral_constant<%s, %s>{}" % ( PYTYPE_TO_CTYPE_TABLE[type(node.n)], ret) return ret
def visit_Num(self, node): if isinstance(node.n, complex): ret = "{0}({1}, {2})".format( PYTYPE_TO_CTYPE_TABLE[complex], node.n.real, node.n.imag) elif isnan(node.n): ret = 'pythonic::numpy::nan' elif isinf(node.n): ret = ('+' if node.n >= 0 else '-') + 'pythonic::numpy::inf' else: ret = repr(node.n) + TYPE_TO_SUFFIX.get(type(node.n), "") if node in self.immediates: assert isinstance(node.n, int) return "std::integral_constant<%s, %s>{}" % ( PYTYPE_TO_CTYPE_TABLE[type(node.n)], node.n) return ret