13699d187869d480a856deeb58a9b72a42414510 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. compilation_unit {
  2. package_statement {
  3. package_name: "ExplorerTest"
  4. }
  5. is_api: true
  6. declarations {
  7. function {
  8. name {
  9. name: "Foo"
  10. }
  11. param_pattern {
  12. fields {
  13. binding_pattern {
  14. name: "a"
  15. type {
  16. expression_pattern {
  17. expression {
  18. int_type_literal {
  19. }
  20. }
  21. }
  22. }
  23. }
  24. }
  25. fields {
  26. binding_pattern {
  27. name: "b"
  28. type {
  29. expression_pattern {
  30. expression {
  31. int_type_literal {
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
  39. return_term {
  40. kind: Auto
  41. }
  42. body {
  43. statements {
  44. variable_definition {
  45. pattern {
  46. binding_pattern {
  47. name: "ret"
  48. type {
  49. expression_pattern {
  50. expression {
  51. int_type_literal {
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. init {
  59. operator {
  60. op: Add
  61. arguments {
  62. identifier {
  63. name: "a"
  64. }
  65. }
  66. arguments {
  67. identifier {
  68. name: "b"
  69. }
  70. }
  71. }
  72. }
  73. is_returned: true
  74. }
  75. }
  76. statements {
  77. if_statement {
  78. condition {
  79. operator {
  80. op: Eq
  81. arguments {
  82. identifier {
  83. name: "b"
  84. }
  85. }
  86. arguments {
  87. identifier {
  88. name: "a"
  89. }
  90. }
  91. }
  92. }
  93. then_block {
  94. statements {
  95. assign {
  96. lhs {
  97. identifier {
  98. name: "ret"
  99. }
  100. }
  101. rhs {
  102. operator {
  103. op: Sub
  104. arguments {
  105. identifier {
  106. name: "b"
  107. }
  108. }
  109. arguments {
  110. identifier {
  111. name: "a"
  112. }
  113. }
  114. }
  115. }
  116. op: Plain
  117. }
  118. }
  119. statements {
  120. return_var_statement {
  121. }
  122. }
  123. }
  124. }
  125. }
  126. statements {
  127. assign {
  128. lhs {
  129. identifier {
  130. name: "ret"
  131. }
  132. }
  133. rhs {
  134. operator {
  135. op: Sub
  136. arguments {
  137. identifier {
  138. name: "a"
  139. }
  140. }
  141. arguments {
  142. identifier {
  143. name: "b"
  144. }
  145. }
  146. }
  147. }
  148. op: Plain
  149. }
  150. }
  151. statements {
  152. return_var_statement {
  153. }
  154. }
  155. }
  156. }
  157. }
  158. declarations {
  159. function {
  160. name {
  161. name: "Main"
  162. }
  163. param_pattern {
  164. }
  165. return_term {
  166. kind: Expression
  167. type {
  168. int_type_literal {
  169. }
  170. }
  171. }
  172. body {
  173. statements {
  174. return_expression_statement {
  175. expression {
  176. call {
  177. function {
  178. identifier {
  179. name: "Foo"
  180. }
  181. }
  182. argument {
  183. tuple_literal {
  184. fields {
  185. int_literal {
  186. value: 1
  187. }
  188. }
  189. fields {
  190. int_literal {
  191. value: 2
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201. }
  202. }
  203. }