本文整理汇总了C++中CodeGenerator::getLineNo方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenerator::getLineNo方法的具体用法?C++ CodeGenerator::getLineNo怎么用?C++ CodeGenerator::getLineNo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator::getLineNo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputCPPImpl
void FunctionStatement::outputCPPImpl(CodeGenerator &cg,
AnalysisResultPtr ar) {
CodeGenerator::Context context = cg.getContext();
FunctionScopeRawPtr funcScope = getFunctionScope();
string fname = funcScope->getId();
bool pseudoMain = funcScope->inPseudoMain();
string origFuncName = !pseudoMain ? funcScope->getOriginalName() :
("run_init::" + funcScope->getContainingFile()->getName());
if (outputFFI(cg, ar)) return;
if (context == CodeGenerator::NoContext) {
funcScope->outputCPPDef(cg);
return;
}
if (context == CodeGenerator::CppDeclaration &&
!funcScope->isInlined()) return;
if (context == CodeGenerator::CppPseudoMain &&
(!pseudoMain || getFileScope()->canUseDummyPseudoMain(ar))) {
return;
}
if (context == CodeGenerator::CppImplementation &&
(funcScope->isInlined() || pseudoMain)) return;
cg.setPHPLineNo(-1);
if (pseudoMain && !Option::GenerateCPPMain) {
if (context == CodeGenerator::CppPseudoMain) {
if (cg.getOutput() != CodeGenerator::SystemCPP) {
cg.setContext(CodeGenerator::NoContext); // no inner functions/classes
funcScope->getVariables()->setAttribute(VariableTable::ForceGlobal);
outputCPPStmt(cg, ar);
funcScope->getVariables()->clearAttribute(VariableTable::ForceGlobal);
cg.setContext(CodeGenerator::CppPseudoMain);
return;
}
} else if (context == CodeGenerator::CppForwardDeclaration &&
cg.getOutput() != CodeGenerator::SystemCPP) {
return;
}
}
if (context == CodeGenerator::CppImplementation) {
printSource(cg);
} else if (context == CodeGenerator::CppForwardDeclaration &&
Option::GenerateCppLibCode) {
cg_printf("\n");
printSource(cg);
cg.printDocComment(funcScope->getDocComment());
}
bool isWrapper = context == CodeGenerator::CppTypedParamsWrapperDecl ||
context == CodeGenerator::CppTypedParamsWrapperImpl;
bool needsWrapper = isWrapper ||
(Option::HardTypeHints && funcScope->needsTypeCheckWrapper());
int startLineImplementation = -1;
if (context == CodeGenerator::CppDeclaration ||
context == CodeGenerator::CppImplementation ||
context == CodeGenerator::CppPseudoMain) {
startLineImplementation = cg.getLineNo(CodeGenerator::PrimaryStream);
}
if (funcScope->isInlined()) cg_printf("inline ");
TypePtr type = funcScope->getReturnType();
if (type) {
bool isHeader = cg.isFileOrClassHeader();
cg.setFileOrClassHeader(true);
type->outputCPPDecl(cg, ar, getScope());
cg.setFileOrClassHeader(isHeader);
} else {
cg_printf("void");
}
if (Option::FunctionSections.find(origFuncName) !=
Option::FunctionSections.end()) {
string funcSection = Option::FunctionSections[origFuncName];
if (!funcSection.empty()) {
cg_printf(" __attribute__ ((section (\".text.%s\")))",
funcSection.c_str());
}
}
if (pseudoMain) {
cg_printf(" %s%s(", Option::PseudoMainPrefix,
funcScope->getContainingFile()->pseudoMainName().c_str());
} else {
cg_printf(" %s%s(",
needsWrapper && !isWrapper ?
Option::TypedFunctionPrefix : Option::FunctionPrefix,
fname.c_str());
}
switch (context) {
case CodeGenerator::CppForwardDeclaration:
//.........这里部分代码省略.........