int ProgramHandler::runDown(IDEGateway& ideGateway)
{
	shared_ptr<LinkedTokenList> tokenList = nullptr;
	shared_ptr<LinkedActionList> compiledList = nullptr;

	try
	{
		//=============START-CLOCK=============
		if (ideGateway.doPrintElapsedTime())
		{
			sttime = clock();
		}

		//=============TOKENIZER=============
		tokenList = runTokenizer(ideGateway.getCode(), ideGateway.doPrintTokenList());

		if (errors())
		{
			return -1;
		}

		//=============COMPILER=============
		compiledList = runCompiler(tokenList, ideGateway.doPrintCompiledList());

		if (errors())
		{
			return -1;
		}

		//=============VM=============
		if (!ideGateway.doBuild())
		{
			runVirtualMachine(compiledList);
		}

		if (errors())
		{
			return -1;
		}

		//=============END-CLOCK=============
		if (ideGateway.doPrintElapsedTime())
		{
			printElapsedTime();
		}
	}
	catch (...)
	{
		cleanup(tokenList, compiledList);
	}
	cleanup(tokenList, compiledList);

	return 0;
}
示例#2
0
std::string CudaCompiler::compileCubinFile(bool enablePrints)
{
  bool bSucceed = true;
  
  staticInit();
    
  /// Check that the source file exists.
  if (!fileExists(m_sourceFile)) {
    fprintf( stderr, "%s : source file does not exist.\n", __FUNCTION__);
    return "";
  }
  
  /// Cache directory does not exist => create it.
  createCacheDir();

  /// Preprocess.
  writeDefineFile();
  std::string cubinFile, finalOpts;
  bSucceed = runPreprocessor(cubinFile, finalOpts);
  
  if (!bSucceed) { 
    fprintf( stderr, "%s : preprocessor failed.\n", __FUNCTION__);
    return ""; 
  }

  /// CUBIN exists => done.
  if (fileExists(cubinFile)) 
  {
#ifndef NDEBUG
    //fprintf( stderr, "CudaCompiler: '%s' already compiled.\n", m_sourceFile.c_str());
#endif
    return cubinFile;
  }
  
  /// Compile.
  if (enablePrints) {
    printf("CudaCompiler: Compiling '%s'...", m_sourceFile.c_str());
  }

  bSucceed = runCompiler( cubinFile, finalOpts);

  if (enablePrints) {
    printf((!bSucceed) ? " Failed.\n" : " Done.\n");
  }
  
  return (bSucceed) ? cubinFile : "";
}
示例#3
0
static void CompilerMenu (const EditorInfoEx *ei, const wchar_t *FileName, const wchar_t *Path, ptrdiff_t lang)
{
	String	top(GetMsg (MTitle));
	const TLang	*lng = langColl[lang];
	size_t	ec = (lng) ? lng->execColl.getCount () : 0;
	if ((!ec) && (!outputmenu)) return ;
	if (autocompile)
	{
		size_t i, count = 0;
		if (ec)
		{
			for (size_t j = 0; j < ec; j++)
			{
				const TExec *ex = lng->execColl[j];
				if (validMenuItem (Path, FileName, ex))
				{
					i = j;
					count++;
				}
			}
		}

		if (count == 1)
			if (lng)
			{
				const TExec *e = lng->execColl[i];
				runCompiler (ei, lng, FileName, Path, e->title, e);
				return ;
			}
	}

	FarMenuItemEx *amenu = new FarMenuItemEx[ec + 2];
	if (amenu)
	{
		for (size_t ii = 0; ii < ec + 2; ii++)
			amenu[ii].Text = new wchar_t[NM];

		const intptr_t scId = -1;
		intptr_t	i = 0;
		sep = true;
		if (ec)
		{
			for (size_t j = 0; j < ec; j++)
			{
				const TExec *ex = lng->execColl[j];
				if (validMenuItem (Path, FileName, ex))
					addToCompilerMenu (ex->title, amenu, i, j, Path, FileName, FarKey());
			}

			addToCompilerMenu (L"", amenu, i, 0, Path, FileName, FarKey());
		}
		addToCompilerMenu (GetMsg (MShowOutput), amenu, i, scId, Path, FileName, {VK_MULTIPLY, 0});
		if (!compilerOut) amenu[i - 1].Flags = MIF_DISABLE;
		for (intptr_t k = 0; k < i; k++)
			if (!(amenu[k].Flags & (MIF_DISABLE | MIF_SEPARATOR)))
			{
				amenu[k].Flags |= MIF_SELECTED;
				break;
			}

		intptr_t res = Info.Menu
			(
				&MainGuid,
				&CompMenuGuid,
				-1,
				-1,
				0,
				FMENU_WRAPMODE | FMENU_AUTOHIGHLIGHT,
				top,
				nullptr,
				nullptr,
				nullptr,
				nullptr,
				(const FarMenuItemEx *) amenu,
				(outputmenu) ? i : i - 2
			);
		if (res != -1)
		{
			intptr_t id = amenu[res].UserData;
			if (id == scId)
				showCompileOut (ei, Path);
			else if (lng)
			{
				const TExec *e = lng->execColl[id];
				runCompiler (ei, lng, FileName, Path, e->title, e);
			}
		}

		for (size_t ii = 0; ii < ec + 2; ii++)
			delete[] amenu[ii].Text;

		delete[] amenu;
	}
}