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

Allow constructor calls when there's an address to this on the stack #67

Open
GGG-KILLER opened this issue Feb 22, 2024 · 0 comments
Open

Comments

@GGG-KILLER
Copy link

The C# compiler itself, when initializing a local, loads the address of the local, constructor arguments and then calls the constructor directly instead of using newobj.

When attempting to do the same with Sigil, instead I get an exception saying that calling constructors is only allowed when inside other constructors.

Example: https://sharplab.io/#v2:C4LglgNgPgAgTABgLACh4EZWoG4EMBOABAB6EC8hAdgKYDuhAkpcAEID2xAFAKwICUAbiwo8RAkQo16TVhwDa3ALpCU4uQkXkqdRs3Zd0g1GvSbJOmfs5wjq/PjlwzJFWoAszqbtldutmOgAnJzitqgAzsD4AK4AxsDeVmDMhHgQ0dR8qADeqIT5hDAAzITJCWkZWhXUKgWEeQXFhegAbIQARmxsEIRsAA7U+LjAbBJknJYchBDUAGbAADSJU/hgAOYAFsB85AB803PAAHTV5BSrm8fVtY0lAW2d3b0DQyNEAITjk6Qz80vfhAuWx2ZH2vyuuHS1EIn0B6y2J0hGRUAF8gA=

Generated IL for var x = new IntBox(50);:

        IL_0000: ldloca.s 0
        IL_0002: ldc.i4.s 50
        IL_0004: call instance void IntBox::.ctor(int32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant