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).