Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. let rec apply_cmd arch prog = function
  2. | AnalysisAst f -> (
  3. match prog with
  4. | Ast p as p' -> f p; p'
  5. | _ -> failwith "need explicit translation to AST"
  6. )
  7. | AnalysisModeAst f -> (
  8. match prog with
  9. | Ast p as p' -> f (Input.get_arch arch) p; p'
  10. | _ -> failwith "need explicit translation to AST"
  11. )
  12. | AnalysisAstCfg f -> (
  13. match prog with
  14. | AstCfg p as p' -> f p; p'
  15. | _ -> failwith "need explicit translation to AST CFG"
  16. )
  17. | AnalysisModeAstCfg f -> (
  18. match prog with
  19. | AstCfg p as p' -> f (Input.get_arch arch) p; p'
  20. | _ -> failwith "need explicit translation to AST CFG"
  21. )
  22. | AnalysisSsa f -> (
  23. match prog with
  24. | Ssa p as p' -> f p; p'
  25. | _ -> failwith "need explicit translation to SSA"
  26. )
  27. | TransformAst f -> (
  28. match prog with
  29. | Ast p -> Ast(f p)
  30. | _ -> failwith "need explicit translation to AST"
  31. )
  32. | TransformModeAst f -> (
  33. match prog with
  34. | Ast p -> Ast(f (Input.get_arch arch) p)
  35. | _ -> failwith "need explicit translation to AST"
  36. )
  37. | TransformAstCfg f -> (
  38. match prog with
  39. | AstCfg p -> AstCfg(f p)
  40. | _ -> failwith "need explicit translation to AST CFG"
  41. )
  42. | TransformSsa f -> (
  43. match prog with
  44. | Ssa p -> Ssa(f p)
  45. | _ -> failwith "need explicit translation to SSA"
  46. )
  47. | ToCfg -> (
  48. match prog with
  49. | Ast p -> AstCfg(Cfg_ast.of_prog p)
  50. | Ssa p -> AstCfg(Cfg_ssa.to_astcfg p)
  51. | AstCfg _ as p -> prerr_endline "Warning: null transformation"; p
  52. )
  53. | ToAst -> (
  54. match prog with
  55. | AstCfg p -> Ast(Cfg_ast.to_prog p)
  56. | p -> apply_cmd arch (apply_cmd arch p ToCfg) ToAst
  57. )
  58. | ToSsa -> (
  59. match prog with
  60. | AstCfg p -> Ssa(Cfg_ssa.of_astcfg ~tac:!tac p)
  61. | p -> apply_cmd arch (apply_cmd arch p ToCfg) ToSsa
  62. );;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement