Sigil
Sigil copied to clipboard
Allow constructor calls when there's an address to this on the stack
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)