def _resolve_abs(self, func, node, argtype): self._expect_n_args(func, node, 1) if argtype.is_complex: dst_type = double result_type = object_ elif argtype.is_int: dst_type = argtype result_type = promote_closest(self.context, argtype, [long_, longlong]) else: dst_type = argtype result_type = argtype node.variable = Variable(result_type) return nodes.CoercionNode(node, dst_type)
def _resolve_abs(self, func, node, argtype): self._expect_n_args(func, node, 1) # TODO: generate efficient inline code if argtype.is_float: return self._resolve_math_call(node, abs) elif argtype.is_int: if argtype.signed: type = promote_closest(self.context, argtype, [long_, longlong]) funcs = {long_: 'labs', longlong: 'llabs'} return self.function_cache.call(funcs[type], node.args[0]) else: # abs() on unsigned integral value return node.args[0] return None