From: silhape2 Date: Tue, 15 Feb 2011 09:27:15 +0000 (+0100) Subject: Corrected Makefile(wrong name of the source file) and updated visualizer.cpp Now... X-Git-Url: http://rtime.felk.cvut.cz/gitweb/boost-statechart-viewer.git/commitdiff_plain/f821788a25d97fae41fe6e32ef704ee769ed84df Corrected Makefile(wrong name of the source file) and updated visualizer.cpp Now working without my own iterator. --- diff --git a/Makefile b/Makefile index 35aabed..bc774c0 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LLVM_BIN= $(CURDIR)/_install/bin LLVM_CONFIG := $(shell $(LLVM_BIN)/llvm-config --cxxflags --ldflags --libs jit core) -g++ : main.cpp +g++ : visualizer.cpp g++ visualizer.cpp -o visualizer -g -lclangParse -lclangFrontend -lclangSerialization \ -lclangDriver -lclangCodeGen -lclangSema -lclangChecker \ -lclangAnalysis -lclangRewrite -lclangAST -lclangLex -lclangBasic \ diff --git a/visualizer.cpp b/visualizer.cpp index 8bafb1e..5d7e942 100644 --- a/visualizer.cpp +++ b/visualizer.cpp @@ -89,9 +89,10 @@ class FindStates : public ASTConsumer { const CXXRecordDecl *cRecDecl = dyn_cast(decl); if(cRecDecl->getNumBases()==1) //state is derived from one base class simple_state - { + { + const DeclContext *declCont = tagDecl->castToDeclContext(tagDecl); std::cout << "New state: " << namedDecl->getNameAsString() << "\n"; - find_transitions(namedDecl->getNameAsString(), cRecDecl); + find_transitions(namedDecl->getNameAsString(), declCont); } } } @@ -101,25 +102,30 @@ class FindStates : public ASTConsumer } } - void find_transitions (const std::string name_of_state, const CXXRecordDecl *cRecDecl) // traverse all methods for finding declarations of transitions + void find_transitions (const std::string name_of_state,const DeclContext *declCont) // traverse all methods for finding declarations of transitions { std::string output, line, event, dest, params; llvm::raw_string_ostream x(output); int pos; - for (CXXRecordDecl::my_iterator i = cRecDecl->it_begin(), e = cRecDecl->it_end(); i != e; ++i) + for (DeclContext::decl_iterator i = declCont->decls_begin(), e = declCont->decls_end(); i != e; ++i) { - const Decl *decl = *i; - const NamedDecl *namedDecl = dyn_cast(decl); - decl->print(x); - output = x.str(); - if(count(output)==1) + const Decl *decl = *i; + //decl->dump(); + + if (const TypedefDecl *typeDecl = llvm::dyn_cast(decl)) { - line = clean_spaces(cut_typedef(output)); - params = get_transition_params(line); - pos = params.find(","); - event = params.substr(0,pos); - dest = params.substr(pos+1); - if(is_transition(line)) std::cout << "New transition: " << name_of_state<<" -> "< "<< dest<<"\n"; + const NamedDecl *namedDecl = dyn_cast(decl); + decl->print(x); + output = x.str(); + if(count(output)==1) + { + line = clean_spaces(cut_typedef(output)); + params = get_transition_params(line); + pos = params.find(","); + event = params.substr(0,pos); + dest = params.substr(pos+1); + if(is_transition(line)) std::cout << "New transition: " << name_of_state<<" -> "< "<< dest<<"\n"; + } } /* TODO else test na projiti*/ }