コード例 #1
0
ファイル: syms.c プロジェクト: dolenle/compiler
symbolTable* searchSymbol(symbolTable* table, char* ident) {
	symbolTable* curTable = table;
	do {
		if(containsSymbol(curTable, ident)) {
			return curTable;
		} else if (curTable->scope != GLOBAL_SCOPE) {
			curTable = curTable->parent;
		}
	} while(curTable->scope != GLOBAL_SCOPE);
	if(containsSymbol(curTable, ident)) {
		return curTable;
	} else {
		return NULL;
	}
}
コード例 #2
0
ModuleLinkerPass::StringVector ModuleLinkerPass::getAllUndefinedSymbols() const
{
	StringVector undefined;
	
	if(_linkedModule == 0) return undefined;
	
	StringSet encountered;
	
	for(auto kernel = _linkedModule->kernels().begin();
		kernel != _linkedModule->kernels().end(); ++kernel)
	{
		auto symbolsUsedByKernel = getAllSymbolsUsedByThisKernel(kernel->first,	
			_linkedModule);
		
		for(auto symbol = symbolsUsedByKernel.begin();
			symbol != symbolsUsedByKernel.end(); ++symbol)
		{
			if(!encountered.insert(*symbol).second) continue;
			
			if(!containsSymbol(*_linkedModule, *kernel->second, *symbol))
			{
				undefined.push_back(*symbol);
			}
		}
	}
	
	return undefined;
}
コード例 #3
0
ファイル: CUnitDefinitionDB.cpp プロジェクト: jonasfoe/COPASI
//virtual
bool CUnitDefinitionDB::add(const CUnitDefinition & src)
{
  // This form will construct a copy, before adding (inherited
  // from CCopasiVectorN). When the CUnitDefinition
  // copy constructor is called, an exception will be thrown if
  // the symbol is already in use.
  // If it's symbol is already present, this form will not add
  // a pointer to the src object, and will return false.

  if (containsSymbol(src.getSymbol()) ||
      getIndex(src.getObjectName()) != C_INVALID_INDEX)
    {
      return false;
    }

  CUnitDefinition * pCopy = NULL;

  try
    {
      pCopy = new CUnitDefinition(src, this);
    }

  catch (...)
    {
      return false;
    }

  return true;
}
コード例 #4
0
ファイル: CUnitDefinitionDB.cpp プロジェクト: jonasfoe/COPASI
//virtual
bool CUnitDefinitionDB::add(CUnitDefinition * src, bool adopt)
{

  // If it's symbol is already present, this form will not add
  // a pointer to the src object, and will return false.
  if (containsSymbol(src->getSymbol()) ||
      getIndex(src->getObjectName()) != C_INVALID_INDEX)
    {
      return false;
    }

  CCopasiVectorN< CUnitDefinition >::add(src, adopt);
  mSymbolToUnitDefinitions[src->getSymbol()] = src;

  if (src->getSymbol() == "\xCE\xA9")
    {
      mSymbolToUnitDefinitions["O"] = src;
    }

  return true;
}
コード例 #5
0
ファイル: Signature.hpp プロジェクト: absinlythe/PCFG-EM
 /*
  * Returns the ID for a symbol or a negative value (-1), if it does not exists.
  * Use add_symbol() as often as possible, if a non const method is ok.
  */
 ID resolve_symbol(const Symbol & symbol) const {
     return containsSymbol(symbol) ? external_to_internal.find(symbol)->second : -1; // return -1, if the symbol does not exist in the signature.
 }