Compile time constant evaluation#241
Open
chromapid wants to merge 8 commits intosimon987:refactor-1.6from
Open
Compile time constant evaluation#241chromapid wants to merge 8 commits intosimon987:refactor-1.6from
chromapid wants to merge 8 commits intosimon987:refactor-1.6from
Conversation
Collaborator
|
Thank you for implementing this feature. Do you know what needs to be added to the frontend to complete this feature? |
Author
|
The frontend needs to be able to understand that operation trees that act on constants should be considered a single, valid operator (except for before DUP, but that could potentially change). I don't know how the checks are implemented front-end so I can't really give anything more specific than that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
This implements compile time constant evaluation as specified in #139. Anywhere an integer is permitted, there can instead be an expression that acts on any combination of these. Operations include shifts, rotations, arithmetic, and bitwise operations. The issue was fairly open-ended, so I took a bit of creative liberty in some of the features it has and how it operates. The token-based parsing system is fairly flexible, so it would not be a large problem to modify it to fit a different syntax.
The DUP factor does not support expressions right now as the amount of space the directive takes up can be dependent on labels, which depend on positions. However, the value to be repeated does support it.
The in-game editor does not recognize it as valid syntax, but it compiles successfully and seems to run perfectly in game. On that note, I added some tests in src/test/java/net/simon987/mar/server/assembly/TokenTest.java. I commented out a couple existing test cases as they conflicted with constant expressions.
There were some minor fixes I made here and there to get it the typescript to compile successfully in src/main/typescript/World.ts and src/main/typescript/phaser.d.ts. These are independent changes and may be reverted with no effect if they cause problems with different typescript versions (I am using v4.5.4 from npm).