From: Jean-Sebastien M. <js_...@us...> - 2004-03-29 16:19:54
|
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 |