From: Raphael Y. de C. <rca...@im...> - 2004-03-29 21:53:08
|
Thanks very much for the fast help. Actually, I hadn't notice the documentation appendix page. Maybe if there was a link from the official openc++ page it would be easier to find... I hadn't say that in the first question but I still have a problem in finding global variables declarations. By what I've seen, It doesn't seems to be a simple way of finding them. Maybe I'll have to look at the source code... thanks, Raphael Citando Jean-Sebastien Mouret <js_...@us...>: > Raphael Yokoingawa de Camargo <rca...@im...> writes: > > > Hi, > > > > I am new openc++ user and I'm using it in my doctoral research. I'm > encountering > > some difficulties. > > > > 1) Is there a way for me to access the entire program PTree instead of only > the > > PTree relative to classes. I need this functionality because I will also > use > > openc++ to manipulate C code (that don't have classes) and I need to know > about > > all the function definitions in the code. > > have a look in the documentation appendix. > > > > > 2) Is there a way to only include some selected source files in the AST > tree? > > The generated source trees are to big because they include all the system > header > > files. It also makes much more difficult for me to analize the code, since > I don > > know wich code is from the applications. > > To do this, I use a special include directive for everything I don't > want openc++ to parse. The technic is rather gory and I'd like to know if > there is a nicer way to do it. > > for example, in your occ file just do: > > #include <common.hh> > // and then > include("iostream") > > > the common.hh contains something like: > > metaclass Tools internal_Tools; > struct internal_Tools {}; > # define include(FILE) void internal_Tools::include() { FILE; } > > > then in your openc++ compiler: > > struct Tools : public Class > { > static bool Initialize(); > void TranslateMemberFunction(Environment* env, Member& m); > void TranslateClass(Environment* env); > }; > > bool Tools::Initialize() > { > return Class::Initialize(); > } > > void Tools::TranslateClass(Environment* env) > { > RemoveClass(); > return Class::TranslateClass(env); > } > > void Tools::TranslateMemberFunction(Environment* env, Member& m) > { > if (Ptree::Match(m.Name(),"include")) > { > //FIXME: delete the member instead of commenting out > InsertBeforeToplevel(env,Ptree::Make("/*")); > AppendAfterToplevel(env,Ptree::Make("*/")); > > for(PtreeIter i = m.FunctionBody()->Rest()->First(); !i.Empty(); i++) > AppendAfterToplevel(env,Ptree::Make("\n#include > %p",(*i)->First())); > } > } > > > Hope this helps > > > -- > js > Raphael Yokoingawa de Camargo <rca...@im...> |