Skip to content

Commit

Permalink
compiler: test case for #31 is quite simple now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilin Chen authored and Zilin Chen committed Jan 12, 2017
1 parent be31059 commit 2f93a67
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions cogent/tests/pass_ticket-e31.cogent
Original file line number Diff line number Diff line change
@@ -1,36 +1,18 @@
type MountState

type Buffer
type UbiVol
type OstoreState = {
next_inum : U32
, rbuf : Buffer
, wbuf_eb : U32
, ubi_vol : UbiVol
}
type OstoreState = { rbuf : Buffer }

type ObjId = U64
type Obj

type R a b = <Success a | Error b>
type RR c a b = (c, R a b)
type RR c a b = (c, <Success a | Error b>)

type BufOffs = U32
deep_freeObj: Obj -> ()
deserialise_Obj: (Buffer!, BufOffs) -> (Obj, BufOffs)
read_obj_pages_in_buf: (MountState!, UbiVol!, Buffer, ObjAddr!) -> Buffer

type ObjAddr = #{ ebnum : U32, offs : U32, len : U32, sqnum : U64 }
index_get_addr : () -> ObjAddr
deserialise_Obj: () -> Obj

ostore_read: (MountState!, OstoreState, ObjId) -> RR OstoreState Obj ()
ostore_read (mount_st, ostore_st, oid) =
let addr = index_get_addr ()
and (ostore_st, r) =
let ostore_st {rbuf} = ostore_st
and rbuf = read_obj_pages_in_buf (mount_st, ostore_st.ubi_vol, rbuf, addr) !ostore_st
and (obj, sz) = deserialise_Obj (rbuf, 1) !rbuf
in (ostore_st {rbuf}, Success obj)
ostore_read: OstoreState -> RR OstoreState Obj ()
ostore_read ostore_st =
let (ostore_st, r) =
let obj = deserialise_Obj ()
in (ostore_st, Success obj)
in r
| Success obj -> let _ = deep_freeObj obj in (ostore_st, Error)
| Error -> (ostore_st, Error)
Expand Down

0 comments on commit 2f93a67

Please sign in to comment.