Skip to content

Commit

Permalink
Add remaining unary operators to stack size assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismaltby committed Apr 29, 2024
1 parent 0813a7a commit 3c78c63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix issue where pasting a "Call Script" event could sometimes incorrectly say script has been modified if project hadn't been saved and reloaded first
- Fix issue where creating a new pattern in music editor would sometimes cause the other patterns in the song to play at a lower octave
- Fix issue where variables in Dialogue and Math inputs could appear above script tabs
- Fix calculation of last parallax layer height in editor input [@pau-tomas](https://github.com/pau-tomas)
- Fix compiler warning when using some unary operators in While loop [@pau-tomas](https://github.com/pau-tomas)

## [3.2.1] - 2024-02-27

Expand Down
9 changes: 8 additions & 1 deletion src/lib/compiler/scriptBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ type RPNHandler = {
stop: () => void;
};

const rpnUnaryOperators: ScriptBuilderRPNOperation[] = [
".ABS",
".NOT",
".B_NOT",
".ISQRT",
];

// - Helpers --------------

const isObject = (value: unknown): value is Record<string, unknown> => {
Expand Down Expand Up @@ -1267,7 +1274,7 @@ class ScriptBuilder {
},
operator: (op: ScriptBuilderRPNOperation) => {
rpnCmd(".R_OPERATOR", op);
if (op !== ".ABS" && op !== ".NOT") {
if (!rpnUnaryOperators.includes(op)) {
stack.pop();
}
return rpn;
Expand Down

0 comments on commit 3c78c63

Please sign in to comment.