struct2.golden 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. ********** source program **********
  2. struct Point {
  3. var x : Int;
  4. var y : Int;
  5. }
  6. fn main () -> Int {
  7. var auto: p1 = Point(x = 1, y = 2);
  8. var auto: p2 = p1;
  9. p2.x = 3;
  10. return (p1.x - 1);
  11. }
  12. ********** type checking **********
  13. --- step exp Int --->
  14. --- step exp Int --->
  15. --- step exp Int --->
  16. --- step exp Int --->
  17. --- step exp auto --->
  18. --- step exp auto --->
  19. ********** type checking complete **********
  20. struct Point {
  21. var x : Int;
  22. var y : Int;
  23. }
  24. fn main () -> Int {
  25. var auto: p1 = Point(x = 1, y = 2);
  26. var auto: p2 = p1;
  27. p2.x = 3;
  28. return (p1.x - 1);
  29. }
  30. ********** starting execution **********
  31. ********** initializing globals **********
  32. --- step exp Int --->
  33. --- step exp Int --->
  34. --- step exp () --->
  35. ********** calling main function **********
  36. {
  37. stack: top{main()<-1>}
  38. heap: struct Point, fun<main>,
  39. env: main: fun<main>, Point: struct Point,
  40. }
  41. --- step exp main() --->
  42. {
  43. stack: top{main<-1> :: main()<0>}
  44. heap: struct Point, fun<main>,
  45. env: main: fun<main>, Point: struct Point,
  46. }
  47. --- step exp main --->
  48. {
  49. stack: top{fun<main><-1> :: main()<0>}
  50. heap: struct Point, fun<main>,
  51. env: main: fun<main>, Point: struct Point,
  52. }
  53. --- handle value fun<main> with main()<1>(fun<main>,) --->
  54. {
  55. stack: top{()<-1> :: main()<1>(fun<main>,)}
  56. heap: struct Point, fun<main>,
  57. env: main: fun<main>, Point: struct Point,
  58. }
  59. --- step exp () --->
  60. {
  61. stack: top{()<-1> :: main()<1>(fun<main>,)}
  62. heap: struct Point, fun<main>,
  63. env: main: fun<main>, Point: struct Point,
  64. }
  65. --- handle value () with main()<2>(fun<main>,(),) --->
  66. pattern_match((), ())
  67. {
  68. stack: main{var auto: p1 = Point(x = 1, y = 2); ... <-1>} :: top{}
  69. heap: struct Point, fun<main>,
  70. env: main: fun<main>, Point: struct Point,
  71. }
  72. --- step stmt var auto: p1 = Point(x = 1, y = 2); ... --->
  73. {
  74. stack: main{var auto: p1 = Point(x = 1, y = 2);<-1> :: var auto: p2 = p1; ... <-1>} :: top{}
  75. heap: struct Point, fun<main>,
  76. env: main: fun<main>, Point: struct Point,
  77. }
  78. --- step stmt var auto: p1 = Point(x = 1, y = 2); --->
  79. {
  80. stack: main{Point(x = 1, y = 2)<-1> :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  81. heap: struct Point, fun<main>,
  82. env: main: fun<main>, Point: struct Point,
  83. }
  84. --- step exp Point(x = 1, y = 2) --->
  85. {
  86. stack: main{Point<-1> :: Point(x = 1, y = 2)<0> :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  87. heap: struct Point, fun<main>,
  88. env: main: fun<main>, Point: struct Point,
  89. }
  90. --- step exp Point --->
  91. {
  92. stack: main{struct Point<-1> :: Point(x = 1, y = 2)<0> :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  93. heap: struct Point, fun<main>,
  94. env: main: fun<main>, Point: struct Point,
  95. }
  96. --- handle value struct Point with Point(x = 1, y = 2)<1>(struct Point,) --->
  97. {
  98. stack: main{(x = 1, y = 2)<-1> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  99. heap: struct Point, fun<main>,
  100. env: main: fun<main>, Point: struct Point,
  101. }
  102. --- step exp (x = 1, y = 2) --->
  103. {
  104. stack: main{1<-1> :: (x = 1, y = 2)<0> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  105. heap: struct Point, fun<main>,
  106. env: main: fun<main>, Point: struct Point,
  107. }
  108. --- step exp 1 --->
  109. {
  110. stack: main{1<-1> :: (x = 1, y = 2)<0> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  111. heap: struct Point, fun<main>,
  112. env: main: fun<main>, Point: struct Point,
  113. }
  114. --- handle value 1 with (x = 1, y = 2)<1>(1,) --->
  115. {
  116. stack: main{2<-1> :: (x = 1, y = 2)<1>(1,) :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  117. heap: struct Point, fun<main>,
  118. env: main: fun<main>, Point: struct Point,
  119. }
  120. --- step exp 2 --->
  121. {
  122. stack: main{2<-1> :: (x = 1, y = 2)<1>(1,) :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  123. heap: struct Point, fun<main>,
  124. env: main: fun<main>, Point: struct Point,
  125. }
  126. --- handle value 2 with (x = 1, y = 2)<2>(1,2,) --->
  127. {
  128. stack: main{(x = 1@2, y = 2@3)<-1> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  129. heap: struct Point, fun<main>, 1, 2,
  130. env: main: fun<main>, Point: struct Point,
  131. }
  132. --- handle value (x = 1@2, y = 2@3) with Point(x = 1, y = 2)<2>(struct Point,(x = 1@2, y = 2@3),) --->
  133. {
  134. stack: main{Point(x = 1@4, y = 2@5)<-1> :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{}
  135. heap: struct Point, fun<main>, 1, 2, 1, 2,
  136. env: main: fun<main>, Point: struct Point,
  137. }
  138. --- handle value Point(x = 1@4, y = 2@5) with var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) --->
  139. {
  140. stack: main{auto: p1<-1> :: var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: var auto: p2 = p1; ... <-1>} :: top{}
  141. heap: struct Point, fun<main>, 1, 2, 1, 2,
  142. env: main: fun<main>, Point: struct Point,
  143. }
  144. --- step exp auto: p1 --->
  145. {
  146. stack: main{auto<-1> :: auto: p1<0> :: var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: var auto: p2 = p1; ... <-1>} :: top{}
  147. heap: struct Point, fun<main>, 1, 2, 1, 2,
  148. env: main: fun<main>, Point: struct Point,
  149. }
  150. --- step exp auto --->
  151. {
  152. stack: main{auto<-1> :: auto: p1<0> :: var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: var auto: p2 = p1; ... <-1>} :: top{}
  153. heap: struct Point, fun<main>, 1, 2, 1, 2,
  154. env: main: fun<main>, Point: struct Point,
  155. }
  156. --- handle value auto with auto: p1<1>(auto,) --->
  157. {
  158. stack: main{auto: p1<-1> :: var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: var auto: p2 = p1; ... <-1>} :: top{}
  159. heap: struct Point, fun<main>, 1, 2, 1, 2,
  160. env: main: fun<main>, Point: struct Point,
  161. }
  162. --- handle value auto: p1 with var auto: p1 = Point(x = 1, y = 2);<2>(Point(x = 1@4, y = 2@5),auto: p1,) --->
  163. pattern_match(auto: p1, Point(x = 1@4, y = 2@5))
  164. {
  165. stack: main{var auto: p2 = p1; ... <-1>} :: top{}
  166. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7),
  167. env: p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  168. }
  169. --- step stmt var auto: p2 = p1; ... --->
  170. {
  171. stack: main{var auto: p2 = p1;<-1> :: p2.x = 3; ... <-1>} :: top{}
  172. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7),
  173. env: p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  174. }
  175. --- step stmt var auto: p2 = p1; --->
  176. {
  177. stack: main{p1<-1> :: var auto: p2 = p1;<0> :: p2.x = 3; ... <-1>} :: top{}
  178. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7),
  179. env: p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  180. }
  181. --- step exp p1 --->
  182. {
  183. stack: main{Point(x = 1@6, y = 2@7)<-1> :: var auto: p2 = p1;<0> :: p2.x = 3; ... <-1>} :: top{}
  184. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7),
  185. env: p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  186. }
  187. --- handle value Point(x = 1@6, y = 2@7) with var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) --->
  188. {
  189. stack: main{auto: p2<-1> :: var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) :: p2.x = 3; ... <-1>} :: top{}
  190. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7),
  191. env: p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  192. }
  193. --- step exp auto: p2 --->
  194. {
  195. stack: main{auto<-1> :: auto: p2<0> :: var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) :: p2.x = 3; ... <-1>} :: top{}
  196. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7),
  197. env: p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  198. }
  199. --- step exp auto --->
  200. {
  201. stack: main{auto<-1> :: auto: p2<0> :: var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) :: p2.x = 3; ... <-1>} :: top{}
  202. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7),
  203. env: p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  204. }
  205. --- handle value auto with auto: p2<1>(auto,) --->
  206. {
  207. stack: main{auto: p2<-1> :: var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) :: p2.x = 3; ... <-1>} :: top{}
  208. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7),
  209. env: p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  210. }
  211. --- handle value auto: p2 with var auto: p2 = p1;<2>(Point(x = 1@6, y = 2@7),auto: p2,) --->
  212. pattern_match(auto: p2, Point(x = 1@6, y = 2@7))
  213. {
  214. stack: main{p2.x = 3; ... <-1>} :: top{}
  215. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10),
  216. env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  217. }
  218. --- step stmt p2.x = 3; ... --->
  219. {
  220. stack: main{p2.x = 3;<-1> :: return (p1.x - 1);<-1>} :: top{}
  221. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10),
  222. env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  223. }
  224. --- step stmt p2.x = 3; --->
  225. {
  226. stack: main{p2.x<-1> :: p2.x = 3;<0> :: return (p1.x - 1);<-1>} :: top{}
  227. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10),
  228. env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  229. }
  230. --- step lvalue p2.x --->
  231. {
  232. stack: main{p2<-1> :: p2.x<0> :: p2.x = 3;<0> :: return (p1.x - 1);<-1>} :: top{}
  233. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10),
  234. env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  235. }
  236. --- step lvalue p2 --->
  237. {
  238. stack: main{ptr<11><-1> :: p2.x<0> :: p2.x = 3;<0> :: return (p1.x - 1);<-1>} :: top{}
  239. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10),
  240. env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  241. }
  242. --- handle value ptr<11> with p2.x<1>(ptr<11>,) --->
  243. {
  244. stack: main{ptr<9><-1> :: p2.x = 3;<0> :: return (p1.x - 1);<-1>} :: top{}
  245. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10),
  246. env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  247. }
  248. --- handle value ptr<9> with p2.x = 3;<1>(ptr<9>,) --->
  249. {
  250. stack: main{3<-1> :: p2.x = 3;<1>(ptr<9>,) :: return (p1.x - 1);<-1>} :: top{}
  251. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10),
  252. env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  253. }
  254. --- step exp 3 --->
  255. {
  256. stack: main{3<-1> :: p2.x = 3;<1>(ptr<9>,) :: return (p1.x - 1);<-1>} :: top{}
  257. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10),
  258. env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  259. }
  260. --- handle value 3 with p2.x = 3;<2>(ptr<9>,3,) --->
  261. {
  262. stack: main{return (p1.x - 1);<-1>} :: top{}
  263. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10),
  264. env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  265. }
  266. --- step stmt return (p1.x - 1); --->
  267. {
  268. stack: main{(p1.x - 1)<-1> :: return (p1.x - 1);<0>} :: top{}
  269. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10),
  270. env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  271. }
  272. --- step exp (p1.x - 1) --->
  273. {
  274. stack: main{p1.x<-1> :: (p1.x - 1)<0> :: return (p1.x - 1);<0>} :: top{}
  275. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10),
  276. env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  277. }
  278. --- step exp p1.x --->
  279. {
  280. stack: main{p1<-1> :: p1.x<0> :: (p1.x - 1)<0> :: return (p1.x - 1);<0>} :: top{}
  281. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10),
  282. env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  283. }
  284. --- step lvalue p1 --->
  285. {
  286. stack: main{ptr<8><-1> :: p1.x<0> :: (p1.x - 1)<0> :: return (p1.x - 1);<0>} :: top{}
  287. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10),
  288. env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  289. }
  290. --- handle value ptr<8> with p1.x<1>(ptr<8>,) --->
  291. {
  292. stack: main{1<-1> :: (p1.x - 1)<0> :: return (p1.x - 1);<0>} :: top{}
  293. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10),
  294. env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  295. }
  296. --- handle value 1 with (p1.x - 1)<1>(1,) --->
  297. {
  298. stack: main{1<-1> :: (p1.x - 1)<1>(1,) :: return (p1.x - 1);<0>} :: top{}
  299. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10),
  300. env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  301. }
  302. --- step exp 1 --->
  303. {
  304. stack: main{1<-1> :: (p1.x - 1)<1>(1,) :: return (p1.x - 1);<0>} :: top{}
  305. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10),
  306. env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  307. }
  308. --- handle value 1 with (p1.x - 1)<2>(1,1,) --->
  309. {
  310. stack: main{0<-1> :: return (p1.x - 1);<0>} :: top{}
  311. heap: struct Point, fun<main>, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10),
  312. env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun<main>, Point: struct Point,
  313. }
  314. --- handle value 0 with return (p1.x - 1);<1>(0,) --->
  315. {
  316. stack: top{0<-1>}
  317. heap: struct Point, fun<main>, 1, 2, 1, 2, !!1, !!2, !!Point!!(x = !!1@6, y = !!2@7), !!3, !!2, !!Point!!(x = !!3@9, y = !!2@10),
  318. env: main: fun<main>, Point: struct Point,
  319. }
  320. result: 0