chore: refactor unary postfix code emitter to reduce nested tostack#2949
Merged
HerrCai0907 merged 2 commits intoAssemblyScript:mainfrom Sep 19, 2025
Merged
chore: refactor unary postfix code emitter to reduce nested tostack#2949HerrCai0907 merged 2 commits intoAssemblyScript:mainfrom
HerrCai0907 merged 2 commits intoAssemblyScript:mainfrom
Conversation
Member
Author
|
The original behaviour class Bar {
v: i32 = 0;
@operator.postfix("++")
static postfix_inc(bar: Bar): string {
bar.v++;
return "i++";
}
}
export function _start(): void {
let a = new Bar();
let c = a++;
trace(`a.v = ${a.v} ${c}`);
}(call $assembly/index/Bar.postfix_inc
(call $~lib/rt/__tostack
(call $~lib/rt/__tostack
(local.get $0)
)
)
) |
fee6fe9 to
a971694
Compare
KKiiim
approved these changes
Sep 19, 2025
CountBleck
approved these changes
Sep 19, 2025
Member
CountBleck
left a comment
There was a problem hiding this comment.
LGTM but don't abbreviate getValueOriginal to getValueOrigin
HerrCai0907
added a commit
to HerrCai0907/assemblyscript
that referenced
this pull request
Sep 25, 2025
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.
In original code,
getLocalSetValuecannot get the original expression accurately. For managed objects, the original expression will be wrapped in a layer oftostack, and will be wrapped in another layer oftostackwhen called. Although the subsequent nestedtostackcan be eliminated, this brings some readability issues.