Skip to content

Convenient shortcut for creating binary operations #3395

@hiker

Description

@hiker

While doing some AI tests, I got the following python script for to create counter = counter + 1:

            increment = Assignment.create(
                counter_ref.copy(),
                # counter = counter + 1
                counter_ref.copy()
                + Literal("1", INTEGER_TYPE)       # Ooops :)
            )

Now obviously that doesn't work, but it's rather trivial to support this in PSyclone by adding:

   def __add__(self, other):
       return BinaryOperation.create(BinaryOperation.Operator.ADD,
                                     self, other)

to DataNode. It would obviously need proper testing of other (and might even be able to support counter_ref.copy() + 1???), but could easily be added for some binary (+-*/ mod and power at least?) operations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions