Skip to content

Instantly share code, notes, and snippets.

@mgroves
Created March 29, 2012 13:59
Show Gist options
  • Save mgroves/2237712 to your computer and use it in GitHub Desktop.
Save mgroves/2237712 to your computer and use it in GitHub Desktop.
fireweaver IL
.class private auto ansi beforefieldinit FireWeaverExample.Program
extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname
instance void .ctor () cil managed
{
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
}
.method private hidebysig static
void Main (
string[] args
) cil managed
{
.entrypoint
.locals init (
[0] class FireWeaverExample.Dog cat
)
IL_0000: nop
IL_0001: newobj instance void [FireWeaverExample]FireWeaverExample.Cat::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: isinst [FireWeaverExample]FireWeaverExample.Cat
IL_000d: ldnull
IL_000e: cgt.un
IL_0010: ldc.i4.0
IL_0011: ceq
IL_0013: brtrue.s IL_0021
IL_0015: nop
IL_0016: ldloc.0
IL_0017: callvirt instance void [FireWeaverExample]FireWeaverExample.Cat::Bark()
IL_001c: br IL_0027
IL_0021: ldloc.0
IL_0022: callvirt instance void FireWeaverExample.Dog::Bark()
IL_0027: nop
IL_0028: ret
}
}
using System;
namespace FireWeaverExample
{
internal class Program
{
private static void Main(string[] args)
{
Dog dog = new Cat();
if (dog is Cat)
{
dog.Bark();
}
else
{
dog.Bark();
}
}
}
}
.class private auto ansi beforefieldinit FireWeaverExample.Program
extends [mscorlib]System.Object
{
// Methods
.method private hidebysig static
void Main (
string[] args
) cil managed
{
// Method begins at RVA 0x2050
// Code size 41 (0x29)
.maxstack 2
.entrypoint
.locals init (
[0] class FireWeaverExample.Dog
)
IL_0000: nop
IL_0001: newobj instance void [FireWeaverExample]FireWeaverExample.Cat::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: isinst [FireWeaverExample]FireWeaverExample.Cat
IL_000d: ldnull
IL_000e: cgt.un
IL_0010: ldc.i4.0
IL_0011: ceq
IL_0013: brtrue.s IL_0021
IL_0015: nop
IL_0016: ldloc.0
IL_0017: callvirt instance void [FireWeaverExample]FireWeaverExample.Cat::Bark()
IL_001c: br IL_0027
IL_0021: ldloc.0
IL_0022: callvirt instance void FireWeaverExample.Dog::Bark()
IL_0027: nop
IL_0028: ret
} // end of method Program::Main
.method public hidebysig specialname rtspecialname
instance void .ctor () cil managed
{
// Method begins at RVA 0x2088
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Program::.ctor
} // end of class FireWeaverExample.Program
.class private auto ansi beforefieldinit FireWeaverExample.Program
extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname
instance void .ctor () cil managed
{
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
}
.method private hidebysig static
void Main (
string[] args
) cil managed
{
.entrypoint
.locals init (
[0] class FireWeaverExample.Dog dog
)
IL_0000: nop
IL_0001: newobj instance void FireWeaverExample.Dog::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: callvirt instance void FireWeaverExample.Dog::Bark()
IL_000d: nop
IL_000e: ret
}
}
C:\zproj\CCC\FireWeaverExample\FireWeaverExample\bin\Debug>PEVerify.exe "FireWeaverExample - After.exe"
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
[IL]: Error: [C:\zproj\CCC\FireWeaverExample\FireWeaverExample\bin\Debug\FireWeaverExample - After.exe : FireWeaverExample.Program::Main][offset 0x00000006][found ref 'FireWeaverExample.Cat'][expected ref 'FireWeaverExample.Dog'] Unexpected type on the stack.
[IL]: Error: [C:\zproj\CCC\FireWeaverExample\FireWeaverExample\bin\Debug\FireWeaverExample - After.exe : FireWeaverExample.Program::Main][offset 0x00000017][found ref 'FireWeaverExample.Dog'][expected ref 'FireWeaverExample.Cat'] Unexpected type on the stack.
failed to load resource string
FireWeaverExample - After.exe
C:\zproj\CCC\FireWeaverExample\FireWeaverExample\bin\Debug>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment