|
| 1 | +:NewDefs |
| 2 | +:ParseOnly |
| 3 | +:UseIR |
| 4 | +:NoTailRec |
| 5 | + |
| 6 | +:prelude |
| 7 | +module True |
| 8 | +module False |
| 9 | +module Callable { |
| 10 | + fun apply0() = 0 |
| 11 | + fun apply1(x0) = 0 |
| 12 | + fun apply2(x0,x1) = 0 |
| 13 | + fun apply3(x0,x1,x2) = 0 |
| 14 | + fun apply4(x0,x1,x2,x3) = 0 |
| 15 | + fun apply5(x0,x1,x2,x3,x4) = 0 |
| 16 | +} |
| 17 | +module List[A, B] |
| 18 | +class Cons[A, B](h: A, t: Cons[A, B]) extends List[A, B] |
| 19 | +module Nil[A, B] extends List[A, B] |
| 20 | +module Option[A] |
| 21 | +class Some[A](x: A) extends Option[A] |
| 22 | +module None[A] extends Option[A] |
| 23 | +class Pair[A, B](x: A, y: B) |
| 24 | +class Tuple2[A, B](x: A, y: B) |
| 25 | +class Tuple3[A, B, C](x: A, y: B, z: C) |
| 26 | +module Nat |
| 27 | +class S(s: Nat) extends Nat |
| 28 | +module O extends Nat |
| 29 | +class HiddenTheseEntities(_0: HiddenTheseEntities, _1: True, _2: False, _3: Callable, _4: List, _5: Cons, _6: Nil, _7: Option, _8: Some, _9: None, _10: Pair, _11: Tuple2, _12: Tuple3, _13: Nat, _14: S, _15: O) |
| 30 | +//│ |#module| |True|↵|#module| |False|↵|#module| |Callable| |{|→|#fun| |apply0|(||)| |#=| |0|↵|#fun| |apply1|(|x0|)| |#=| |0|↵|#fun| |apply2|(|x0|,|x1|)| |#=| |0|↵|#fun| |apply3|(|x0|,|x1|,|x2|)| |#=| |0|↵|#fun| |apply4|(|x0|,|x1|,|x2|,|x3|)| |#=| |0|↵|#fun| |apply5|(|x0|,|x1|,|x2|,|x3|,|x4|)| |#=| |0|←|↵|}|↵|#module| |List|[|A|,| |B|]|↵|#class| |Cons|[|A|,| |B|]|(|h|#:| |A|,| |t|#:| |Cons|[|A|,| |B|]|)| |#extends| |List|[|A|,| |B|]|↵|#module| |Nil|[|A|,| |B|]| |#extends| |List|[|A|,| |B|]|↵|#module| |Option|[|A|]|↵|#class| |Some|[|A|]|(|x|#:| |A|)| |#extends| |Option|[|A|]|↵|#module| |None|[|A|]| |#extends| |Option|[|A|]|↵|#class| |Pair|[|A|,| |B|]|(|x|#:| |A|,| |y|#:| |B|)|↵|#class| |Tuple2|[|A|,| |B|]|(|x|#:| |A|,| |y|#:| |B|)|↵|#class| |Tuple3|[|A|,| |B|,| |C|]|(|x|#:| |A|,| |y|#:| |B|,| |z|#:| |C|)|↵|#module| |Nat|↵|#class| |S|(|s|#:| |Nat|)| |#extends| |Nat|↵|#module| |O| |#extends| |Nat|↵|#class| |HiddenTheseEntities|(|_0|#:| |HiddenTheseEntities|,| |_1|#:| |True|,| |_2|#:| |False|,| |_3|#:| |Callable|,| |_4|#:| |List|,| |_5|#:| |Cons|,| |_6|#:| |Nil|,| |_7|#:| |Option|,| |_8|#:| |Some|,| |_9|#:| |None|,| |_10|#:| |Pair|,| |_11|#:| |Tuple2|,| |_12|#:| |Tuple3|,| |_13|#:| |Nat|,| |_14|#:| |S|,| |_15|#:| |O|)| |
| 31 | +//│ Parsed: {module True {}; module False {}; module Callable {fun apply0 = () => 0; fun apply1 = (x0,) => 0; fun apply2 = (x0, x1,) => 0; fun apply3 = (x0, x1, x2,) => 0; fun apply4 = (x0, x1, x2, x3,) => 0; fun apply5 = (x0, x1, x2, x3, x4,) => 0}; module List‹A, B› {}; class Cons‹A, B›(h: A, t: Cons‹A, B›,): List‹A, B› {}; module Nil‹A, B›: List‹A, B› {}; module Option‹A› {}; class Some‹A›(x: A,): Option‹A› {}; module None‹A›: Option‹A› {}; class Pair‹A, B›(x: A, y: B,) {}; class Tuple2‹A, B›(x: A, y: B,) {}; class Tuple3‹A, B, C›(x: A, y: B, z: C,) {}; module Nat {}; class S(s: Nat,): Nat {}; module O: Nat {}; class HiddenTheseEntities(_0: HiddenTheseEntities, _1: True, _2: False, _3: Callable, _4: List, _5: Cons, _6: Nil, _7: Option, _8: Some, _9: None, _10: Pair, _11: Tuple2, _12: Tuple3, _13: Nat, _14: S, _15: O,) {}} |
| 32 | +//│ |
| 33 | +//│ Preluded. |
| 34 | +//│ |
| 35 | + |
| 36 | +:genCpp |
| 37 | +:runCpp |
| 38 | +:interpIR |
| 39 | +fun main(x) = |
| 40 | + class InnerClass(y) extends Callable { |
| 41 | + fun apply1(z) = x + y + z |
| 42 | + } |
| 43 | + let ic = InnerClass(1) |
| 44 | + ic(2) + ic(3) |
| 45 | +main(4) |
| 46 | +//│ |#fun| |main|(|x|)| |#=|→|#class| |InnerClass|(|y|)| |#extends| |Callable| |{|→|#fun| |apply1|(|z|)| |#=| |x| |+| |y| |+| |z|←|↵|}|↵|#let| |ic| |#=| |InnerClass|(|1|)|↵|ic|(|2|)| |+| |ic|(|3|)|←|↵|main|(|4|)| |
| 47 | +//│ Parsed: {fun main = (x,) => {class InnerClass(y,): Callable {fun apply1 = (z,) => +(+(x, y,), z,)}; let ic = InnerClass(1,); +(ic(2,), ic(3,),)}; main(4,)} |
| 48 | +//│ |
| 49 | +//│ |
| 50 | +//│ IR: |
| 51 | +//│ Program: |
| 52 | +//│ class InnerClass(y,x) extends Callable { |
| 53 | +//│ def apply1(z$0) = |
| 54 | +//│ let x$6 = +(x,y) in -- #45 |
| 55 | +//│ let x$7 = +(x$6,z$0) in -- #44 |
| 56 | +//│ x$7 -- #43 |
| 57 | +//│ } |
| 58 | +//│ def main(x$1) = |
| 59 | +//│ let x$2 = InnerClass(1,x$1) in -- #26 |
| 60 | +//│ let x$3 = Callable.apply1(x$2,2) in -- #25 |
| 61 | +//│ let x$4 = Callable.apply1(x$2,3) in -- #24 |
| 62 | +//│ let x$5 = +(x$3,x$4) in -- #23 |
| 63 | +//│ x$5 -- #22 |
| 64 | +//│ let* (x$0) = main(4) in -- #4 |
| 65 | +//│ x$0 -- #3 |
| 66 | +//│ |
| 67 | +//│ Interpreted: |
| 68 | +//│ 15 |
| 69 | +//│ |
| 70 | +//│ |
| 71 | +//│ Execution succeeded: |
| 72 | +//│ 15 |
| 73 | +//│ |
| 74 | + |
| 75 | +:genCpp |
| 76 | +:runCpp |
| 77 | +:interpIR |
| 78 | +fun main(x) = |
| 79 | + class InnerClass(y) extends Callable { |
| 80 | + fun apply1(z) = |
| 81 | + module InnerClass2 extends Callable { |
| 82 | + fun apply1(w) = w + z |
| 83 | + } |
| 84 | + InnerClass2 |
| 85 | + } |
| 86 | + let ic = InnerClass(1) |
| 87 | + ic(2)(2) + ic(3)(1) |
| 88 | +main(4) |
| 89 | +//│ |#fun| |main|(|x|)| |#=|→|#class| |InnerClass|(|y|)| |#extends| |Callable| |{|→|#fun| |apply1|(|z|)| |#=|→|#module| |InnerClass2| |#extends| |Callable| |{|→|#fun| |apply1|(|w|)| |#=| |w| |+| |z|←|↵|}|↵|InnerClass2|←|←|↵|}|↵|#let| |ic| |#=| |InnerClass|(|1|)|↵|ic|(|2|)|(|2|)| |+| |ic|(|3|)|(|1|)|←|↵|main|(|4|)| |
| 90 | +//│ Parsed: {fun main = (x,) => {class InnerClass(y,): Callable {fun apply1 = (z,) => {module InnerClass2: Callable {fun apply1 = (w,) => +(w, z,)}; InnerClass2}}; let ic = InnerClass(1,); +(ic(2,)(2,), ic(3,)(1,),)}; main(4,)} |
| 91 | +//│ |
| 92 | +//│ |
| 93 | +//│ IR: |
| 94 | +//│ Program: |
| 95 | +//│ class InnerClass(y) extends Callable { |
| 96 | +//│ def apply1(z$0) = |
| 97 | +//│ let x$8 = InnerClass2(z$0) in -- #44 |
| 98 | +//│ x$8 -- #43 |
| 99 | +//│ } |
| 100 | +//│ class InnerClass2(z) extends Callable { |
| 101 | +//│ def apply1(w$0) = |
| 102 | +//│ let x$9 = +(w$0,z) in -- #51 |
| 103 | +//│ x$9 -- #50 |
| 104 | +//│ } |
| 105 | +//│ def main(x$1) = |
| 106 | +//│ let x$2 = InnerClass(1) in -- #36 |
| 107 | +//│ let x$3 = Callable.apply1(x$2,2) in -- #35 |
| 108 | +//│ let x$4 = Callable.apply1(x$3,2) in -- #34 |
| 109 | +//│ let x$5 = Callable.apply1(x$2,3) in -- #33 |
| 110 | +//│ let x$6 = Callable.apply1(x$5,1) in -- #32 |
| 111 | +//│ let x$7 = +(x$4,x$6) in -- #31 |
| 112 | +//│ x$7 -- #30 |
| 113 | +//│ let* (x$0) = main(4) in -- #4 |
| 114 | +//│ x$0 -- #3 |
| 115 | +//│ |
| 116 | +//│ Interpreted: |
| 117 | +//│ 8 |
| 118 | +//│ |
| 119 | +//│ |
| 120 | +//│ Execution succeeded: |
| 121 | +//│ 8 |
| 122 | +//│ |
| 123 | + |
| 124 | +:genCpp |
| 125 | +:runCpp |
| 126 | +:interpIR |
| 127 | +fun main(x) = |
| 128 | + class InnerClass(y) extends Callable { |
| 129 | + fun f(x) = y |
| 130 | + } |
| 131 | + let ic = InnerClass(1) |
| 132 | + InnerClass.f(ic, Nil) |
| 133 | +main(2) |
| 134 | +//│ |#fun| |main|(|x|)| |#=|→|#class| |InnerClass|(|y|)| |#extends| |Callable| |{|→|#fun| |f|(|x|)| |#=| |y|←|↵|}|↵|#let| |ic| |#=| |InnerClass|(|1|)|↵|InnerClass|.f|(|ic|,| |Nil|)|←|↵|main|(|2|)| |
| 135 | +//│ Parsed: {fun main = (x,) => {class InnerClass(y,): Callable {fun f = (x,) => y}; let ic = InnerClass(1,); (InnerClass).f(ic, Nil,)}; main(2,)} |
| 136 | +//│ |
| 137 | +//│ |
| 138 | +//│ IR: |
| 139 | +//│ Program: |
| 140 | +//│ class InnerClass(y) extends Callable { |
| 141 | +//│ def f(x$5) = |
| 142 | +//│ y -- #24 |
| 143 | +//│ } |
| 144 | +//│ def main(x$1) = |
| 145 | +//│ let x$2 = InnerClass(1) in -- #17 |
| 146 | +//│ let x$3 = Nil() in -- #16 |
| 147 | +//│ let x$4 = InnerClass.f(x$2,x$3) in -- #15 |
| 148 | +//│ x$4 -- #14 |
| 149 | +//│ let* (x$0) = main(2) in -- #4 |
| 150 | +//│ x$0 -- #3 |
| 151 | +//│ |
| 152 | +//│ Interpreted: |
| 153 | +//│ 1 |
| 154 | +//│ |
| 155 | +//│ |
| 156 | +//│ Execution succeeded: |
| 157 | +//│ 1 |
| 158 | +//│ |
0 commit comments