From: Grzegorz J. <ja...@he...> - 2004-04-02 14:09:44
|
Smart. GJ On Mon, 29 Mar 2004, Jean-Sebastien Mouret wrote: > 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 > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > Opencxx-users mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/opencxx-users > > ################################################################## # Grzegorz Jakacki Huada Electronic Design # # Senior Engineer, CAD Dept. 1 Gaojiayuan, Chaoyang # # tel. +86-10-64365577 x2074 Beijing 100015, China # # Copyright (C) 2004 Grzegorz Jakacki, HED. All Rights Reserved. # ################################################################## |