Changeset 2326 for src/Clight/abstract.ma
- Timestamp:
- Sep 7, 2012, 12:15:51 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Clight/abstract.ma
r2325 r2326 52 52 (* Labelled states in Clight are a little tricky because there are cost labels 53 53 in the expressions in addition to the cost statement. Note that a labelled 54 state may produce several cost labels due to expressions. *) 54 state may produce several cost labels due to expressions, and that we should 55 only check the root of the statement because sub-statements will not be 56 executed until later. 57 58 Also, a labelled state will only be guaranteed to generate a cost label in 59 the trace if the program is properly cost labelled - if it isn't then an 60 Econd might be used to with a cost label in only one branch. 61 *) 55 62 56 63 definition expr_labelled : expr → bool ≝ 57 64 any_expr (λe. match e with [ Expr e _ ⇒ match e with [ Ecost _ _ ⇒ true | _ ⇒ false ] ]). 58 65 66 definition statement_cont_labelled : statement → cont → bool ≝ 67 λs,k. 68 match s with 69 [ Sskip ⇒ 70 match k with 71 [ Kdowhile e _ _ ⇒ expr_labelled e 72 | _ ⇒ false 73 ] 74 | Sassign e1 e2 ⇒ expr_labelled e1 ∨ expr_labelled e2 75 | Scall oe e es ⇒ (option_map_def … expr_labelled false oe) ∨ expr_labelled e ∨ all ? expr_labelled es 76 | Ssequence _ _ ⇒ false 77 | Sifthenelse e _ _ ⇒ expr_labelled e 78 | Swhile e _ ⇒ expr_labelled e 79 | Sdowhile e _ ⇒ false 80 | Sfor s e _ _ ⇒ match s with [ Sskip ⇒ expr_labelled e | _ ⇒ false ] 81 | Sbreak ⇒ false 82 | Scontinue ⇒ 83 match k with 84 [ Kdowhile e _ _ ⇒ expr_labelled e 85 | _ ⇒ false 86 ] 87 | Sreturn oe ⇒ option_map_def … expr_labelled false oe 88 | Sswitch e _ ⇒ expr_labelled e (* should not occur due to early switch removal *) 89 | Slabel _ _ ⇒ false 90 | Sgoto _ ⇒ false 91 | Scost _ _ ⇒ true 92 ]. 93 59 94 definition Clight_labelled : state → bool ≝ 60 95 λs. match s with 61 [ State f s k e m ⇒ 62 any_statement (λs. match s with [ Scost _ _ ⇒ true | _ ⇒ any_expr_statement expr_labelled s ]) s 96 [ State f s k e m ⇒ statement_cont_labelled s k 63 97 | _ ⇒ false 64 98 ].
Note: See TracChangeset
for help on using the changeset viewer.