本文整理汇总了C++中Engine::Compile方法的典型用法代码示例。如果您正苦于以下问题:C++ Engine::Compile方法的具体用法?C++ Engine::Compile怎么用?C++ Engine::Compile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine::Compile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
/*
* Argument specification: -a"Arg1 Arg2 Arg3" or -aArg1
* -------------------------------------------------------------
* Each argument should be space seperated.
* If arguments have already been specified then these arguments
* are appended to the previous array of arguments.
* All arguments are strings.
*/
case 'a':
{
AddArgument(eng, cl.Opt(), arguments);
}
break;
/*
* Script File: -fFileToExecute
*/
case 'f':
{
fileName = cl.Opt();
break;
}
/*
* Suppress Banner: -s
*/
case 'v':
{
if (!fileName)
{
Pika_PrintBanner();
exit(0);
}
break;
}
default:
{
if (cl.Kind() == '\0' && cl.Opt())
{
if (!fileName)
{
fileName = cl.Opt();
}
else
{
AddArgument(eng, cl.Opt(), arguments);
}
}
else
{
std::cerr << "Unknown Option: " << cl.CurrArg();
Pika_DisplayUsage(argv[0]);
}
}
}// switch
cl.Next();
}
if (!fileName)
{
ReadExecutePrintLoop(eng);
}
else
{
// Depending on the size of the script, arguments might be collected
// before Compile returns.
//
// So we add them to the roots to prevent collection.
eng->AddToRoots(arguments);
// Add paths defined in $PIKA_PATH to our PathManager.
eng->AddEnvPath("PIKA_PATH");
// Compile the script.
Script* script = eng->Compile(fileName);
if (script)
{
script->Run(arguments);
}
else
{
std::cerr << "\n** Could not run script: " << fileName << std::endl;
}
}
}
catch (Exception& e)
{
std::cerr << "Uncaught " << e.GetErrorKind(eng) << ": " << e.GetMessage() << std::endl;
}
catch (...)
{
std::cerr << "Uncaught exception. Exiting pika ..." << std::endl;
}
if (eng)
{
eng->Release();
}
}
return 0;
}