From 52d2259941b75eedbecb404e91f36b3e67f82f65 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <kloeckner@haamster.(none)> Date: Mon, 1 Dec 2008 17:46:32 -0600 Subject: [PATCH] C Code mapper: treat functions specially. --- src/mapper/c_code.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mapper/c_code.py b/src/mapper/c_code.py index 3dde4e9..f002d8e 100644 --- a/src/mapper/c_code.py +++ b/src/mapper/c_code.py @@ -4,13 +4,24 @@ from pymbolic.mapper.stringifier import SimplifyingSortingStringifyMapper class CCodeMapper(SimplifyingSortingStringifyMapper): - def __init__(self, constant_mapper=repr, reverse=True, cse_prefix="cse"): + def __init__(self, constant_mapper=repr, reverse=True, cse_prefix="_cse"): SimplifyingSortingStringifyMapper.__init__(self, constant_mapper, reverse) self.cse_prefix = cse_prefix self.cses = [] self.cse_to_index = {} # mappings ---------------------------------------------------------------- + def map_call(self, expr, enclosing_prec): + from pymbolic.primitives import Variable + from pymbolic.mapper.stringifier import PREC_NONE, PREC_CALL + if isinstance(expr.function, Variable): + func = expr.function.name + else: + func = self.rec(expr.function, PREC_CALL) + + return self.format("%s(%s)", + func, self.join_rec(", ", expr.parameters, PREC_NONE)) + def map_power(self, expr, enclosing_prec): from pymbolic.mapper.stringifier import PREC_NONE from pymbolic.primitives import is_constant, is_zero -- GitLab