本文整理汇总了C++中FunctionScopePtr::needsTypeCheckWrapper方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionScopePtr::needsTypeCheckWrapper方法的具体用法?C++ FunctionScopePtr::needsTypeCheckWrapper怎么用?C++ FunctionScopePtr::needsTypeCheckWrapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionScopePtr
的用法示例。
在下文中一共展示了FunctionScopePtr::needsTypeCheckWrapper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputCPPStaticMethodWrapper
void MethodStatement::outputCPPStaticMethodWrapper(CodeGenerator &cg,
AnalysisResultPtr ar,
const char *cls) {
if (!m_modifiers->isStatic() || !m_stmt) return;
CodeGenerator::Context context = cg.getContext();
FunctionScopePtr funcScope = m_funcScope.lock();
bool isWrapper = context == CodeGenerator::CppTypedParamsWrapperDecl ||
context == CodeGenerator::CppTypedParamsWrapperImpl;
bool needsWrapper = isWrapper ||
(Option::HardTypeHints && funcScope->needsTypeCheckWrapper());
m_modifiers->outputCPP(cg, ar);
TypePtr type = funcScope->getReturnType();
if (type) {
type->outputCPPDecl(cg, ar);
} else {
cg_printf("void");
}
cg_printf(" %s%s(", needsWrapper && !isWrapper ?
Option::TypedMethodPrefix : Option::MethodPrefix,
cg.formatLabel(m_name).c_str());
if (!isWrapper) cg.setContext(CodeGenerator::CppStaticMethodWrapper);
funcScope->outputCPPParamsDecl(cg, ar, m_params, true);
cg_printf(") { %s%s%s(", type ? "return " : "",
needsWrapper && !isWrapper ?
Option::TypedMethodImplPrefix : Option::MethodImplPrefix,
cg.formatLabel(m_name).c_str());
cg_printf("%s%s::s_class_name", Option::ClassPrefix, cls);
cg.setContext(context);
if (funcScope->isVariableArgument()) {
cg_printf(", num_args");
}
if (m_params) {
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
ASSERT(param);
cg_printf(", %s%s", Option::VariablePrefix, param->getName().c_str());
}
}
if (funcScope->isVariableArgument()) {
cg_printf(", args");
}
cg_printf("); }\n");
if (!isWrapper && needsWrapper) {
cg.setContext(CodeGenerator::CppTypedParamsWrapperDecl);
outputCPPStaticMethodWrapper(cg, ar, cls);
cg.setContext(context);
}
}
示例2: outputCPPImpl
void MethodStatement::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
FunctionScopePtr funcScope = m_funcScope.lock();
ClassScopePtr scope = getClassScope();
if (outputFFI(cg, ar)) return;
cg.setPHPLineNo(-1);
CodeGenerator::Context context = cg.getContext();
if (context == CodeGenerator::CppImplementation) {
printSource(cg);
}
bool isWrapper = context == CodeGenerator::CppTypedParamsWrapperDecl ||
context == CodeGenerator::CppTypedParamsWrapperImpl;
bool needsWrapper = isWrapper ||
(Option::HardTypeHints && funcScope->needsTypeCheckWrapper());
const char *prefix = needsWrapper && !isWrapper ?
Option::TypedMethodPrefix : Option::MethodPrefix;
switch (context) {
case CodeGenerator::CppDeclaration:
case CodeGenerator::CppTypedParamsWrapperDecl:
{
if (!m_stmt && !funcScope->isPerfectVirtual()) {
cg_printf("// ");
}
m_modifiers->outputCPP(cg, ar);
if (!m_stmt || m_name == "__offsetget_lval" ||
funcScope->isPerfectVirtual()) {
cg_printf("virtual ");
}
TypePtr type = funcScope->getReturnType();
if (type) {
type->outputCPPDecl(cg, ar);
} else {
cg_printf("void");
}
if (m_name == "__offsetget_lval") {
cg_printf(" &___offsetget_lval(");
} else if (m_modifiers->isStatic() && m_stmt) {
// Static method wrappers get generated as support methods
cg_printf(" %s%s(CStrRef cls%s",
needsWrapper && !isWrapper ?
Option::TypedMethodImplPrefix : Option::MethodImplPrefix,
cg.formatLabel(m_name).c_str(),
funcScope->isVariableArgument() ||
(m_params && m_params->getCount()) ? ", " : "");
} else {
cg_printf(" %s%s(", prefix, cg.formatLabel(m_name).c_str());
}
funcScope->outputCPPParamsDecl(cg, ar, m_params, true);
if (m_stmt) {
cg_printf(");\n");
} else if (funcScope->isPerfectVirtual()) {
cg_printf(") { return throw_fatal(\"pure virtual\");}\n");
} else {
cg_printf(") = 0;\n");
}
if (context != CodeGenerator::CppTypedParamsWrapperDecl) {
if (funcScope->isConstructor(scope)
&& !funcScope->isAbstract() && !scope->isInterface()) {
funcScope->outputCPPCreateDecl(cg, ar);
}
if (Option::HardTypeHints && funcScope->needsTypeCheckWrapper()) {
cg.setContext(CodeGenerator::CppTypedParamsWrapperDecl);
outputCPPImpl(cg, ar);
cg.setContext(context);
}
}
}
break;
case CodeGenerator::CppImplementation:
case CodeGenerator::CppTypedParamsWrapperImpl:
if (m_stmt) {
TypePtr type = funcScope->getReturnType();
if (type) {
type->outputCPPDecl(cg, ar);
} else {
cg_printf("void");
}
string origFuncName = getOriginalFullName();
string funcSection = Option::FunctionSections[origFuncName];
if (!funcSection.empty()) {
cg_printf(" __attribute__ ((section (\".text.%s\")))",
funcSection.c_str());
}
if (m_name == "__offsetget_lval") {
cg_printf(" &%s%s::___offsetget_lval(",
Option::ClassPrefix, scope->getId(cg).c_str());
} else if (m_modifiers->isStatic()) {
cg_printf(" %s%s::%s%s(CStrRef cls%s", Option::ClassPrefix,
scope->getId(cg).c_str(),
//.........这里部分代码省略.........