Skip to content

Instantly share code, notes, and snippets.

@bamboo
Created July 27, 2015 10:42
Show Gist options
  • Save bamboo/4da42e1627e6e35a5620 to your computer and use it in GitHub Desktop.
Save bamboo/4da42e1627e6e35a5620 to your computer and use it in GitHub Desktop.
idris-cil - Hello World
.assembly extern mscorlib
{
.ver 2:0:0:0
.publickeytoken = (B7 7A 5C 56 19 34 E0 89)
}
.assembly 'HelloIdris' {}
.class private M
{
.method static assembly object call__IO(object e0, object e1, object e2) cil managed
{
.locals init (
object l0)
ldarg.2
ldloc.0
tail. call object M::APPLY0(object, object)
ret
}
.method static assembly object io_bind(object e0, object e1, object e2, object e3, object e4, object w) cil managed
{
.locals init (
object l0,
object l1)
ldarg.0
ldarg.1
ldarg.2
ldarg.3
ldarg 4
ldarg 5
call object M::io_bind2(object, object, object, object, object, object)
stloc.0
ldarg.3
ldarg 5
call object M::APPLY0(object, object)
stloc.1
ldloc.0
ldloc.1
tail. call object M::APPLY0(object, object)
ret
}
.method static assembly object io_return(object e0, object e1, object e2, object w) cil managed
{
.locals init (
object l0)
ldarg.2
ret
}
.method static assembly object main() cil managed
{
.locals init (
object l0,
object l1)
ldstr "Hello, Idris!\n"
stloc.1
ldloc.0
ldloc.1
tail. call object M::putStr(object, object)
ret
}
.method static assembly object prim__writeString(object op0, object op1) cil managed
{
.locals init (
object l0)
ldarg.1
castclass string
call void [mscorlib]System.Console::Write(string)
ldnull
ret
}
.method static assembly object prim_io_bind(object e0, object e1, object e2, object e3) cil managed
{
.locals init (
object l0)
ldarg.3
ldarg.2
tail. call object M::APPLY0(object, object)
ret
}
.method static assembly object putStr(object e0, object e1) cil managed
{
.locals init (
object l0,
object l1,
object l2,
object l3,
object l4)
ldc.i4 65626
ldc.i4.1
newarr object
dup
ldc.i4.0
ldarg.1
stelem.ref
newobj instance void SCon::.ctor(int32, object[])
stloc.3
ldc.i4 65627
ldc.i4.0
newarr object
newobj instance void SCon::.ctor(int32, object[])
stloc 4
ldc.i4 65628
ldc.i4.5
newarr object
dup
ldc.i4.0
ldloc.0
stelem.ref
dup
ldc.i4.1
ldloc.1
stelem.ref
dup
ldc.i4.2
ldloc.2
stelem.ref
dup
ldc.i4.3
ldloc.3
stelem.ref
dup
ldc.i4.4
ldloc 4
stelem.ref
newobj instance void SCon::.ctor(int32, object[])
ret
}
.method static assembly object run__IO(object e0, object e1) cil managed
{
.locals init (
object l0)
ldarg.1
ldloc.0
tail. call object M::APPLY0(object, object)
ret
}
.method static assembly object world(object e0) cil managed
{
.locals init (
object l0)
ldarg.0
ret
}
.method static assembly object APPLY0(object fn0, object arg0) cil managed
{
.locals init (
object l0,
object l1,
object l2,
object l3,
object l4,
object l5)
ldarg.0
castclass class SCon
ldfld int32 SCon::tag
ldc.i4 65626
sub
switch (L0, L1, L2, L3, L4, L5)
L0:
ldarg.0
castclass class SCon
ldfld object[] SCon::fields
dup
ldc.i4.0
ldelem.ref
stloc.0
pop
ldloc.0
ldarg.1
tail. call object M::putStr0(object, object)
ret
L1:
ldarg.1
tail. call object M::putStr1(object)
ret
L2:
ldarg.0
castclass class SCon
ldfld object[] SCon::fields
dup
ldc.i4.0
ldelem.ref
stloc.0
dup
ldc.i4.1
ldelem.ref
stloc.1
dup
ldc.i4.2
ldelem.ref
stloc.2
dup
ldc.i4.3
ldelem.ref
stloc.3
dup
ldc.i4.4
ldelem.ref
stloc 4
pop
ldloc.0
ldloc.1
ldloc.2
ldloc.3
ldloc 4
ldarg.1
tail. call object M::io_bind(object, object, object, object, object, object)
ret
L3:
ldarg.0
castclass class SCon
ldfld object[] SCon::fields
dup
ldc.i4.0
ldelem.ref
stloc.0
dup
ldc.i4.1
ldelem.ref
stloc.1
dup
ldc.i4.2
ldelem.ref
stloc.2
pop
ldloc.0
ldloc.1
ldloc.2
ldarg.1
tail. call object M::io_return(object, object, object, object)
ret
L4:
ldarg.0
castclass class SCon
ldfld object[] SCon::fields
dup
ldc.i4.0
ldelem.ref
stloc.0
dup
ldc.i4.1
ldelem.ref
stloc.1
dup
ldc.i4.2
ldelem.ref
stloc.2
dup
ldc.i4.3
ldelem.ref
stloc.3
dup
ldc.i4.4
ldelem.ref
stloc 4
dup
ldc.i4.5
ldelem.ref
stloc 5
pop
ldloc.0
ldloc.1
ldloc.2
ldloc.3
ldloc 4
ldloc 5
ldarg.1
tail. call object M::io_bind1(object, object, object, object, object, object, object)
ret
L5:
// NOT IMPLEMENTED: SDefaultCase SNothing
ldnull
br END
END:
ret
}
.method static assembly object EVAL0(object arg0) cil managed
{
.locals init (
object l0)
ldarg.0
ret
}
.method static assembly object io_bind0(object e0, object e1, object e2, object e3, object e4, object w, object in0) cil managed
{
.locals init (
object l0)
ldarg 4
ldarg 6
tail. call object M::APPLY0(object, object)
ret
}
.method static assembly object putStr0(object e1, object in0) cil managed
{
.locals init (
object l0)
ldarg.0
castclass string
call void [mscorlib]System.Console::Write(string)
ldnull
ret
}
.method static assembly object runMain0() cil managed
{
.entrypoint
.locals init (
object l0,
object l1)
call object M::main()
stloc.0
ldloc.0
ldloc.1
call object M::APPLY0(object, object)
stloc.0
ldloc.0
tail. call object M::EVAL0(object)
ret
}
.method static assembly object io_bind1(object e0, object e1, object e2, object e3, object e4, object w, object in0) cil managed
{
.locals init (
object l0)
ldarg.0
ldarg.1
ldarg.2
ldarg.3
ldarg 4
ldarg 5
ldarg 6
call object M::io_bind0(object, object, object, object, object, object, object)
stloc.0
ldloc.0
ldarg 5
tail. call object M::APPLY0(object, object)
ret
}
.method static assembly object putStr1(object in1) cil managed
{
.locals init (
object l0,
object l1,
object l2)
ldc.i4.0
ldc.i4.0
newarr object
newobj instance void SCon::.ctor(int32, object[])
stloc.2
ldc.i4 65629
ldc.i4.3
newarr object
dup
ldc.i4.0
ldloc.0
stelem.ref
dup
ldc.i4.1
ldloc.1
stelem.ref
dup
ldc.i4.2
ldloc.2
stelem.ref
newobj instance void SCon::.ctor(int32, object[])
ret
}
.method static assembly object io_bind2(object e0, object e1, object e2, object e3, object e4, object w) cil managed
{
.locals init (
object l0)
ldc.i4 65630
ldc.i4.6
newarr object
dup
ldc.i4.0
ldarg.0
stelem.ref
dup
ldc.i4.1
ldarg.1
stelem.ref
dup
ldc.i4.2
ldarg.2
stelem.ref
dup
ldc.i4.3
ldarg.3
stelem.ref
dup
ldc.i4.4
ldarg 4
stelem.ref
dup
ldc.i4.5
ldarg 5
stelem.ref
newobj instance void SCon::.ctor(int32, object[])
ret
}
.method static assembly object case_block_in_io_bind(object e0, object e1, object e2, object e3, object e4, object e5, object e6, object e7) cil managed
{
.locals init (
object l0)
ldarg 7
ldarg 5
tail. call object M::APPLY0(object, object)
ret
}
}
.class private SCon
{
.field public int32 tag
.field public object[] fields
.method public void .ctor(int32 tag, object[] fields) cil managed
{
ldarg.0
call instance void object::.ctor()
ldarg.0
ldarg.1
stfld int32 SCon::tag
ldarg.0
ldarg.2
stfld object[] SCon::fields
ret
}
}
module Main
main : IO ()
main = putStrLn "Hello, Idris!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment