本文整理汇总了C++中ASTPrinter::PrintAST方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTPrinter::PrintAST方法的具体用法?C++ ASTPrinter::PrintAST怎么用?C++ ASTPrinter::PrintAST使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTPrinter
的用法示例。
在下文中一共展示了ASTPrinter::PrintAST方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompileShaderPrimary
//.........这里部分代码省略.........
if (IsLanguageHLSL(inputDesc.shaderVersion))
{
/* Establish intrinsic adept */
intrinsicAdpet = MakeUnique<HLSLIntrinsicAdept>();
/* Parse HLSL input code */
HLSLParser parser(log_);
program = parser.ParseSource(
std::make_shared<SourceCode>(std::move(processedInput)),
outputDesc.nameMangling,
inputDesc.shaderVersion,
outputDesc.options.rowMajorAlignment,
((inputDesc.warnings & Warnings::Syntax) != 0)
);
}
else if (IsLanguageGLSL(inputDesc.shaderVersion))
{
/* Establish intrinsic adept */
#if 0
intrinsicAdpet = MakeUnique<GLSLIntrinsicAdept>();
#else //!!!
intrinsicAdpet = MakeUnique<HLSLIntrinsicAdept>();
#endif
/* Parse GLSL input code */
GLSLParser parser(log_);
program = parser.ParseSource(
std::make_shared<SourceCode>(std::move(processedInput)),
outputDesc.nameMangling,
inputDesc.shaderVersion,
((inputDesc.warnings & Warnings::Syntax) != 0)
);
}
if (!program)
return ReturnWithError(R_ParsingSourceFailed);
/* ----- Context analysis ----- */
timePoints_.analyzer = Time::now();
bool analyzerResult = false;
if (IsLanguageHLSL(inputDesc.shaderVersion))
{
/* Analyse HLSL program */
HLSLAnalyzer analyzer(log_);
analyzerResult = analyzer.DecorateAST(*program, inputDesc, outputDesc);
}
/* Print AST */
if (outputDesc.options.showAST)
{
ASTPrinter printer;
printer.PrintAST(program.get());
}
if (!analyzerResult)
return ReturnWithError(R_AnalyzingSourceFailed);
/* Optimize AST */
timePoints_.optimizer = Time::now();
if (outputDesc.options.optimize)
{
Optimizer optimizer;
optimizer.Optimize(*program);
}
/* ----- Code generation ----- */
timePoints_.generation = Time::now();
bool generatorResult = false;
if (IsLanguageGLSL(outputDesc.shaderVersion) || IsLanguageESSL(outputDesc.shaderVersion) || IsLanguageVKSL(outputDesc.shaderVersion))
{
/* Generate GLSL output code */
GLSLGenerator generator(log_);
generatorResult = generator.GenerateCode(*program, inputDesc, outputDesc, log_);
}
if (!generatorResult)
return ReturnWithError(R_GeneratingOutputCodeFailed);
/* ----- Code reflection ----- */
timePoints_.reflection = Time::now();
if (reflectionData)
{
ReflectionAnalyzer reflectAnalyzer(log_);
reflectAnalyzer.Reflect(
*program, inputDesc.shaderTarget, *reflectionData,
((inputDesc.warnings & Warnings::CodeReflection) != 0)
);
}
return true;
}