Exemple #1
0
/// <summary>
///   <list type="number">
///     <item>Set output type of PrologueI.</item>
///     <item>Load parameters</item>
///   </list>
/// </summary>
void Builder::SetUpMethodBody(Function& fun, MethodDef& method_def) {
  auto const pPrologueI = fun.GetStartBB()->GetFirstI();
  auto const pRefI = pPrologueI->GetNext();
  auto const pBB = pPrologueI->GetBBlock();
  auto& v1 = *pPrologueI->GetVd();

  ValuesTypeBuilder tybuilder(
      method_def.IsStatic()
          ? method_def.CountParams()
          : method_def.CountParams() + 1);

  auto nth = 0;

  // "this" parameter.
  if (!method_def.IsStatic()) {
    tybuilder.Append(method_def.owner_class_def().GetClass());
    nth++;
  }

  foreach (MethodDef::EnumParam, oEnum, method_def) {
    auto const pParamDef = oEnum.Get();
    auto& var = pParamDef->GetVariable();
    auto& varty = var.GetTy();
    tybuilder.Append(varty);
    DEBUG_FORMAT("%s %s", varty, var);

    auto& cell_class = Ty_ClosedCell->Construct(varty);
    //auto& r2 = *NewOutput(varty).StaticCast<Register>();
    auto& r2 = *NewOutput(varty).StaticCast<Register>();
    r2.SetVariable(var);

    auto const pSelectI = new(zone()) SelectI(varty, r2, v1, nth);
    pSelectI->SetSourceInfo(pParamDef->GetSourceInfo());
    pBB->InsertBeforeI(*pSelectI, pRefI);

    auto& r3 = NewRegister();
    auto& vardef_inst = *new(zone()) VarDefI(cell_class, r3, var, r2);
    vardef_inst.set_source_info(pParamDef->source_info());
    pBB->InsertBeforeI(vardef_inst, pRefI);

    ++nth;
  }
Exemple #2
0
bool CNtlLogSystem::IsChannelOn(DWORD dwSource, BYTE byChannel)
{
	::EnterCriticalSection(&m_lock);

	sSOURCE_INFO* pSourceInfo = GetSourceInfo(dwSource);
	if (NULL == pSourceInfo)
	{
		::LeaveCriticalSection(&m_lock);
		return false;
	}

	sCHANNEL_INFO* pChannelInfo = GetChannelInfo(pSourceInfo, byChannel);
	if (NULL == pChannelInfo)
	{
		::LeaveCriticalSection(&m_lock);
		return false;
	}

	bool bIsOn = pChannelInfo->bIsOn;

	::LeaveCriticalSection(&m_lock);
	return bIsOn;
}
bool CTheoraSource::GetOutputInfo(int nIndex, MediaInfo *pInfo)
{
	return nIndex >= m_nOutputNum? false : GetSourceInfo(pInfo);
}
Exemple #4
0
wxIASourceInfo wxIASaneProvider::GetSelSourceInfo()
{
    wxCHECK_MSG(Ok(), wxNullIASourceInfo, _T("wxIASane not valid!"));
    return GetSourceInfo(m_selDevice);
}
Exemple #5
0
bool CNtlLogSystem::AddLogAlternative(DWORD dwSource, BYTE byChannel, char* pszFormatString, va_list args)
{
	if (NULL == pszFormatString)
	{
		return false;
	}

	::EnterCriticalSection(&m_lock);

	if (false == m_bIsEnabled)
	{
		::LeaveCriticalSection(&m_lock);
		return true;
	}

	sSOURCE_INFO* pSourceInfo = GetSourceInfo(dwSource);
	if (NULL == pSourceInfo)
	{
		::LeaveCriticalSection(&m_lock);
		return false;
	}

	sCHANNEL_INFO* pChannelInfo = GetChannelInfo(pSourceInfo, byChannel);
	if (NULL == pChannelInfo)
	{
		::LeaveCriticalSection(&m_lock);
		return false;
	}

	if (false == pChannelInfo->bIsOn)
	{
		::LeaveCriticalSection(&m_lock);
		return true;
	}

	sLOG_FILE_KEY key(dwSource, byChannel);

	std::map<sLOG_FILE_KEY, sLOG_FILE_INFO*>::iterator iter;
	iter = m_mapLogFileRef.find(key);

	if (m_mapLogFileRef.end() == iter)
	{
		::LeaveCriticalSection(&m_lock);
		return false;
	}

	sLOG_FILE_INFO* pLogFileInfo = iter->second;

	::LeaveCriticalSection(&m_lock);

	::EnterCriticalSection(&(pLogFileInfo->lock));

	SYSTEMTIME localTime;
	GetLocalTime(&localTime);

	if (pLogFileInfo->wLastLogYear != localTime.wYear ||
		pLogFileInfo->wLastLogMonth != localTime.wMonth ||
		pLogFileInfo->wLastLogDay != localTime.wDay)
	{
		CloseLogFile(pLogFileInfo);
		OpenLogFile(pLogFileInfo);
	}

	fprintf( pLogFileInfo->fileStream.GetFilePtr(), "[%s],", pChannelInfo->szChannelName);
	vfprintf( pLogFileInfo->fileStream.GetFilePtr(), pszFormatString, args);
	fprintf( pLogFileInfo->fileStream.GetFilePtr(), "\n");
	fflush( pLogFileInfo->fileStream.GetFilePtr() );

	::LeaveCriticalSection(&(pLogFileInfo->lock));
	return true;
}
Exemple #6
0
bool CNtlLogSystem::RegisterChannel(
						DWORD dwSource, BYTE byChannel, char* pszChannelName,
						char* pszLogFileNamePrefix, char* pszLogFileNameSuffix, char* pszLogFileExtName, bool bIsOn)
{
	if (NULL == pszChannelName || NULL == pszLogFileNamePrefix || NULL == pszLogFileNameSuffix || NULL == pszLogFileExtName)
	{
		return false;
	}

	::EnterCriticalSection(&m_lock);

	sSOURCE_INFO* pSourceInfo = GetSourceInfo(dwSource);
	if (NULL == pSourceInfo)
	{
		::LeaveCriticalSection(&m_lock);
		return false;
	}

	sCHANNEL_INFO* pChannelInfo = GetChannelInfo(pSourceInfo, byChannel);
	if (NULL != pChannelInfo)
	{
		::LeaveCriticalSection(&m_lock);
		return false;
	}

	// Creates channel info.
	{
		pChannelInfo = new sCHANNEL_INFO(bIsOn);
		if (NULL == pChannelInfo)
		{
			::LeaveCriticalSection(&m_lock);
			return false;
		}

		NTL_SAFE_STRCPY(pChannelInfo->szChannelName, pszChannelName);

		if (false == (pSourceInfo->mapChannel).insert(std::pair<BYTE, sCHANNEL_INFO*>(byChannel, pChannelInfo)).second)
		{
			SAFE_DELETE(pChannelInfo);

			::LeaveCriticalSection(&m_lock);
			return false;
		}
	}

	sLOG_FILE_INFO* pLogFileInfo = NULL;

	// Creates log file info.
	{
		CNtlString strLogFileKey;
		strLogFileKey.Format("%s_%s", pszLogFileNamePrefix, pszLogFileNameSuffix);

		std::map<CNtlString, sLOG_FILE_INFO*>::iterator iterLogFile;
		iterLogFile = (pSourceInfo->mapLoggingFileInfo).find(strLogFileKey);

		if ((pSourceInfo->mapLoggingFileInfo).end() == iterLogFile)
		{
			pLogFileInfo = new sLOG_FILE_INFO;
			if (NULL == pLogFileInfo)
			{
				(pSourceInfo->mapChannel).erase(byChannel);
				SAFE_DELETE(pChannelInfo);

				::LeaveCriticalSection(&m_lock);
				return false;
			}

			NTL_SAFE_STRCPY(pLogFileInfo->szLogFileNamePrefix, pszLogFileNamePrefix);
			NTL_SAFE_STRCPY(pLogFileInfo->szLogFileNameSuffix, pszLogFileNameSuffix);
			NTL_SAFE_STRCPY(pLogFileInfo->szLogFileExtName, pszLogFileExtName);

			if (false == (pSourceInfo->mapLoggingFileInfo).insert(std::pair<CNtlString, sLOG_FILE_INFO*>(strLogFileKey, pLogFileInfo)).second)
			{
				SAFE_DELETE(pLogFileInfo);

				(pSourceInfo->mapChannel).erase(byChannel);
				SAFE_DELETE(pChannelInfo);

				::LeaveCriticalSection(&m_lock);
				return false;
			}

			if (false == OpenLogFile(pLogFileInfo))
			{
				(pSourceInfo->mapLoggingFileInfo).erase(strLogFileKey);
				SAFE_DELETE(pLogFileInfo);

				(pSourceInfo->mapChannel).erase(byChannel);
				SAFE_DELETE(pChannelInfo);

				::LeaveCriticalSection(&m_lock);
				return false;
			}

			::EnterCriticalSection(&(pLogFileInfo->lock));

			pLogFileInfo->dwRefCount = 1;
		}
		else
		{
			pLogFileInfo = iterLogFile->second;

			::EnterCriticalSection(&(pLogFileInfo->lock));

			(pLogFileInfo->dwRefCount)++;
		}

		sLOG_FILE_KEY logKey(dwSource, byChannel);

		if (false == m_mapLogFileRef.insert(std::pair<sLOG_FILE_KEY, sLOG_FILE_INFO*>(logKey, pLogFileInfo)).second)
		{
			(pLogFileInfo->dwRefCount)--;

			if (0 == pLogFileInfo->dwRefCount)
			{
				::LeaveCriticalSection(&(pLogFileInfo->lock));

				(pSourceInfo->mapLoggingFileInfo).erase(strLogFileKey);
				SAFE_DELETE(pLogFileInfo);
			}
			else
			{
				::LeaveCriticalSection(&(pLogFileInfo->lock));
			}

			(pSourceInfo->mapChannel).erase(byChannel);
			SAFE_DELETE(pChannelInfo);

			::LeaveCriticalSection(&m_lock);
			return false;
		}
		else
		{
			::LeaveCriticalSection(&(pLogFileInfo->lock));
		}
	}

	::LeaveCriticalSection(&m_lock);
	return true;
}