UndertaleModTool
UndertaleModTool copied to clipboard
NullReferenceException when decompiling a do-until loop
I compiled the following script:
var value = 0;
do {
value = irandom(100);
} until (value < 50);
This is the resulting assembly:
.localvar 0 arguments
.localvar 1 value 1
:[0]
pushi.e 0
pop.v.i local.value
:[1]
pushi.e 100
conv.i.v
call.i irandom(argc=1)
pop.v.v local.value
pushloc.v local.value
pushi.e 50
cmp.i.v LT
bf [1]
:[end]
After that, I tried to decompile it back into a script, but got an error:
/* EXCEPTION!
System.NullReferenceException: Object reference not set to an instance of an object.
at UndertaleModLib.Decompiler.Decompiler.ComputeReverseDominators(Dictionary`2 blocks, Block entryBlock) in D:\kod\UndertaleModTool\UndertaleModLib\Decompiler\Decompiler.cs:line 2978
at UndertaleModLib.Decompiler.Decompiler.HLDecompile(DecompileContext context, Dictionary`2 blocks, Block entryPoint, Block rootExitPoint) in D:\kod\UndertaleModTool\UndertaleModLib\Decompiler\Decompiler.cs:line 3318
at UndertaleModLib.Decompiler.Decompiler.Decompile(UndertaleCode code, GlobalDecompileContext globalContext) in D:\kod\UndertaleModTool\UndertaleModLib\Decompiler\Decompiler.cs:line 3432
at UndertaleModTool.UndertaleCodeEditor.<>c__DisplayClass26_1.<DecompileCode>b__1() in D:\kod\UndertaleModTool\UndertaleModTool\Editors\UndertaleCodeEditor.xaml.cs:line 344
*/
I suspect there's a problem with flow graph generation. Here's a screenshot from debugger:
Current bleeding edge doesn't seem to have a complete decompilation crash, but still yields the disappearance described in #268.