Exemplo n.º 1
0
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;
	}
}
Exemplo n.º 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;
}
Exemplo n.º 3
0
//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;
}
Exemplo n.º 4
0
//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;
}
Exemplo n.º 5
0
 /*
  * 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.
 }