Skip to content
Snippets Groups Projects

Bugfix avoid east and west const

Merged Stephan Seitz requested to merge seitz/pystencils:bugfix-avoid-east-and-west-const into master

Here's the printing logic for SympyAsssignment:

        if node.is_declaration:
            if node.is_const # <<<  and 'const' not in self._print(node.lhs.dtype):
                prefix = 'const '
            else:
                prefix = ''
            data_type = prefix + self._print(node.lhs.dtype) + " "
            return "%s%s = %s;" % (data_type, self.sympy_printer.doprint(node.lhs),
                                   self.sympy_printer.doprint(node.rhs))
        else:
            lhs_type = get_type_of_expression(node.lhs)
            if type(lhs_type) is VectorType and isinstance(node.lhs, cast_func):

It will always prefix const on a declaration. This will not work if dtype is also const since:

    def __str__(self):
        result = BasicType.numpy_name_to_c(str(self._dtype))
        if self.const:
            result += " const"
        return result

So we get something like const int64_t const.

I deleted the postfix const to have everything nicely aligned.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
Please register or sign in to reply