compiler/LexTest/AST.cpp
//search for variable in the current class

search for variable in the current class
search for variable in the current class
bool ID_Node::SearchClass(Class *currClass,char *name,bool in_class,Variable*& locate,char* Caller)
{
	bool ok=false;
	list<Variable *>::const_iterator i=currClass->fields.begin();
	while ((i!=currClass->fields.end())&&(!ok))
	{
		Variable *u=(Variable*)*i;
		if ((strcmp (u->name,name)==0) && (in_class))
		{
			char* type=(char*)*(--u->varType->implement.end());
			if(strcmp(type,"SELF_TYPE")==0)
			{
				list<char*> new_type; new_type.clear();
				new_type.push_front(Caller);
				Variable *tmp=new Variable(u->name);
				*tmp=*u;
				my_implements *R=new my_implements();
				R->implement=new_type;
				tmp->varType=R;
				locate = tmp;
			}
			else
				locate = u;
			ok=true;
		}
		else
		{
			if (!u->modi.empty())
			{
				if ((strcmp(u->name,name)==0)&&((my_modifiers::found(u->modi,Public))||(my_modifiers::found(u->modi,Protected))))
				{
					char* type=(char*)*(--u->varType->implement.end());
					if(strcmp (type,"SELF_TYPE")==0)
					{
						list<char*> new_type; new_type.clear();
						new_type.push_front(Caller);
						Variable *tmp=new Variable(u->name);
						*tmp=*u;
						my_implements *R=new my_implements ();
						R->implement=new_type;
						tmp->varType=R;
						locate = tmp;
					}
					else
						locate = u;
					ok=true;
				}
			}
		}
		i++;
	}
	return ok;
}
bool ID_Node :: SearchClass ( Class * currClass , char * name , bool in_class , Variable * & locate , char * Caller ) { bool ok = false ; list < Variable * > :: const_iterator i = currClass -> fields . begin ( ) ; while ( ( i != currClass -> fields . end ( ) ) && ( ! ok ) ) { Variable * u = ( Variable * ) * i ; if ( ( strcmp ( u -> name , name ) == 0 ) && ( in_class ) ) { char * type = ( char * ) * ( -- u -> varType -> implement . end ( ) ) ; if ( strcmp ( type , " " ) == 0 ) { list < char * > new_type ; new_type . clear ( ) ; new_type . push_front ( Caller ) ; Variable * tmp = new Variable ( u -> name ) ; * tmp = * u ; my_implements * R = new my_implements ( ) ; R -> implement = new_type ; tmp -> varType = R ; locate = tmp ; } else locate = u ; ok = true ; } else { if ( ! u -> modi . empty ( ) ) { if ( ( strcmp ( u -> name , name ) == 0 ) && ( ( my_modifiers :: found ( u -> modi , Public ) ) || ( my_modifiers :: found ( u -> modi , Protected ) ) ) ) { char * type = ( char * ) * ( -- u -> varType -> implement . end ( ) ) ; if ( strcmp ( type , " " ) == 0 ) { list < char * > new_type ; new_type . clear ( ) ; new_type . push_front ( Caller ) ; Variable * tmp = new Variable ( u -> name ) ; * tmp = * u ; my_implements * R = new my_implements ( ) ; R -> implement = new_type ; tmp -> varType = R ; locate = tmp ; } else locate = u ; ok = true ; } } } i ++ ; } return ok ; }
search for variable in the current class
search for variable in the current class
//IF ID TYPE IS SELF_TYPE
 //IF ID TYPE IS SELF_TYPE
