Beispiel #1
0
int TABLE::Find(std::string na,__int16 rettype, TypeArray *typearray, bool exact)
{
	SYM *thead, *first;
	int nn;
	TypeArray *ta;
	char namebuf[1000];
	int s1,s2,s3;
	std::string name;

  dfs.puts("</Find>\n");
  dfs.puts((char *)na.c_str());
  if (this==nullptr) {
    matchno = 0;
    return 0;
  }
	if (na.length()==0) {
	  dfs.printf("name is empty string\n");
		throw new C64PException(ERR_NULLPOINTER,1);
  }

	matchno = 0;
	if (this==&gsyms[0])
		thead = SYM::GetPtr(gsyms[hashadd((char *)na.c_str())].GetHead());
	else
		thead = SYM::GetPtr(head);
	first = thead;
//	while(thead != NULL) {
//	  lfs.printf("Ele:%s|\n", (char *)thead->name->c_str());
//	  thead = thead->GetNext();
// }
 thead = first;
	while( thead != NULL) {
//		dfs.printf((char *)"|%s|,|%s|\n",(char *)thead->name->c_str(),(char *)na.c_str());
    name = *thead->name;
		s1 = thead->name->compare(na);
		s2 = thead->name2->compare(na);
		s3 = thead->name3->compare(na);
//		dfs.printf("s1:%d ",s1);
//		dfs.printf("s2:%d ",s2);
//		dfs.printf("s3:%d\n",s3);
		if(((s1&s2)|(s1&s3)|(s2&s3))==0) {
		  dfs.printf("Match\n");
			match[matchno] = thead;
			matchno++;
			if (matchno > 98)
				break;
		
			if (exact) {
				ta = thead->GetProtoTypes();
				if (ta->IsEqual(typearray)) {
				  dfs.printf("Exact match");
				  ta->Print();
				  typearray->Print();
				  delete ta;
				  return 1;
				}
				ta->Print();
				delete ta;
			}
		}
    thead = thead->GetNextPtr();
    if (thead==first) {
      dfs.printf("Circular list.\n");
      throw new C64PException(ERR_CIRCULAR_LIST,1);
    }
  }
  dfs.puts("</Find>\n");
  return exact ? 0 : matchno;
}