Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AgentPython capture external constants. #1147

Merged
merged 7 commits into from
Nov 21, 2023
Merged

AgentPython capture external constants. #1147

merged 7 commits into from
Nov 21, 2023

Conversation

Robadob
Copy link
Member

@Robadob Robadob commented Nov 8, 2023

import pyflamegpu
import typing
TEST: typing.Final = 5
TEST2: typing.Final = 12
TEST2: typing.Final = math.sqrt(12 * 36)
TEST3: pyflamegpu.constant = 12
TEST4: int = 14

converts to

constexpr auto TEST = 5;
constexpr auto TEST2 = 20.784609690826528;
constexpr auto TEST3 = 12;

todo

  • tests
  • Do something inside actual codegen() to make global vars constexpr? (if a user passes in a string)
  • Replace inspect.get_attributes() (Its python 3.10+, can be emulated via inspect.get_members())

Closes #1144

@Robadob Robadob self-assigned this Nov 8, 2023
@Robadob Robadob requested review from mondus and ptheywood November 8, 2023 12:33
@Robadob Robadob marked this pull request as ready for review November 8, 2023 12:33
Copy link
Member

@mondus mondus left a comment

Choose a reason for hiding this comment

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

Can we have a test for

TEST2: typing.Final = some_user_defined_func()

The expected result of this is that it should inspect the function and assign a value.

Robadob and others added 3 commits November 20, 2023 16:04
Had to tweak many of the existing tests to prevent unwanted constexpr.
Copy link
Member

@ptheywood ptheywood left a comment

Choose a reason for hiding this comment

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

New tests all pass under linux (and existing codegen tests)

@ptheywood ptheywood merged commit 90ac246 into master Nov 21, 2023
20 checks passed
@ptheywood ptheywood deleted the codegen_constants branch November 21, 2023 11:11
Robadob added a commit that referenced this pull request Nov 27, 2023
This variant has been tested on both 3.8.13 and 3.10.12
Robadob added a commit that referenced this pull request Nov 27, 2023
This variant has been tested on both 3.8.13 and 3.10.12
Robadob added a commit that referenced this pull request Nov 27, 2023
This variant has been tested on both 3.8.13 and 3.10.12
Robadob added a commit that referenced this pull request Nov 27, 2023
This variant has been tested on both 3.8.13 and 3.10.12
Robadob added a commit that referenced this pull request Nov 27, 2023
This variant has been tested on both 3.8.13 and 3.10.12
@ptheywood ptheywood mentioned this pull request Nov 27, 2023
1 task
mondus pushed a commit that referenced this pull request Dec 1, 2023
* BugFix: AgentPython was missing ID->id_t type conversion.

Improved detail in various codgen exceptions too.

* BugFix: #1147 broke Python 3.8.13

This variant has been tested on both 3.8.13 and 3.10.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AgentPython does not capture external variables/constants
3 participants