fun3.golden 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. ********** source program **********
  2. fn f (0 = Int: x, 1 = Int: y) -> Int {
  3. return (x + y);
  4. }
  5. fn main () -> Int {
  6. return (f(0 = 2, 1 = 3) - 5);
  7. }
  8. ********** type checking **********
  9. --- step exp Int --->
  10. --- step exp Int --->
  11. --- step exp Int --->
  12. --- step exp Int --->
  13. --- step exp Int --->
  14. --- step exp Int --->
  15. --- step exp Int --->
  16. --- step exp Int --->
  17. ********** type checking complete **********
  18. fn f (0 = Int: x, 1 = Int: y) -> Int {
  19. return (x + y);
  20. }
  21. fn main () -> Int {
  22. return (f(0 = 2, 1 = 3) - 5);
  23. }
  24. ********** starting execution **********
  25. ********** initializing globals **********
  26. --- step exp (0 = Int: x, 1 = Int: y) --->
  27. --- step exp Int: x --->
  28. --- step exp Int --->
  29. --- handle value Int with Int: x<1>(Int,) --->
  30. --- handle value Int: x with (0 = Int: x, 1 = Int: y)<1>(Int: x,) --->
  31. --- step exp Int: y --->
  32. --- step exp Int --->
  33. --- handle value Int with Int: y<1>(Int,) --->
  34. --- handle value Int: y with (0 = Int: x, 1 = Int: y)<2>(Int: x,Int: y,) --->
  35. --- step exp () --->
  36. ********** calling main function **********
  37. {
  38. stack: top{main()<-1>}
  39. heap: Int: x, Int: y, fun<f>, fun<main>,
  40. env: main: fun<main>, f: fun<f>,
  41. }
  42. --- step exp main() --->
  43. {
  44. stack: top{main<-1> :: main()<0>}
  45. heap: Int: x, Int: y, fun<f>, fun<main>,
  46. env: main: fun<main>, f: fun<f>,
  47. }
  48. --- step exp main --->
  49. {
  50. stack: top{fun<main><-1> :: main()<0>}
  51. heap: Int: x, Int: y, fun<f>, fun<main>,
  52. env: main: fun<main>, f: fun<f>,
  53. }
  54. --- handle value fun<main> with main()<1>(fun<main>,) --->
  55. {
  56. stack: top{()<-1> :: main()<1>(fun<main>,)}
  57. heap: Int: x, Int: y, fun<f>, fun<main>,
  58. env: main: fun<main>, f: fun<f>,
  59. }
  60. --- step exp () --->
  61. {
  62. stack: top{()<-1> :: main()<1>(fun<main>,)}
  63. heap: Int: x, Int: y, fun<f>, fun<main>,
  64. env: main: fun<main>, f: fun<f>,
  65. }
  66. --- handle value () with main()<2>(fun<main>,(),) --->
  67. pattern_match((), ())
  68. {
  69. stack: main{return (f(0 = 2, 1 = 3) - 5);<-1>} :: top{}
  70. heap: Int: x, Int: y, fun<f>, fun<main>,
  71. env: main: fun<main>, f: fun<f>,
  72. }
  73. --- step stmt return (f(0 = 2, 1 = 3) - 5); --->
  74. {
  75. stack: main{(f(0 = 2, 1 = 3) - 5)<-1> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  76. heap: Int: x, Int: y, fun<f>, fun<main>,
  77. env: main: fun<main>, f: fun<f>,
  78. }
  79. --- step exp (f(0 = 2, 1 = 3) - 5) --->
  80. {
  81. stack: main{f(0 = 2, 1 = 3)<-1> :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  82. heap: Int: x, Int: y, fun<f>, fun<main>,
  83. env: main: fun<main>, f: fun<f>,
  84. }
  85. --- step exp f(0 = 2, 1 = 3) --->
  86. {
  87. stack: main{f<-1> :: f(0 = 2, 1 = 3)<0> :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  88. heap: Int: x, Int: y, fun<f>, fun<main>,
  89. env: main: fun<main>, f: fun<f>,
  90. }
  91. --- step exp f --->
  92. {
  93. stack: main{fun<f><-1> :: f(0 = 2, 1 = 3)<0> :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  94. heap: Int: x, Int: y, fun<f>, fun<main>,
  95. env: main: fun<main>, f: fun<f>,
  96. }
  97. --- handle value fun<f> with f(0 = 2, 1 = 3)<1>(fun<f>,) --->
  98. {
  99. stack: main{(0 = 2, 1 = 3)<-1> :: f(0 = 2, 1 = 3)<1>(fun<f>,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  100. heap: Int: x, Int: y, fun<f>, fun<main>,
  101. env: main: fun<main>, f: fun<f>,
  102. }
  103. --- step exp (0 = 2, 1 = 3) --->
  104. {
  105. stack: main{2<-1> :: (0 = 2, 1 = 3)<0> :: f(0 = 2, 1 = 3)<1>(fun<f>,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  106. heap: Int: x, Int: y, fun<f>, fun<main>,
  107. env: main: fun<main>, f: fun<f>,
  108. }
  109. --- step exp 2 --->
  110. {
  111. stack: main{2<-1> :: (0 = 2, 1 = 3)<0> :: f(0 = 2, 1 = 3)<1>(fun<f>,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  112. heap: Int: x, Int: y, fun<f>, fun<main>,
  113. env: main: fun<main>, f: fun<f>,
  114. }
  115. --- handle value 2 with (0 = 2, 1 = 3)<1>(2,) --->
  116. {
  117. stack: main{3<-1> :: (0 = 2, 1 = 3)<1>(2,) :: f(0 = 2, 1 = 3)<1>(fun<f>,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  118. heap: Int: x, Int: y, fun<f>, fun<main>,
  119. env: main: fun<main>, f: fun<f>,
  120. }
  121. --- step exp 3 --->
  122. {
  123. stack: main{3<-1> :: (0 = 2, 1 = 3)<1>(2,) :: f(0 = 2, 1 = 3)<1>(fun<f>,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  124. heap: Int: x, Int: y, fun<f>, fun<main>,
  125. env: main: fun<main>, f: fun<f>,
  126. }
  127. --- handle value 3 with (0 = 2, 1 = 3)<2>(2,3,) --->
  128. {
  129. stack: main{(0 = 2@4, 1 = 3@5)<-1> :: f(0 = 2, 1 = 3)<1>(fun<f>,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  130. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3,
  131. env: main: fun<main>, f: fun<f>,
  132. }
  133. --- handle value (0 = 2@4, 1 = 3@5) with f(0 = 2, 1 = 3)<2>(fun<f>,(0 = 2@4, 1 = 3@5),) --->
  134. pattern_match((0 = Int: x@0, 1 = Int: y@1), (0 = 2@4, 1 = 3@5))
  135. pattern_match(Int: x, 2)
  136. pattern_match(Int: y, 3)
  137. {
  138. stack: f{return (x + y);<-1>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  139. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, 2, 3,
  140. env: y: 3, x: 2, main: fun<main>, f: fun<f>,
  141. }
  142. --- step stmt return (x + y); --->
  143. {
  144. stack: f{(x + y)<-1> :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  145. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, 2, 3,
  146. env: y: 3, x: 2, main: fun<main>, f: fun<f>,
  147. }
  148. --- step exp (x + y) --->
  149. {
  150. stack: f{x<-1> :: (x + y)<0> :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  151. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, 2, 3,
  152. env: y: 3, x: 2, main: fun<main>, f: fun<f>,
  153. }
  154. --- step exp x --->
  155. {
  156. stack: f{2<-1> :: (x + y)<0> :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  157. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, 2, 3,
  158. env: y: 3, x: 2, main: fun<main>, f: fun<f>,
  159. }
  160. --- handle value 2 with (x + y)<1>(2,) --->
  161. {
  162. stack: f{y<-1> :: (x + y)<1>(2,) :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  163. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, 2, 3,
  164. env: y: 3, x: 2, main: fun<main>, f: fun<f>,
  165. }
  166. --- step exp y --->
  167. {
  168. stack: f{3<-1> :: (x + y)<1>(2,) :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  169. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, 2, 3,
  170. env: y: 3, x: 2, main: fun<main>, f: fun<f>,
  171. }
  172. --- handle value 3 with (x + y)<2>(2,3,) --->
  173. {
  174. stack: f{5<-1> :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  175. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, 2, 3,
  176. env: y: 3, x: 2, main: fun<main>, f: fun<f>,
  177. }
  178. --- handle value 5 with return (x + y);<1>(5,) --->
  179. {
  180. stack: main{5<-1> :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  181. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, !!2, !!3,
  182. env: main: fun<main>, f: fun<f>,
  183. }
  184. --- handle value 5 with (f(0 = 2, 1 = 3) - 5)<1>(5,) --->
  185. {
  186. stack: main{5<-1> :: (f(0 = 2, 1 = 3) - 5)<1>(5,) :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  187. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, !!2, !!3,
  188. env: main: fun<main>, f: fun<f>,
  189. }
  190. --- step exp 5 --->
  191. {
  192. stack: main{5<-1> :: (f(0 = 2, 1 = 3) - 5)<1>(5,) :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  193. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, !!2, !!3,
  194. env: main: fun<main>, f: fun<f>,
  195. }
  196. --- handle value 5 with (f(0 = 2, 1 = 3) - 5)<2>(5,5,) --->
  197. {
  198. stack: main{0<-1> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{}
  199. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, !!2, !!3,
  200. env: main: fun<main>, f: fun<f>,
  201. }
  202. --- handle value 0 with return (f(0 = 2, 1 = 3) - 5);<1>(0,) --->
  203. {
  204. stack: top{0<-1>}
  205. heap: Int: x, Int: y, fun<f>, fun<main>, 2, 3, !!2, !!3,
  206. env: main: fun<main>, f: fun<f>,
  207. }
  208. result: 0