-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c13d775
commit 8448557
Showing
5 changed files
with
276 additions
and
48 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
[6nload : std/core | ||
load : std/core/types | ||
load : std/core/undiv | ||
load : std/core/order | ||
load : std/core/exn | ||
load : std/core/unsafe | ||
load : std/core/bool | ||
load : std/core/hnd | ||
load : std/core/int | ||
load : std/core/char | ||
load : std/core/string | ||
load : std/core/sslice | ||
load : std/core/vector | ||
load : std/core/list | ||
load : std/core/tuple | ||
load : std/core/maybe | ||
load : std/core/either | ||
load : std/core/show | ||
load : std/core/delayed | ||
load : std/core/debug | ||
load : std/core/console | ||
parse : .../test/cgen/match-merge.kk | ||
check : test/cgen/match-merge | ||
module test/cgen/match-merge | ||
import std/core/types = std/core/types pub = ""; | ||
import std/core/hnd = std/core/hnd pub = ""; | ||
import std/core/exn = std/core/exn pub = ""; | ||
import std/core/bool = std/core/bool pub = ""; | ||
import std/core/order = std/core/order pub = ""; | ||
import std/core/char = std/core/char pub = ""; | ||
import std/core/int = std/core/int pub = ""; | ||
import std/core/vector = std/core/vector pub = ""; | ||
import std/core/string = std/core/string pub = ""; | ||
import std/core/sslice = std/core/sslice pub = ""; | ||
import std/core/list = std/core/list pub = ""; | ||
import std/core/maybe = std/core/maybe pub = ""; | ||
import std/core/either = std/core/either pub = ""; | ||
import std/core/tuple = std/core/tuple pub = ""; | ||
import std/core/show = std/core/show pub = ""; | ||
import std/core/debug = std/core/debug pub = ""; | ||
import std/core/delayed = std/core/delayed pub = ""; | ||
import std/core/console = std/core/console pub = ""; | ||
import std/core = std/core = ""; | ||
pub fun implicit-error-fallthrough : (e : list<int>) -> <console/console,exn> () | ||
= fn<<console/console,exn>>(e: list<int>){ | ||
match (e) { | ||
(std/core/types/Cons(((@skip std/core/types/@Box((a: int)) : @Box ) as @box-x0: @Box), ((std/core/types/Cons(((@skip std/core/types/@Box((b: int)) : @Box | ||
) as @box-x1: @Box), (@case306: list<int>)) : list<int> ) as @pat@0: list<int>)) : list<int> ) | ||
-> val _ : () | ||
= (match ((std/core/types/@is-unique(e))) { | ||
(std/core/types/True() : bool ) | ||
-> val _ : () | ||
= val _ : () | ||
= (match ((std/core/types/@is-unique(@pat@0))) { | ||
(std/core/types/True() : bool ) | ||
-> val _ : () | ||
= std/core/types/Unit; | ||
std/core/types/@free(@pat@0); | ||
_ | ||
-> val _ : () | ||
= val _ : list<int> | ||
= std/core/types/@dup(@case306); | ||
val _ : int | ||
= std/core/types/@dup(b); | ||
std/core/types/Unit; | ||
val _ : () | ||
= std/core/types/@dec-ref(@pat@0); | ||
std/core/types/Unit; | ||
}); | ||
std/core/types/Unit; | ||
std/core/types/@free(e); | ||
_ | ||
-> val _ : () | ||
= val _ : list<int> | ||
= std/core/types/@dup(@case306); | ||
val _ : int | ||
= std/core/types/@dup(a); | ||
val _ : int | ||
= std/core/types/@dup(b); | ||
std/core/types/Unit; | ||
val _ : () | ||
= std/core/types/@dec-ref(e); | ||
std/core/types/Unit; | ||
}); | ||
std/core/console/printsln((std/core/int/show((match (b, @case306) { | ||
1, (std/core/types/Cons(((@skip std/core/types/@Box((c: int)) : @Box ) as @box-x2: @Box), ((std/core/types/Nil() : list<int> ) as @pat@3: list<int>)) | ||
: list<int> ) | ||
-> val _ : () | ||
= std/core/types/@drop(b); | ||
val _ : () | ||
= (match ((std/core/types/@is-unique(@case306))) { | ||
(std/core/types/True() : bool ) | ||
-> val _ : () | ||
= std/core/types/Unit; | ||
std/core/types/@free(@case306); | ||
_ | ||
-> val _ : () | ||
= val _ : int | ||
= std/core/types/@dup(c); | ||
std/core/types/Unit; | ||
val _ : () | ||
= std/core/types/@dec-ref(@case306); | ||
std/core/types/Unit; | ||
}); | ||
std/core/int/int-add(a, c); | ||
_, _ | ||
-> val _ : () | ||
= std/core/types/@drop(a); | ||
val _ : () | ||
= std/core/types/@drop(@case306); | ||
b; | ||
})))); | ||
(std/core/types/Nil() : (list<int>) ) | ||
-> std/core/console/printsln("Nothing"); | ||
_ | ||
-> val _ : () | ||
= std/core/types/@drop(e); | ||
std/core/types/@unbox((std/core/exn/error-pattern("test/cgen/match-merge(2, 3)", "implicit-error-fallthrough"))); | ||
}; | ||
}; | ||
pub fun main : () -> console/console () | ||
= fn<console/console>(){ | ||
std/core/types/@unbox(val @b-x11@22 : ((m : hnd/marker<console/console,()>, hnd/ev<exn>, x : exception) -> console/console a) | ||
= (fn<console/console>(m: hnd/marker<console/console,()>, @_wildcard-x638_16: hnd/ev<exn>, x: exception){ | ||
val _ : () | ||
= (std/core/types/@drop(@_wildcard-x638_16, (std/core/types/@make-int32(3)))); | ||
val _ : () | ||
= (std/core/types/@drop(x)); | ||
(std/core/hnd/yield-to-final(m, (fn<e>(@b-x9: (hnd/resume-result<3004,3007>) -> 3006 3007){ | ||
val @_wildcard-x638_45@25 : ((hnd/resume-result<a,()>) -> console/console ()) | ||
= (fn<console/console>(@b-x10: hnd/resume-result<1004,()>){ | ||
(std/core/types/@unbox((@b-x9(@b-x10)))); | ||
}); | ||
val _ : () | ||
= (std/core/types/@drop(@_wildcard-x638_45@25)); | ||
(std/core/types/@box((std/core/console/printsln("Error")))); | ||
}))); | ||
}); | ||
(std/core/exn/@handle-exn((std/core/exn/@Hnd-exn(0, (std/core/hnd/Clause1((fn<e>(@b-x12: hnd/marker<1018,1019>, @b-x13: hnd/ev<1017>, @b-x14: 1015){ | ||
(@b-x11@22(@b-x12, @b-x13, (std/core/types/@unbox(@b-x14)))); | ||
}))))), (fn<e>(@b-x18: 3002){ | ||
val @x@26 : () | ||
= (std/core/types/@unbox(@b-x18)); | ||
(std/core/types/@box(@x@26)); | ||
}), (fn<<exn|e>>(){ | ||
(std/core/types/@box((std/core/console/printsln((std/core/int/show(2)))))); | ||
})))); | ||
}; | ||
module test/cgen/match-merge/@main | ||
import std/core/types = std/core/types pub = ""; | ||
import std/core/hnd = std/core/hnd pub = ""; | ||
import std/core/exn = std/core/exn pub = ""; | ||
import std/core/bool = std/core/bool pub = ""; | ||
import std/core/order = std/core/order pub = ""; | ||
import std/core/char = std/core/char pub = ""; | ||
import std/core/int = std/core/int pub = ""; | ||
import std/core/vector = std/core/vector pub = ""; | ||
import std/core/string = std/core/string pub = ""; | ||
import std/core/sslice = std/core/sslice pub = ""; | ||
import std/core/list = std/core/list pub = ""; | ||
import std/core/maybe = std/core/maybe pub = ""; | ||
import std/core/either = std/core/either pub = ""; | ||
import std/core/tuple = std/core/tuple pub = ""; | ||
import std/core/show = std/core/show pub = ""; | ||
import std/core/debug = std/core/debug pub = ""; | ||
import std/core/delayed = std/core/delayed pub = ""; | ||
import std/core/console = std/core/console pub = ""; | ||
import std/core = std/core = ""; | ||
import test/cgen/match-merge = test/cgen/match-merge = ""; | ||
// Stateful functions can manipulate heap `:h` using allocations, reads and writes. | ||
local alias st<(h :: H)> :: H -> E = <(read :: H -> X)<(h :: H)>,(write :: H -> X)<(h :: H)>,(alloc :: H -> X)<(h :: H)>> = 1; | ||
pub fun @expr : () -> console/console () | ||
= fn<console/console>(){ | ||
test/cgen/match-merge/main(); | ||
}; | ||
pub fun @main : () -> <st<global>,console/console,div,fsys,ndet,net,ui> () | ||
= fn<io-noexn>(){ | ||
test/cgen/match-merge/main(); | ||
}; | ||
linking : test/cgen/match-merge/@main | ||
compile : kklib from: /home/tim/koka/kklib | ||
created : .koka/v3.1.2/gcc-debug-612e08/test_cgen_match_dash_merge__main | ||
2 |
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
Oops, something went wrong.