48caa4aa710abcf73fe7b82ab8fd9fbd10f52a7d 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. compilation_unit {
  2. package_statement {
  3. package_name: "Foo"
  4. }
  5. is_api: true
  6. declarations {
  7. choice {
  8. name {
  9. name: "Choice"
  10. }
  11. alternatives {
  12. name: "Alternative"
  13. signature {
  14. }
  15. }
  16. }
  17. }
  18. declarations {
  19. class_declaration {
  20. name {
  21. name: "Class"
  22. }
  23. members {
  24. function {
  25. name {
  26. name: "F"
  27. }
  28. param_pattern {
  29. fields {
  30. binding_pattern {
  31. name: "n"
  32. type {
  33. expression_pattern {
  34. expression {
  35. int_type_literal {
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }
  43. return_term {
  44. kind: Expression
  45. type {
  46. int_type_literal {
  47. }
  48. }
  49. }
  50. body {
  51. statements {
  52. return_expression_statement {
  53. expression {
  54. operator {
  55. op: Add
  56. arguments {
  57. identifier {
  58. name: "n"
  59. }
  60. }
  61. arguments {
  62. int_literal {
  63. value: 1
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74. }
  75. declarations {
  76. interface {
  77. name {
  78. name: "Interface"
  79. }
  80. members {
  81. function {
  82. name {
  83. name: "G"
  84. }
  85. self_pattern {
  86. binding_pattern {
  87. name: "self"
  88. type {
  89. expression_pattern {
  90. expression {
  91. identifier {
  92. name: "Self"
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. param_pattern {
  100. }
  101. return_term {
  102. kind: Expression
  103. type {
  104. identifier {
  105. name: "Self"
  106. }
  107. }
  108. }
  109. }
  110. }
  111. }
  112. }
  113. declarations {
  114. interface {
  115. name {
  116. name: "AnotherInterface"
  117. }
  118. }
  119. }
  120. declarations {
  121. impl {
  122. kind: InternalImpl
  123. impl_type {
  124. int_type_literal {
  125. }
  126. }
  127. interface {
  128. identifier {
  129. name: "Interface"
  130. }
  131. }
  132. members {
  133. function {
  134. name {
  135. name: "G"
  136. }
  137. self_pattern {
  138. binding_pattern {
  139. name: "self"
  140. type {
  141. expression_pattern {
  142. expression {
  143. int_type_literal {
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. param_pattern {
  151. }
  152. return_term {
  153. kind: Expression
  154. type {
  155. int_type_literal {
  156. }
  157. }
  158. }
  159. body {
  160. statements {
  161. return_expression_statement {
  162. expression {
  163. operator {
  164. op: Add
  165. arguments {
  166. identifier {
  167. name: "self"
  168. }
  169. }
  170. arguments {
  171. int_literal {
  172. value: 1
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. declarations {
  185. impl {
  186. kind: InternalImpl
  187. impl_type {
  188. int_type_literal {
  189. }
  190. }
  191. interface {
  192. identifier {
  193. name: "AnotherInterface"
  194. }
  195. }
  196. }
  197. }
  198. declarations {
  199. function {
  200. name {
  201. name: "GetStruct"
  202. }
  203. param_pattern {
  204. }
  205. return_term {
  206. kind: Expression
  207. type {
  208. type_type_literal {
  209. }
  210. }
  211. }
  212. body {
  213. statements {
  214. return_expression_statement {
  215. expression {
  216. struct_type_literal {
  217. fields {
  218. name: "n"
  219. expression {
  220. int_type_literal {
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }
  228. }
  229. }
  230. }
  231. declarations {
  232. function {
  233. name {
  234. name: "GetChoice"
  235. }
  236. param_pattern {
  237. }
  238. return_term {
  239. kind: Expression
  240. type {
  241. type_type_literal {
  242. }
  243. }
  244. }
  245. body {
  246. statements {
  247. return_expression_statement {
  248. expression {
  249. identifier {
  250. name: "Choice"
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. declarations {
  259. function {
  260. name {
  261. name: "GetClass"
  262. }
  263. param_pattern {
  264. }
  265. return_term {
  266. kind: Expression
  267. type {
  268. type_type_literal {
  269. }
  270. }
  271. }
  272. body {
  273. statements {
  274. return_expression_statement {
  275. expression {
  276. identifier {
  277. name: "Class"
  278. }
  279. }
  280. }
  281. }
  282. }
  283. }
  284. }
  285. declarations {
  286. function {
  287. name {
  288. name: "GetInterface"
  289. }
  290. param_pattern {
  291. }
  292. return_term {
  293. kind: Expression
  294. type {
  295. type_type_literal {
  296. }
  297. }
  298. }
  299. body {
  300. statements {
  301. return_expression_statement {
  302. expression {
  303. identifier {
  304. name: "Interface"
  305. }
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. declarations {
  313. function {
  314. name {
  315. name: "GetConstraint"
  316. }
  317. param_pattern {
  318. }
  319. return_term {
  320. kind: Expression
  321. type {
  322. type_type_literal {
  323. }
  324. }
  325. }
  326. body {
  327. statements {
  328. return_expression_statement {
  329. expression {
  330. operator {
  331. op: BitwiseAnd
  332. arguments {
  333. identifier {
  334. name: "Interface"
  335. }
  336. }
  337. arguments {
  338. identifier {
  339. name: "AnotherInterface"
  340. }
  341. }
  342. }
  343. }
  344. }
  345. }
  346. }
  347. }
  348. }
  349. declarations {
  350. function {
  351. name {
  352. name: "TestStruct"
  353. }
  354. param_pattern {
  355. }
  356. return_term {
  357. kind: Omitted
  358. }
  359. body {
  360. statements {
  361. variable_definition {
  362. pattern {
  363. binding_pattern {
  364. name: "s"
  365. type {
  366. expression_pattern {
  367. expression {
  368. call {
  369. function {
  370. identifier {
  371. name: "GetStruct"
  372. }
  373. }
  374. argument {
  375. tuple_literal {
  376. }
  377. }
  378. }
  379. }
  380. }
  381. }
  382. }
  383. }
  384. init {
  385. struct_literal {
  386. fields {
  387. name: "n"
  388. expression {
  389. int_literal {
  390. value: 1
  391. }
  392. }
  393. }
  394. }
  395. }
  396. is_returned: false
  397. }
  398. }
  399. statements {
  400. if_statement {
  401. condition {
  402. operator {
  403. op: Eq
  404. arguments {
  405. compound_member_access {
  406. object {
  407. identifier {
  408. name: "s"
  409. }
  410. }
  411. path {
  412. simple_member_access {
  413. field: "n"
  414. object {
  415. call {
  416. function {
  417. identifier {
  418. name: "GetStruct"
  419. }
  420. }
  421. argument {
  422. tuple_literal {
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429. }
  430. }
  431. arguments {
  432. int_literal {
  433. value: 1
  434. }
  435. }
  436. }
  437. }
  438. then_block {
  439. statements {
  440. expression_statement {
  441. expression {
  442. call {
  443. function {
  444. identifier {
  445. name: "Print"
  446. }
  447. }
  448. argument {
  449. tuple_literal {
  450. fields {
  451. string_literal {
  452. value: "Struct OK"
  453. }
  454. }
  455. }
  456. }
  457. }
  458. }
  459. }
  460. }
  461. }
  462. }
  463. }
  464. }
  465. }
  466. }
  467. declarations {
  468. function {
  469. name {
  470. name: "TestChoice"
  471. }
  472. param_pattern {
  473. }
  474. return_term {
  475. kind: Omitted
  476. }
  477. body {
  478. statements {
  479. variable_definition {
  480. pattern {
  481. binding_pattern {
  482. name: "c"
  483. type {
  484. expression_pattern {
  485. expression {
  486. call {
  487. function {
  488. identifier {
  489. name: "GetChoice"
  490. }
  491. }
  492. argument {
  493. tuple_literal {
  494. }
  495. }
  496. }
  497. }
  498. }
  499. }
  500. }
  501. }
  502. init {
  503. call {
  504. function {
  505. simple_member_access {
  506. field: "Alternative"
  507. object {
  508. call {
  509. function {
  510. identifier {
  511. name: "GetChoice"
  512. }
  513. }
  514. argument {
  515. tuple_literal {
  516. }
  517. }
  518. }
  519. }
  520. }
  521. }
  522. argument {
  523. tuple_literal {
  524. }
  525. }
  526. }
  527. }
  528. is_returned: false
  529. }
  530. }
  531. statements {
  532. match {
  533. expression {
  534. identifier {
  535. name: "c"
  536. }
  537. }
  538. clauses {
  539. pattern {
  540. expression_pattern {
  541. expression {
  542. call {
  543. function {
  544. simple_member_access {
  545. field: "Alternative"
  546. object {
  547. call {
  548. function {
  549. identifier {
  550. name: "GetChoice"
  551. }
  552. }
  553. argument {
  554. tuple_literal {
  555. }
  556. }
  557. }
  558. }
  559. }
  560. }
  561. argument {
  562. tuple_literal {
  563. }
  564. }
  565. }
  566. }
  567. }
  568. }
  569. statement {
  570. block {
  571. statements {
  572. expression_statement {
  573. expression {
  574. call {
  575. function {
  576. identifier {
  577. name: "Print"
  578. }
  579. }
  580. argument {
  581. tuple_literal {
  582. fields {
  583. string_literal {
  584. value: "Choice OK"
  585. }
  586. }
  587. }
  588. }
  589. }
  590. }
  591. }
  592. }
  593. }
  594. }
  595. }
  596. }
  597. }
  598. }
  599. }
  600. }
  601. declarations {
  602. function {
  603. name {
  604. name: "TestClass"
  605. }
  606. param_pattern {
  607. }
  608. return_term {
  609. kind: Omitted
  610. }
  611. body {
  612. statements {
  613. if_statement {
  614. condition {
  615. operator {
  616. op: Eq
  617. arguments {
  618. call {
  619. function {
  620. simple_member_access {
  621. field: "F"
  622. object {
  623. call {
  624. function {
  625. identifier {
  626. name: "GetClass"
  627. }
  628. }
  629. argument {
  630. tuple_literal {
  631. }
  632. }
  633. }
  634. }
  635. }
  636. }
  637. argument {
  638. tuple_literal {
  639. fields {
  640. int_literal {
  641. value: 1
  642. }
  643. }
  644. }
  645. }
  646. }
  647. }
  648. arguments {
  649. int_literal {
  650. value: 2
  651. }
  652. }
  653. }
  654. }
  655. then_block {
  656. statements {
  657. expression_statement {
  658. expression {
  659. call {
  660. function {
  661. identifier {
  662. name: "Print"
  663. }
  664. }
  665. argument {
  666. tuple_literal {
  667. fields {
  668. string_literal {
  669. value: "Class OK"
  670. }
  671. }
  672. }
  673. }
  674. }
  675. }
  676. }
  677. }
  678. }
  679. }
  680. }
  681. }
  682. }
  683. }
  684. declarations {
  685. function {
  686. name {
  687. name: "TestInterface"
  688. }
  689. param_pattern {
  690. }
  691. return_term {
  692. kind: Omitted
  693. }
  694. body {
  695. statements {
  696. variable_definition {
  697. pattern {
  698. binding_pattern {
  699. name: "n"
  700. type {
  701. expression_pattern {
  702. expression {
  703. int_type_literal {
  704. }
  705. }
  706. }
  707. }
  708. }
  709. }
  710. init {
  711. int_literal {
  712. value: 1
  713. }
  714. }
  715. is_returned: false
  716. }
  717. }
  718. statements {
  719. if_statement {
  720. condition {
  721. operator {
  722. op: Eq
  723. arguments {
  724. call {
  725. function {
  726. compound_member_access {
  727. object {
  728. identifier {
  729. name: "n"
  730. }
  731. }
  732. path {
  733. simple_member_access {
  734. field: "G"
  735. object {
  736. call {
  737. function {
  738. identifier {
  739. name: "GetInterface"
  740. }
  741. }
  742. argument {
  743. tuple_literal {
  744. }
  745. }
  746. }
  747. }
  748. }
  749. }
  750. }
  751. }
  752. argument {
  753. tuple_literal {
  754. }
  755. }
  756. }
  757. }
  758. arguments {
  759. int_literal {
  760. value: 2
  761. }
  762. }
  763. }
  764. }
  765. then_block {
  766. statements {
  767. expression_statement {
  768. expression {
  769. call {
  770. function {
  771. identifier {
  772. name: "Print"
  773. }
  774. }
  775. argument {
  776. tuple_literal {
  777. fields {
  778. string_literal {
  779. value: "Interface OK"
  780. }
  781. }
  782. }
  783. }
  784. }
  785. }
  786. }
  787. }
  788. }
  789. }
  790. }
  791. }
  792. }
  793. }
  794. declarations {
  795. function {
  796. name {
  797. name: "TestConstraint"
  798. }
  799. param_pattern {
  800. }
  801. return_term {
  802. kind: Omitted
  803. }
  804. body {
  805. statements {
  806. variable_definition {
  807. pattern {
  808. binding_pattern {
  809. name: "n"
  810. type {
  811. expression_pattern {
  812. expression {
  813. int_type_literal {
  814. }
  815. }
  816. }
  817. }
  818. }
  819. }
  820. init {
  821. int_literal {
  822. value: 1
  823. }
  824. }
  825. is_returned: false
  826. }
  827. }
  828. statements {
  829. if_statement {
  830. condition {
  831. operator {
  832. op: Eq
  833. arguments {
  834. call {
  835. function {
  836. compound_member_access {
  837. object {
  838. identifier {
  839. name: "n"
  840. }
  841. }
  842. path {
  843. simple_member_access {
  844. field: "G"
  845. object {
  846. call {
  847. function {
  848. identifier {
  849. name: "GetConstraint"
  850. }
  851. }
  852. argument {
  853. tuple_literal {
  854. }
  855. }
  856. }
  857. }
  858. }
  859. }
  860. }
  861. }
  862. argument {
  863. tuple_literal {
  864. }
  865. }
  866. }
  867. }
  868. arguments {
  869. int_literal {
  870. value: 2
  871. }
  872. }
  873. }
  874. }
  875. then_block {
  876. statements {
  877. expression_statement {
  878. expression {
  879. call {
  880. function {
  881. identifier {
  882. name: "Print"
  883. }
  884. }
  885. argument {
  886. tuple_literal {
  887. fields {
  888. string_literal {
  889. value: "Constraint OK"
  890. }
  891. }
  892. }
  893. }
  894. }
  895. }
  896. }
  897. }
  898. }
  899. }
  900. }
  901. }
  902. }
  903. }
  904. declarations {
  905. function {
  906. name {
  907. name: "Main"
  908. }
  909. param_pattern {
  910. }
  911. return_term {
  912. kind: Expression
  913. type {
  914. int_type_literal {
  915. }
  916. }
  917. }
  918. body {
  919. statements {
  920. expression_statement {
  921. expression {
  922. call {
  923. function {
  924. identifier {
  925. name: "TestStruct"
  926. }
  927. }
  928. argument {
  929. tuple_literal {
  930. }
  931. }
  932. }
  933. }
  934. }
  935. }
  936. statements {
  937. expression_statement {
  938. expression {
  939. call {
  940. function {
  941. identifier {
  942. name: "TestChoice"
  943. }
  944. }
  945. argument {
  946. tuple_literal {
  947. }
  948. }
  949. }
  950. }
  951. }
  952. }
  953. statements {
  954. expression_statement {
  955. expression {
  956. call {
  957. function {
  958. identifier {
  959. name: "TestClass"
  960. }
  961. }
  962. argument {
  963. tuple_literal {
  964. }
  965. }
  966. }
  967. }
  968. }
  969. }
  970. statements {
  971. expression_statement {
  972. expression {
  973. call {
  974. function {
  975. identifier {
  976. name: "TestInterface"
  977. }
  978. }
  979. argument {
  980. tuple_literal {
  981. }
  982. }
  983. }
  984. }
  985. }
  986. }
  987. statements {
  988. expression_statement {
  989. expression {
  990. call {
  991. function {
  992. identifier {
  993. name: "TestConstraint"
  994. }
  995. }
  996. argument {
  997. tuple_literal {
  998. }
  999. }
  1000. }
  1001. }
  1002. }
  1003. }
  1004. statements {
  1005. return_expression_statement {
  1006. expression {
  1007. int_literal {
  1008. value: 0
  1009. }
  1010. }
  1011. }
  1012. }
  1013. }
  1014. }
  1015. }
  1016. }