ScopePtr Findable::findClassType( Scope* stable, const std::string& class_name ) { ScopePtr found = findClassType_downward( stable, class_name ); if( found ) return found; else if( stable->m_parent ) return findClassType( stable->m_parent, class_name ); else return ScopePtr(); }
ScopePtr Findable::findPackage( Scope* stable, const std::string& pkgs_name ) { for( std::vector<SymbolPtr>::iterator I = stable->m_childs.begin(), B = stable->m_childs.end() ; I != B ; I ++ ) { // std::cerr << " findPackage iterator to " <<(*I)->name() << std::endl; if( (*I)->name() == pkgs_name && (*I)->is( Symbol::T_SCOPE ) ) { ScopePtr pkg_symbol = DYNA_CAST( Scope, *I ); if( pkg_symbol->getScopeType() == Scope::T_PACKAGE ) { return pkg_symbol; } } } if( stable->m_parent ) return findPackage( stable->m_parent, pkgs_name ); return ScopePtr(); }
ScopePtr Findable::findClassType_downward( Scope* stable, const std::string& class_name ) { for( std::vector<SymbolPtr>::iterator I = stable->m_childs.begin(), B = stable->m_childs.end() ; I != B ; I ++ ) { if( (*I)->name() == class_name && (*I)->is(Symbol::T_SCOPE) ) { ScopePtr pkg_symbol = DYNA_CAST( Scope, *I ); if( pkg_symbol->getScopeType() == Scope::T_CLASS ) { return pkg_symbol; } } if( (*I)->name() == "" && (*I)->is( Symbol::T_SCOPE) ) { ScopePtr pkg_symbol = DYNA_CAST( Scope, *I ); if( pkg_symbol->getScopeType() == Scope::T_PACKAGE ) { ScopePtr found = findClassType_downward( pkg_symbol.get() , class_name ); if( found ) return found; } } } return ScopePtr(); }
listTail(const Constant& l); std::string read_file(std::istream& is); struct ExtraTreeInformation { std::vector<std::pair<ScopePtr, Parser::Line>> equations; }; std::pair < Tree::Expr, ExtraTreeInformation > fixupTree(System& s, const Tree::Expr& e, ScopePtr scope = ScopePtr()); //the magic hash combine from boost inline void hash_combine(size_t v, std::size_t& seed) { seed ^= v + 0x9e3779b9 + (seed<<6) + (seed>>2); } template <typename T> inline void hash_combine_hasher(const T& v, std::size_t& seed) { hash_combine(std::hash<T>()(v), seed); }
SymbolTable::SymbolTable () { this->scopes.push_back(ScopePtr(new Scope)); this->getRootScope()->setName("global"); }