Anakrino .NET to C# Decompiler Tests

Anakrino is a .NET to C# decompiler, released under a BSD-like license. These tests refer to "Interim #9" (Anakrino9.zip). Anakrino does not save an entire file of code to write to a source file; I had to add the text in bold to the given output.

The distributed binaries require Windows XP (or perhaps another Windows based .NET JIT). It would not run under Mono version 0.20 (current in early March 2003).

Fibo

For source, see DecompilerFiboDotNetSource. Decompiled source from Anakrino:
using System;
class Fibo {
private static int fib(int x) {
    if (x > 1)
        return Fibo.fib(x - 1) + Fibo.fib(x - 2);
    return x;
}

public static int Main(string[] args) {
    int local0;
    int local1;
    Exception local2;
    int local3;

    local1 = 0;
    try {
        local1 = Convert.ToInt32(args[0]);
    }
    catch (Exception local2) {
        Console.WriteLine("Input error");
        local3 = 1;
        <{ class ILEngineer::Ops::MSIL::Leave }>
    }
    local0 = Fibo.fib(local1);
    Console.WriteLine("fibonacci({0}) = {1}", local1, local0);
    return 0;
    return local3;
}
}

There are several errors in this output. Most obviously, there is the Leave code which should be return local3. The return local3; at the end should be removed. Finally, local2 is declared twice. When all these changes are made, the result compiles and runs correctly.

Casting

For source, see DecompilerCastingDotNetSource. Here is the output from Anakrino:

using System;
class Casting {
public static void Main(string[] args) {
    char local0;
    char local1;

    local0 = '';
    while (local0 < 128) {
        Console.WriteLine("ascii {0} character {1}", local0, local0);
        local1 = local0 + 1;
        local0 = local1;
    }
}
}
The main cast is missing in the WriteLine statement. The character constant for character 0 is '\0' , not '' as given. The line local1 = local0 + 1; needs to be replaced with local1 = (char) (((int)local0)+1);. When all these changes are made, the program compiles and is correct.

Inner Classes

For source, see DecompilerInnerClassesDotNetSource. When decompiled with Anakrino, the result appears correct, but tedious to piece together from the individual functions (and constructors). The print_names function decompiles as follows:

public void print_names() {
    Console.WriteLine(this.name);
}
The this. is not needed.

Sable Test Program

For source, see DecompilerSableDotNetSource. The decompiler exited with a runtime fault when this program was loaded.

Simple Control Flow

For source, see DecompilerControlFlowDotNetSource. The decompiler exited with a runtime fault when this program was loaded.

Conclusion

As of early March 2003, Anakrino is not a mature decompiler. It may be useful for examining snippets of code here and there, or even for decompiling small assemblies if you have a fair bit of time spare.

-- MikeVanEmmerik - 07 Mar 2003
CategoryDecompilation

Revision: r1.3 - 11 Mar 2003 - 02:42 - MikeVanEmmerik
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback