0

I am trying to make changes to the behavior of a function and print the results to a file. The ViewCfg plug-in described in the Plug-in Development Guide does something similar, but I am trying to avoid having to use Ast.get, which ViewCfg uses. I am thinking of extending Printer.extensible_printer which, according to the Frama-C API Documentation, is something I can do if I want to obtain a custom pretty-printer.

However, if I extend the pretty-printer as described in the API docs, unless I'm doing something wrong, I notice that the changes I make take place regardless of which project is set as the current project. I'm using File.create_project_from_visitor to create a new project and Project.set_current to set the new project as the current project before I use the custom pretty-printer.

Is it true that any change made by a class that extends Printer.extensible_printer applies to all projects? I happen to be using frama-c-Aluminium-20160502, which I know is not the latest version.

EDIT: Sorry, I should have made this clearer in the beginning, but I'm not actually making changes to the behavior of a function. I'm reading in the behavior of a function, then based on that, I'm trying to generate as output valid C code that's meant to be read as input by another program.

Regarding AST.get, the only reason I was avoiding it was that it sounds like it gets the entire AST, while I'm only interested in part of it, i.e. behaviors. But if I'm just making things harder for myself by avoiding it, then I'll go ahead and use it.

gsp
  • 67
  • 1
  • 5
  • Yes, the printer is set globally, not on a per-project basis. That said, your question is unclear to me. You seem to want to do a program transformation, for which you are right to consider `File.create_project_from_visitor`. Why would you need to alter the behavior of the printer whose purpose is to pretty-print the AST (or a fragment thereof) as a piece of C code? – Virgile Jan 24 '17 at 08:13
  • @gsp, could you elaborate on why you want to avoid having to use `Ast.get`? That might help understand your goal and how to best achieve it. – anol Jan 24 '17 at 12:56

0 Answers0