Exemple #1
0
Symbol* SymScope::lookup( const char * name )
{
	//first check the current table;
	ScopeTableType::const_iterator i;
	i = m_scopetable.find( (char*) name );
	if ( i != m_scopetable.end() ) {
		return i->second;
	}
	return NULL;
}
Exemple #2
0
Symbol* SymScope::lookup( const char * name )
{
    //first check the current table;
    ScopeTableType::const_iterator i;
    i = m_scopetable.find( name );
    if ( i != m_scopetable.end() ) {
        return i->second;
    }

    //failing that, check all the parents;
    if ( m_parent != NULL ) {
        return m_parent->lookup( name );
    } else {
        //if this has no parents, then it cannot be found
        return NULL;
    }
}
Exemple #3
0
bool SymScope::is_dup_string(const char* name)
{
    ScopeTableType::iterator si;

    si = m_scopetable.find( name );
    if ( si != m_scopetable.end() ) {
        //check if the pointers match
        if ( si->first == name ) return false;
    }

    list<SymScope*>::iterator li;
    for( li=m_child.begin(); li!=m_child.end(); ++li )
    {
        bool r = (*li)->is_dup_string(name);
        if ( r==false ) return false;
    }

    //if it gets this far, there is no duplicate
    return true;
}