annotate Paper/src/MetaMetaCodeSegment.agda @ 0:14a0e409d574

ADD fast commit
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Sun, 24 Apr 2022 23:13:44 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 -- meta level
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 liftContext : {X Y : Set} {{_ : N.DataSegment X}} {{_ : N.DataSegment Y}} -> N.CodeSegment X Y -> N.CodeSegment Context Context
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 liftContext {{x}} {{y}} (N.cs f) = N.cs (\c -> N.DataSegment.set y c (f (N.DataSegment.get x c)))
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 liftMeta : {X Y : Set} {{_ : M.DataSegment X}} {{_ : M.DataSegment Y}} -> N.CodeSegment X Y -> M.CodeSegment X Y
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 liftMeta (N.cs f) = M.cs f
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 gotoMeta : {I O : Set} {{_ : N.DataSegment I}} {{_ : N.DataSegment O}} -> M.CodeSegment Meta Meta -> N.CodeSegment I O -> Meta -> Meta
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 gotoMeta mCode code m = M.exec mCode (record m {next = (liftContext code)})
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 push : M.CodeSegment Meta Meta
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 push = M.cs (\m -> M.exec (liftMeta (Meta.next m)) (record m {c' = Context.c (Meta.context m)}))
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 -- normal level
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 cs2 : N.CodeSegment ds1 ds1
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 cs2 = N.cs id
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 cs1 : N.CodeSegment ds1 ds1
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 cs1 = N.cs (\d -> N.goto cs2 d)
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 cs0 : N.CodeSegment ds0 ds1
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 cs0 = N.cs (\d -> N.goto cs1 (record {c = (ds0.a d) + (ds0.b d)}))
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 -- meta level (with extended normal)
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 main : Meta
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 main = gotoMeta push cs0 (record {context = (record {a = 100 ; b = 50 ; c = 70}) ; c' = 0 ; next = (N.cs id)})
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 -- record {context = record {a = 100 ; b = 50 ; c = 150} ; c' = 70 ; next = (N.cs id)}
14a0e409d574 ADD fast commit
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29