Skip to content

Conversation

@vecchiot-aws
Copy link
Contributor

@vecchiot-aws vecchiot-aws commented Jul 9, 2021

Description of changes:

Introduces a visitor pattern for transforming the symbol table. An example identity transformation is included to show the setup, and any of the default methods can be overridden to change behavior. Adds a compiler flag to list out symbol table passes to perform after codegenning.

Resolved issues:

Resolves #291

Call-outs:

Todo:

  • Documentation

Testing:

  • How is this change tested? Existing regression suite, plus new unit test suite specific to the symbol table transformer trait.

  • Is this a refactor change? No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@vecchiot-aws vecchiot-aws force-pushed the symbol-table-transformer branch from 4d5cfa5 to cd83ecd Compare July 9, 2021 20:35
@vecchiot-aws vecchiot-aws marked this pull request as ready for review July 9, 2021 20:35
Copy link
Contributor

@avanhatt avanhatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High level thoughts:

  • Visitor pattern implementation seems clean, straightforward, and useful.
  • Before landing, I would want to see some fairly heavy testing of this. Can we add a separate script that runs this over existing tests and checks that the identity is indeed correct? And that we can do simple changes, like inverting every boolean or similar?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a constructor that enforces this invariant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I should make the comment more clear, but this means manually wrapped in .array_to_ptr() after construction (the other constructor does it for you).

Copy link
Contributor

@adpaco-aws adpaco-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about having the thing you are transforming be the second part of the function names?

For example, transform_type_... when transforming types, transform_expr_... when transforming expressions, and so on. Otherwise I feel like it's a bit harder to read/search, but maybe you've already considered this and decided this was the best way.

@vecchiot-aws vecchiot-aws force-pushed the symbol-table-transformer branch from cd83ecd to 65851cd Compare July 12, 2021 18:15
@vecchiot-aws
Copy link
Contributor Author

vecchiot-aws commented Jul 12, 2021

Before landing, I would want to see some fairly heavy testing of this. Can we add a separate script that runs this over existing tests and checks that the identity is indeed correct? And that we can do simple changes, like inverting every boolean or similar?

This has been manually checked, but I'm not sure what approach is best for automating it.

@avanhatt
Copy link
Contributor

LGTM once some automated test is included in the PR (or, let me know if you feel like that should be a 2nd PR for timing).

@vecchiot-aws vecchiot-aws force-pushed the symbol-table-transformer branch 3 times, most recently from c5b36ca to 13192f3 Compare July 15, 2021 17:18
@vecchiot-aws vecchiot-aws requested a review from avanhatt July 15, 2021 17:48
@vecchiot-aws vecchiot-aws force-pushed the symbol-table-transformer branch from cba5f7d to d9ddad5 Compare July 15, 2021 19:33
@vecchiot-aws vecchiot-aws changed the base branch from main-153-2021-07-09 to main-153-2021-07-15 July 15, 2021 19:34
Copy link
Contributor

@avanhatt avanhatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@danielsn danielsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to add something about this to a readme.

}

/// Transform an assign expr (`left = right`)
/// Currently not able to be constructed, as does not exist in Rust
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constructor doesn't exist?

@danielsn danielsn merged commit 524b6f3 into model-checking:main-153-2021-07-15 Jul 20, 2021
adpaco-aws pushed a commit that referenced this pull request Jul 26, 2021
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
adpaco-aws pushed a commit that referenced this pull request Aug 2, 2021
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
@zhassan-aws zhassan-aws mentioned this pull request Aug 6, 2021
4 tasks
adpaco-aws pushed a commit that referenced this pull request Aug 6, 2021
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
adpaco-aws pushed a commit that referenced this pull request Aug 17, 2021
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
adpaco-aws pushed a commit that referenced this pull request Aug 24, 2021
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
tedinski pushed a commit that referenced this pull request Apr 27, 2022
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create visitor/transformer pattern for RMC/Goto structs

4 participants