Skip to content

Instantly share code, notes, and snippets.

@pyrocat101
Created November 25, 2014 10:39
Show Gist options
  • Save pyrocat101/0f568bf48f471481fc67 to your computer and use it in GitHub Desktop.
Save pyrocat101/0f568bf48f471481fc67 to your computer and use it in GitHub Desktop.
const vmt_A
:A.init
:A.test_while
:A.get_if_self
:A.test_if_main
:A.test_if_0
:A.test_if1
:A.test_if2
:A.get_int
:A.set_e
:A.get_e
:A.another_A_init
:A.iter_A_a
const vmt_B
:A.init
:A.test_while
:A.get_if_self
:A.test_if_main
:A.test_if_0
:A.test_if1
:A.test_if2
:A.get_int
:B.set_e
:B.get_e
:A.another_A_init
:A.iter_A_a
:B.init_and_test_array_alloc
:B.get_arr_1
:B.get_arr_2
:B.get_arr_3
:B.get_arr_4
:B.another_B_init
:B.iter_B_a
const vmt_C
:A.init
:A.test_while
:A.get_if_self
:A.test_if_main
:A.test_if_0
:A.test_if1
:A.test_if2
:A.get_int
:C.set_e
:C.get_e
:A.another_A_init
:A.iter_A_a
:B.init_and_test_array_alloc
:C.get_arr_1
:B.get_arr_2
:B.get_arr_3
:B.get_arr_4
:B.another_B_init
:B.iter_B_a
:C.c_init
:C.iter_C_a
func Main()
t.0 = HeapAllocZ(24)
if t.0 goto :null0
Error("null pointer")
null0:
[t.0] = :vmt_A
a = t.0
t.1 = [a]
t.1 = [t.1+0]
t.2 = call t.1(a)
b = t.2
t.3 = [a]
t.3 = [t.3+4]
t.4 = call t.3(a)
b = t.4
t.5 = [a]
t.5 = [t.5+12]
t.6 = call t.5(a)
b = t.6
t.7 = HeapAllocZ(44)
if t.7 goto :null1
Error("null pointer")
null1:
[t.7] = :vmt_B
t.8 = [t.7]
t.8 = [t.8+48]
t.9 = call t.8(t.7)
b = t.9
PrintIntS(999999999)
t.10 = HeapAllocZ(60)
if t.10 goto :null2
Error("null pointer")
null2:
[t.10] = :vmt_C
cc = t.10
t.11 = [cc]
t.11 = [t.11+76]
t.12 = call t.11(cc)
b = t.12
ret
func A.init(this)
t.0 = call :AllocArray(10)
[this+4] = t.0
t.1 = [this]
t.1 = [t.1+28]
t.2 = call t.1(this 5)
t.3 = call :AllocArray(t.2)
[this+8] = t.3
[this+12] = 0
[this+16] = 0
[this+20] = 1984
ret 1
func A.test_while(this)
a = 5
while_top3:
t.0 = LtS(a 10)
if0 t.0 goto :while_end4
while_top5:
t.1 = LtS(a 10)
if0 t.1 goto :while_end6
while_top7:
t.2 = LtS(a 10)
if0 t.2 goto :while_end8
while_top9:
t.3 = LtS(a 10)
if t.3 goto :and_second10
t.4 = t.3
goto :and_end11
and_second10:
t.5 = LtS(a 15)
t.4 = t.5
and_end11:
if0 t.4 goto :while_end12
t.6 = [this]
t.6 = [t.6+28]
t.7 = Add(a 1)
t.8 = call t.6(this t.7)
a = t.8
t.9 = [this]
t.9 = [t.9+8]
t.10 = call t.9(this)
t.11 = [t.10]
t.11 = [t.11+12]
t.12 = call t.11(t.10)
if0 t.12 goto :if_else13
t.13 = [this]
t.13 = [t.13+28]
t.14 = call t.13(this a)
a = t.14
goto :if_end14
if_else13:
t.15 = [this]
t.15 = [t.15+28]
t.16 = Sub(a 1)
t.17 = Add(t.16 1)
t.18 = MulS(t.17 1)
t.19 = call t.15(this t.18)
a = t.19
if_end14:
goto :while_top9
while_end12:
goto :while_top7
while_end8:
goto :while_top5
while_end6:
goto :while_top3
while_end4:
PrintIntS(a)
ret 1
func A.get_if_self(this)
ret this
func A.test_if_main(this)
t.0 = HeapAllocZ(24)
if t.0 goto :null15
Error("null pointer")
null15:
[t.0] = :vmt_A
t.1 = [t.0]
t.1 = [t.1+16]
t.2 = call t.1(t.0)
t.3 = Sub(1 t.2)
if t.3 goto :and_second16
t.4 = t.3
goto :and_end17
and_second16:
t.5 = [this]
t.5 = [t.5+24]
t.6 = call t.5(this)
t.7 = Sub(1 t.6)
t.4 = t.7
and_end17:
t.8 = Sub(1 t.4)
t.9 = Sub(1 t.8)
if0 t.9 goto :if_else18
PrintIntS(0)
goto :if_end19
if_else18:
PrintIntS(1)
if_end19:
if 1 goto :and_second20
t.10 = 1
goto :and_end21
and_second20:
t.10 = 0
and_end21:
if t.10 goto :and_second22
t.11 = t.10
goto :and_end23
and_second22:
t.11 = 1
and_end23:
if t.11 goto :and_second24
t.12 = t.11
goto :and_end25
and_second24:
t.12 = 0
and_end25:
if t.12 goto :and_second26
t.13 = t.12
goto :and_end27
and_second26:
t.13 = 1
and_end27:
ret t.13
func A.test_if_0(this)
b = 0
t.0 = [this]
t.0 = [t.0+20]
t.1 = call t.0(this)
if t.1 goto :and_second28
t.2 = t.1
goto :and_end29
and_second28:
t.3 = HeapAllocZ(24)
if t.3 goto :null30
Error("null pointer")
null30:
[t.3] = :vmt_A
t.4 = [t.3]
t.4 = [t.4+24]
t.5 = call t.4(t.3)
t.2 = t.5
and_end29:
if t.2 goto :and_second31
t.6 = t.2
goto :and_end32
and_second31:
t.7 = HeapAllocZ(24)
if t.7 goto :null33
Error("null pointer")
null33:
[t.7] = :vmt_A
t.8 = [t.7]
t.8 = [t.8+20]
t.9 = call t.8(t.7)
t.6 = t.9
and_end32:
b = t.6
ret b
func A.test_if1(this)
if 0 goto :and_second34
t.0 = 0
goto :and_end35
and_second34:
t.0 = 1
and_end35:
if t.0 goto :and_second36
t.1 = t.0
goto :and_end37
and_second36:
t.1 = 1
and_end37:
ret t.1
func A.test_if2(this)
if 0 goto :and_second38
t.0 = 0
goto :and_end39
and_second38:
t.0 = 1
and_end39:
if t.0 goto :and_second40
t.1 = t.0
goto :and_end41
and_second40:
t.1 = 0
and_end41:
if t.1 goto :and_second42
t.2 = t.1
goto :and_end43
and_second42:
t.3 = [this]
t.3 = [t.3+20]
t.4 = call t.3(this)
t.2 = t.4
and_end43:
ret t.2
func A.get_int(this a)
ret a
func A.set_e(this)
[this+20] = 1
ret 1
func A.get_e(this)
t.0 = [this+20]
ret t.0
func A.another_A_init(this)
t.0 = HeapAllocZ(44)
if t.0 goto :null44
Error("null pointer")
null44:
[t.0] = :vmt_B
t.1 = [t.0]
t.1 = [t.1+60]
t.2 = call t.1(t.0)
[this+4] = t.2
ret 1
func A.iter_A_a(this)
t.0 = [this+4]
t.1 = [t.0]
t.1 = Lt(0 t.1)
if t.1 goto :bounds45
Error("array index out of bounds")
bounds45:
t.1 = Add(t.0 4)
t.1 = [t.1]
PrintIntS(t.1)
t.2 = [this+4]
t.3 = [t.2]
t.3 = Lt(1 t.3)
if t.3 goto :bounds46
Error("array index out of bounds")
bounds46:
t.3 = Add(t.2 8)
t.3 = [t.3]
PrintIntS(t.3)
t.4 = [this+4]
t.5 = [t.4]
t.5 = Lt(2 t.5)
if t.5 goto :bounds47
Error("array index out of bounds")
bounds47:
t.5 = Add(t.4 12)
t.5 = [t.5]
PrintIntS(t.5)
ret 1
func B.init_and_test_array_alloc(this)
t.0 = HeapAllocZ(44)
if t.0 goto :null48
Error("null pointer")
null48:
[t.0] = :vmt_B
t.1 = [t.0]
t.1 = [t.1+52]
t.2 = call t.1(t.0)
[this+24] = t.2
t.3 = [this]
t.3 = [t.3+56]
t.4 = call t.3(this)
[this+28] = t.4
t.5 = [this+24]
t.6 = [t.5]
t.6 = Lt(0 t.6)
if t.6 goto :bounds49
Error("array index out of bounds")
bounds49:
t.6 = Add(t.5 4)
t.6 = [t.6]
PrintIntS(t.6)
t.7 = [this+24]
t.8 = [t.7]
t.8 = Lt(1 t.8)
if t.8 goto :bounds50
Error("array index out of bounds")
bounds50:
t.8 = Add(t.7 8)
t.8 = [t.8]
PrintIntS(t.8)
t.9 = [this+24]
t.10 = [t.9]
t.10 = Lt(2 t.10)
if t.10 goto :bounds51
Error("array index out of bounds")
bounds51:
t.10 = Add(t.9 12)
t.10 = [t.10]
PrintIntS(t.10)
t.11 = [this+28]
t.12 = [t.11]
t.12 = Lt(0 t.12)
if t.12 goto :bounds52
Error("array index out of bounds")
bounds52:
t.12 = Add(t.11 4)
t.12 = [t.12]
PrintIntS(t.12)
t.13 = [this+28]
t.14 = [t.13]
t.14 = Lt(1 t.14)
if t.14 goto :bounds53
Error("array index out of bounds")
bounds53:
t.14 = Add(t.13 8)
t.14 = [t.14]
PrintIntS(t.14)
t.15 = [this+28]
t.16 = [t.15]
t.16 = Lt(2 t.16)
if t.16 goto :bounds54
Error("array index out of bounds")
bounds54:
t.16 = Add(t.15 12)
t.16 = [t.16]
PrintIntS(t.16)
ret 0
func B.get_arr_1(this)
t.0 = call :AllocArray(3)
a1 = t.0
t.1 = [a1]
t.1 = Lt(0 t.1)
if t.1 goto :bounds55
Error("array index out of bounds")
bounds55:
t.1 = Add(a1 4)
[t.1] = 1
t.2 = [a1]
t.2 = Lt(1 t.2)
if t.2 goto :bounds56
Error("array index out of bounds")
bounds56:
t.2 = Add(a1 8)
[t.2] = 2
t.3 = [a1]
t.3 = Lt(2 t.3)
if t.3 goto :bounds57
Error("array index out of bounds")
bounds57:
t.3 = Add(a1 12)
[t.3] = 3
ret a1
func B.get_arr_2(this)
t.0 = call :AllocArray(4)
a1 = t.0
t.1 = [a1]
t.1 = Lt(0 t.1)
if t.1 goto :bounds58
Error("array index out of bounds")
bounds58:
t.1 = Add(a1 4)
[t.1] = 4
t.2 = [a1]
t.2 = Lt(1 t.2)
if t.2 goto :bounds59
Error("array index out of bounds")
bounds59:
t.2 = Add(a1 8)
[t.2] = 5
t.3 = [a1]
t.3 = Lt(2 t.3)
if t.3 goto :bounds60
Error("array index out of bounds")
bounds60:
t.3 = Add(a1 12)
[t.3] = 6
t.4 = [a1]
t.4 = Lt(3 t.4)
if t.4 goto :bounds61
Error("array index out of bounds")
bounds61:
t.4 = Add(a1 16)
[t.4] = 61
ret a1
func B.get_arr_3(this)
t.0 = call :AllocArray(5)
a1 = t.0
t.1 = [a1]
t.1 = Lt(0 t.1)
if t.1 goto :bounds62
Error("array index out of bounds")
bounds62:
t.1 = Add(a1 4)
[t.1] = 7
t.2 = [a1]
t.2 = Lt(1 t.2)
if t.2 goto :bounds63
Error("array index out of bounds")
bounds63:
t.2 = Add(a1 8)
[t.2] = 8
t.3 = [a1]
t.3 = Lt(2 t.3)
if t.3 goto :bounds64
Error("array index out of bounds")
bounds64:
t.3 = Add(a1 12)
[t.3] = 9
t.4 = [a1]
t.4 = Lt(3 t.4)
if t.4 goto :bounds65
Error("array index out of bounds")
bounds65:
t.4 = Add(a1 16)
[t.4] = 91
t.5 = [a1]
t.5 = Lt(4 t.5)
if t.5 goto :bounds66
Error("array index out of bounds")
bounds66:
t.5 = Add(a1 20)
[t.5] = 92
ret a1
func B.get_arr_4(this)
t.0 = call :AllocArray(6)
a1 = t.0
t.1 = [a1]
t.1 = Lt(0 t.1)
if t.1 goto :bounds67
Error("array index out of bounds")
bounds67:
t.1 = Add(a1 4)
[t.1] = 10
t.2 = [a1]
t.2 = Lt(1 t.2)
if t.2 goto :bounds68
Error("array index out of bounds")
bounds68:
t.2 = Add(a1 8)
[t.2] = 11
t.3 = [a1]
t.3 = Lt(2 t.3)
if t.3 goto :bounds69
Error("array index out of bounds")
bounds69:
t.3 = Add(a1 12)
[t.3] = 12
t.4 = [a1]
t.4 = Lt(3 t.4)
if t.4 goto :bounds70
Error("array index out of bounds")
bounds70:
t.4 = Add(a1 16)
[t.4] = 121
t.5 = [a1]
t.5 = Lt(4 t.5)
if t.5 goto :bounds71
Error("array index out of bounds")
bounds71:
t.5 = Add(a1 20)
[t.5] = 122
ret a1
func B.another_B_init(this)
t.0 = [this]
t.0 = [t.0+64]
t.1 = call t.0(this)
[this+24] = t.1
ret 1
func B.iter_B_a(this)
t.0 = [this+24]
t.1 = [t.0]
t.1 = Lt(0 t.1)
if t.1 goto :bounds72
Error("array index out of bounds")
bounds72:
t.1 = Add(t.0 4)
t.1 = [t.1]
PrintIntS(t.1)
t.2 = [this+24]
t.3 = [t.2]
t.3 = Lt(1 t.3)
if t.3 goto :bounds73
Error("array index out of bounds")
bounds73:
t.3 = Add(t.2 8)
t.3 = [t.3]
PrintIntS(t.3)
t.4 = [this+24]
t.5 = [t.4]
t.5 = Lt(2 t.5)
if t.5 goto :bounds74
Error("array index out of bounds")
bounds74:
t.5 = Add(t.4 12)
t.5 = [t.5]
PrintIntS(t.5)
ret 1
func B.set_e(this)
[this+40] = 2
ret 1
func B.get_e(this)
t.0 = [this+40]
ret t.0
func C.c_init(this)
t.0 = HeapAllocZ(60)
if t.0 goto :null75
Error("null pointer")
null75:
[t.0] = :vmt_C
t.1 = [t.0]
t.1 = [t.1+52]
t.2 = call t.1(t.0)
[this+44] = t.2
t.3 = [this]
t.3 = [t.3+52]
t.4 = call t.3(this)
[this+48] = t.4
t.5 = [this]
t.5 = [t.5+40]
t.6 = call t.5(this)
[this+56] = t.6
t.7 = [this]
t.7 = [t.7+68]
t.8 = call t.7(this)
[this+56] = t.8
t.9 = [this]
t.9 = [t.9+44]
t.10 = call t.9(this)
[this+56] = t.10
t.11 = [this]
t.11 = [t.11+72]
t.12 = call t.11(this)
[this+56] = t.12
t.13 = [this]
t.13 = [t.13+80]
t.14 = call t.13(this)
[this+56] = t.14
ret 0
func C.iter_C_a(this)
t.0 = [this+44]
t.1 = [t.0]
t.1 = Lt(0 t.1)
if t.1 goto :bounds76
Error("array index out of bounds")
bounds76:
t.1 = Add(t.0 4)
t.1 = [t.1]
PrintIntS(t.1)
t.2 = [this+44]
t.3 = [t.2]
t.3 = Lt(1 t.3)
if t.3 goto :bounds77
Error("array index out of bounds")
bounds77:
t.3 = Add(t.2 8)
t.3 = [t.3]
PrintIntS(t.3)
t.4 = [this+44]
t.5 = [t.4]
t.5 = Lt(2 t.5)
if t.5 goto :bounds78
Error("array index out of bounds")
bounds78:
t.5 = Add(t.4 12)
t.5 = [t.5]
PrintIntS(t.5)
ret 0
func C.set_e(this)
[this+52] = 3
ret 1
func C.get_e(this)
t.0 = [this+52]
ret t.0
func C.get_arr_1(this)
t.0 = call :AllocArray(3)
a1 = t.0
t.1 = [a1]
t.1 = Lt(0 t.1)
if t.1 goto :bounds79
Error("array index out of bounds")
bounds79:
t.1 = Add(a1 4)
[t.1] = 31
t.2 = [a1]
t.2 = Lt(1 t.2)
if t.2 goto :bounds80
Error("array index out of bounds")
bounds80:
t.2 = Add(a1 8)
[t.2] = 32
t.3 = [a1]
t.3 = Lt(2 t.3)
if t.3 goto :bounds81
Error("array index out of bounds")
bounds81:
t.3 = Add(a1 12)
[t.3] = 33
ret a1
func AllocArray(size)
bytes = MulS(size 4)
bytes = Add(bytes 4)
v = HeapAllocZ(bytes)
[v] = size
ret v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment