Last active
April 28, 2016 18:43
-
-
Save mhyee/562e21c31554f373277328ee12e6e857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AST: | |
def f: Int = | |
match () with { _ => 11 } | |
SAST: | |
def f: Int = | |
let matchVar1 = () in | |
let case2 = λ() -> MatchError in | |
let case3 = λ() -> 11 in | |
Apply(case3) | |
LIFTED: | |
def f$5(): Int = 11 | |
def f$4(): Int = MatchError | |
def f(): Int = | |
let matchVar1 = #U in | |
let case2 = MkClosureRef(f$4, free()) in | |
let case3 = MkClosureRef(f$5, free()) in | |
ApplyClosure(case3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AST: | |
def f(x: Int): Int = | |
match x with { case a => 1 } | |
def g: Int = f(3) | |
SAST: | |
def f(x: Int): Int = | |
let matchVar1 = x in | |
let case2 = λ() -> MatchError in | |
let case3 = λ() -> (let a = matchVar1 in 1) in | |
Apply(case3) | |
def g: Int = Apply(f, 3) | |
LIFTED: | |
def f$5(matchVar1: Int): Int = let a = matchVar1 in 1 | |
def f$4(): Int = MatchError | |
def f(x: Int): Int = | |
let matchVar1 = x in | |
let case2 = MkClosureRef(f$4, free()) in | |
let case3 = MkClosureRef(f$5, free(matchVar1)) in | |
ApplyClosure(case3) | |
def g(): Int = ApplyRef(f, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AST: | |
def f(x: Bool): Int = | |
match x with { | |
case true => 30 | |
case false => 81 | |
} | |
def g01: Int = f(true) | |
def g02: Int = f(false) | |
SAST: | |
def f(x: Bool): Int = | |
let matchVar1 = x in | |
let case2 = λ() -> MatchError in | |
let case4 = λ() -> if (false == matchVar1) 81 else Apply(case2) in | |
let case3 = λ() -> if (true == matchVar1) 30 else Apply(case4) in | |
Apply(case3) | |
def g01: Int = Apply(f, true) | |
def g02: Int = Apply(f, false) | |
LIFTED: | |
def f$7(matchVar1: Bool, case4: ()->Int) = | |
if (#t == matchVar1) 30 | |
else ApplyClosure(case4) | |
def f$6(matchVar1: Bool, case2: ()->Int) = | |
if (#f == matchVar1) 81 | |
else ApplyClosure(case2) | |
def f$5(): Int = MatchError | |
def f(x: Bool): Int = | |
let matchVar1 = x in | |
let case2 = MkClosureRef(f$5, free()) in | |
let case4 = MkClosureRef(f$6, free(matchVar1, case2)) in | |
let case3 = MkClosureRef(f$7, free(matchVar1, case4)) in | |
ApplyClosure(case3) | |
def g01(): Int = ApplyRef(f, #t) | |
def g02(): Int = ApplyRef(f, #f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AST: | |
def f(x: Int, y: Int): Int = match x with { | |
case 0 => y | |
case _ => match y with { | |
case 0 => x | |
case _ => 0 | |
} | |
} | |
def g01: Int = f(0, 0) | |
def g02: Int = f(1, 0) | |
def g03: Int = f(0, 2) | |
def g04: Int = f(3, 4) | |
SAST: | |
def f(x: Int, y: Int): Int = | |
let matchVar1 = x in | |
let case2 = λ() -> MatchError in | |
let case4 = λ() -> let matchVar5 = y in | |
let case2 = λ() -> MatchError in | |
let case8 = λ() -> 0 in | |
let case7 = λ() -> if (0 == matchVar5) x else Apply(case8) in | |
Apply(case7) in | |
let case3 = λ() -> if (0 == matchVar1) y else Apply(case4) in | |
Apply(case3) | |
def g01: Int = Apply(f, 0, 0) | |
def g02: Int = Apply(f, 1, 0) | |
def g03: Int = Apply(f, 0, 2) | |
def g04: Int = Apply(f, 3, 4) | |
LIFTED: | |
def f$14(matchVar1: Int, y: Int, case4: ()->Int): Int = | |
if (0 == matchVar1) y | |
else ApplyClosure(case4) | |
def f$13(y: Int, x: Int): Int = | |
let matchVar5 = y in | |
let case6 = MkClosureRef(f$10, free()) in | |
let case8 = MkClosureRef(f$11, free()) in | |
let case7 = MkClosureRef(f$12, free(matchVar5, x, case8)) in | |
ApplyClosure(case7) | |
def f$12(matchVar5: Int, x: Int, case8: ()->Int): Int = | |
if (0 == matchVar5) x | |
else ApplyClosure(case8) | |
def f$11(): Int = 0 | |
def f$10(): Int = MatchError | |
def f$9(): Int = MatchError | |
def f(x: Int, y: Int): Int = | |
let matchVar1 = x in | |
let case2 = MkClosureRef(f$9, free()) in | |
let case4 = MkClosureRef(f$13, free(y, x)) in | |
let case3 = MkClosureRef(f$14, free(matchVar1, y, case4)) in | |
ApplyClosure(case3) | |
def g01(): Int = ApplyRef(f, 0, 0) | |
def g02(): Int = ApplyRef(f, 1, 0) | |
def g03(): Int = ApplyRef(f, 0, 2) | |
def g04(): Int = ApplyRef(f, 3, 4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AST: | |
def f(x: (Int) -> Int, y: Int): Int = x(y) | |
def g(x: Int): Int = x + 1 | |
def h: Int = f(g, 5) | |
SAST: | |
def f(x: (Int) -> Int, y: Int): Int = Apply(x, y) | |
def g(x: Int): Int = x + 1 | |
def h: Int = Apply(f, g, 5) | |
LIFTED: | |
def f(x: (Int)->Int, y: Int): Int = ApplyClosure(x, y) | |
def g(x: Int): Int = x + 1 | |
def h(): Int = ApplyRef(f, MkClosureRef(g, free()), 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment