Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • pystencils pystencils
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 18
    • Issues 18
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pycodegen
  • pystencilspystencils
  • Merge requests
  • !64

Bugfix avoid east and west const

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Stephan Seitz requested to merge seitz/pystencils:bugfix-avoid-east-and-west-const into master Sep 27, 2019
  • Overview 0
  • Commits 1
  • Pipelines 1
  • Changes 1

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.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: bugfix-avoid-east-and-west-const