Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let cfg_of_imp = fun imp_prog -> match imp_prog with
- ImpProg (dec, com) ->
- let rec cfg_of_imp' = fun com cont -> match com with
- Cseq (com1, com2) -> let cfg = cfg_of_imp' com1 cont in
- let cont' = ultimo_cont cfg in
- let cfg' = cfg_of_imp' com2 cont' in
- (match com1 with
- While (exp, com) -> union_cfg cfg cfg'
- | _ -> union_cfg cfg (imposta_archi ([string_of_int cont', string_of_int (cont'+1)])
- (cfg_of_imp' com2 (cont'+1))))
- | Skip -> ([(string_of_int cont, BSkip)], [])
- | AssignVar (ide, n) -> ([string_of_int cont, BAssignVar (ide, n)], [])
- | AssignArray (ide, i, n) -> ([string_of_int cont, BAssignArray (ide, i, n)], [])
- | If (exp, com1, com2) -> let cfg_com1 = cfg_of_imp' com1 (cont+1) in
- let cont' = ultimo_cont cfg_com1 in
- let cfg_com2 = cfg_of_imp' com2 cont' in
- union_cfg (imposta_archi ([string_of_int cont, string_of_int (cont')])
- ([string_of_int cont, BGuard exp], [string_of_int cont, string_of_int (cont + 1)]))
- (union_cfg cfg_com1 cfg_com2)
- | While (exp, com) -> let cfg = cfg_of_imp' com (cont+1) in
- let cont' = ultimo_cont cfg in
- imposta_archi ([string_of_int cont', string_of_int cont; string_of_int cont, string_of_int (cont' + 1)]) (union_cfg ([string_of_int cont, BGuard exp], [string_of_int cont, string_of_int (cont+1)]) cfg)
- in cfg_of_imp' com 0
- ;;
Add Comment
Please, Sign In to add comment