Skip to content

Instantly share code, notes, and snippets.

@leafgarland
Created May 16, 2013 21:18
Show Gist options
  • Save leafgarland/5595181 to your computer and use it in GitHub Desktop.
Save leafgarland/5595181 to your computer and use it in GitHub Desktop.
Compilable IL example for this stackoverflow answer http://stackoverflow.com/questions/16594075/instance-method-warning-in-f/#16597415 To test: > ilasm.exe foo.il > foo.exe
.assembly extern mscorlib
{
}
.assembly hello
{
}
.method static void main()
{
.entrypoint
.maxstack 1
.locals (class Foo foo)
call void Foo::Bar()
newobj void Foo::.ctor()
stloc foo
ldloc foo
call instance void Foo::Bar()
ldloc foo
ldfld string Foo::Bar
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.class public auto Foo
extends [mscorlib]System.Object
{
.method public instance void .ctor()
{
ldarg.0
ldstr "Instance field"
stfld string Foo::Bar
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
.field public string Bar
.method public void Bar()
{
ldstr "Instance method"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method static public void Bar()
{
ldstr "Static method"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment