0

When I use fram-c to write parser. I encountered a problem that Ast.get() returns the type Cil_types.file but I need Cil.file for future use. They are actually has the same fields, but the ocaml compiler just not let the direct assignment from Cil_types.file to Cil.file. Is there any type cast functions in Ocaml can help me do this.

Ps: I try to assign each field of Cil_types.file to Cil.file, but the same problem happens recursively (do not allow Cil.file.* = Cil_types.file.*). I really appreciate your help!

svick
  • 236,525
  • 50
  • 385
  • 514
FakeJohn
  • 3
  • 2

1 Answers1

1

In Frama-C, there is no Cil_types.file type. Maybe you are mixing Frama-C with the original Cil?

AlexB
  • 7,302
  • 12
  • 56
  • 74
  • Hi, originally, I also think that Cil_types.file and Cil.file should not be used in the same file. However, the function Ast.get() will return a Cil_type.file() which defined in [frama-c-Nitrogen-20111001/src/kernel/ast.ml](http://docs.camlcity.org/docs/godisrc/frama-c-Nitrogen-20111001.tar.gz/frama-c-Nitrogen-20111001/src/kernel/ast.ml) And the function computeGraph() will need a Cil.file as the input. What can I do to do the transformation of the two actually the same data type? – FakeJohn Dec 04 '13 at 15:23
  • Actually, why I encountered this problem is that, I am currently modifying a project written in Frama-c-Lithium_20081201 version. It uses computeGraph(Cil_state.file). However In the next release of Frama-c, it changes Cil_state to Ast and Cil_state.file to Ast.get(). which changes the return type to Cil_types.file. I don't know how to fill the gap :( – FakeJohn Dec 04 '13 at 15:37
  • Maybe you can try running the scripts in bin/ in the order of atomic elements, that does a large part of the conversion. The script lithium2beryllium seems to do what you want. – Matthieu Lemerre Dec 04 '13 at 15:47
  • Thanks for your suggestions but how can I find lithium2beryllium, I didn't find it in the frama-c folder? – FakeJohn Dec 04 '13 at 19:16
  • It is in the bin folder of the Frama-C distribution. – Matthieu Lemerre Dec 05 '13 at 16:25