本文整理汇总了C++中FunctionScopePtr::isAbstract方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionScopePtr::isAbstract方法的具体用法?C++ FunctionScopePtr::isAbstract怎么用?C++ FunctionScopePtr::isAbstract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionScopePtr
的用法示例。
在下文中一共展示了FunctionScopePtr::isAbstract方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyzeProgram
void ObjectMethodExpression::analyzeProgram(AnalysisResultPtr ar) {
FunctionCall::analyzeProgram(ar);
m_object->analyzeProgram(ar);
if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
FunctionScopePtr func = m_funcScope;
if (!func && m_object->isThis() && !m_origName.empty()) {
ClassScopePtr cls = getClassScope();
if (cls) {
m_classScope = cls;
func = cls->findFunction(ar, m_origName, true, true);
if (func &&
!cls->isInterface() &&
!(func->isVirtual() &&
(func->isAbstract() ||
(func->hasOverride() &&
cls->getAttribute(ClassScope::NotFinal))))) {
m_funcScope = func;
func->addCaller(getScope());
}
}
}
markRefParams(func, m_origName);
}
}
示例2: checkParamsAndReturn
TypePtr FunctionCall::checkParamsAndReturn(AnalysisResultPtr ar,
TypePtr type, bool coerce,
FunctionScopePtr func) {
ConstructPtr self = shared_from_this();
ar->getDependencyGraph()->add(DependencyGraph::KindOfFunctionCall,
ar->getName(), getText(),
self, func->getFullName(), func->getStmt());
TypePtr frt = func->getReturnType();
if (!frt) {
m_voidReturn = true;
setActualType(TypePtr());
if (!type->is(Type::KindOfAny)) {
if (!m_allowVoidReturn && ar->isSecondPass() && !func->isAbstract()) {
ar->getCodeError()->record(self, CodeError::UseVoidReturn, self);
}
m_voidWrapper = true;
}
} else {
m_voidReturn = false;
m_voidWrapper = false;
type = checkTypesImpl(ar, type, frt, coerce);
}
m_extraArg = func->inferParamTypes(ar, self, m_params, m_valid);
m_variableArgument = func->isVariableArgument();
if (m_valid) {
m_implementedType.reset();
} else {
m_implementedType = Type::Variant;
}
return type;
}
示例3: checkParamsAndReturn
TypePtr FunctionCall::checkParamsAndReturn(AnalysisResultPtr ar,
TypePtr type, bool coerce,
FunctionScopePtr func,
bool arrayParams) {
ConstructPtr self = shared_from_this();
TypePtr frt = func->getReturnType();
if (!frt) {
m_voidReturn = true;
setActualType(TypePtr());
if (!type->is(Type::KindOfAny)) {
if (!m_allowVoidReturn && !func->isFirstPass() && !func->isAbstract()) {
Compiler::Error(Compiler::UseVoidReturn, self);
}
m_voidWrapper = true;
}
} else {
m_voidReturn = false;
m_voidWrapper = false;
type = checkTypesImpl(ar, type, frt, coerce);
}
if (arrayParams) {
m_extraArg = 0;
(*m_params)[0]->inferAndCheck(ar, Type::Array, false);
} else {
m_extraArg = func->inferParamTypes(ar, self, m_params, m_valid);
}
m_variableArgument = func->isVariableArgument();
if (m_valid) {
m_implementedType.reset();
} else {
m_implementedType = Type::Variant;
}
return type;
}
示例4: checkParamsAndReturn
TypePtr FunctionCall::checkParamsAndReturn(AnalysisResultPtr ar,
TypePtr type, bool coerce,
FunctionScopePtr func,
bool arrayParams) {
#ifdef HPHP_DETAILED_TYPE_INF_ASSERT
assert(func->hasUser(getScope(), BlockScope::UseKindCaller));
#endif /* HPHP_DETAILED_TYPE_INF_ASSERT */
ConstructPtr self = shared_from_this();
TypePtr frt;
{
TRY_LOCK(func);
func->getInferTypesMutex().assertOwnedBySelf();
assert(!func->inVisitScopes() || getScope() == func);
frt = func->getReturnType();
}
if (!frt) {
m_voidReturn = true;
setActualType(TypePtr());
if (!isUnused() && !type->is(Type::KindOfAny)) {
if (!hasContext(ReturnContext) &&
!func->isFirstPass() && !func->isAbstract()) {
if (Option::WholeProgram || !func->getContainingClass() ||
func->isStatic() || func->isFinal() || func->isPrivate()) {
Compiler::Error(Compiler::UseVoidReturn, self);
}
}
if (!Type::IsMappedToVariant(type)) {
setExpectedType(type);
}
m_voidWrapper = true;
}
} else {
m_voidReturn = false;
m_voidWrapper = false;
type = checkTypesImpl(ar, type, frt, coerce);
assert(m_actualType);
}
if (arrayParams) {
m_extraArg = 0;
(*m_params)[0]->inferAndCheck(ar, Type::Array, false);
} else {
m_extraArg = func->inferParamTypes(ar, self, m_params, m_valid);
}
m_variableArgument = func->isVariableArgument();
if (m_valid) {
m_implementedType.reset();
} else {
m_implementedType = Type::Variant;
}
assert(type);
return type;
}
示例5: analyzeProgram
void ObjectMethodExpression::analyzeProgram(AnalysisResultPtr ar) {
FunctionCall::analyzeProgram(ar);
m_object->analyzeProgram(ar);
if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
FunctionScopePtr func = m_funcScope;
if (!func && m_object->isThis() && !m_name.empty()) {
ClassScopePtr cls = getClassScope();
if (cls) {
m_classScope = cls;
func = cls->findFunction(ar, m_name, true, true);
if (func &&
!cls->isInterface() &&
!(func->isVirtual() &&
(func->isAbstract() ||
(func->hasOverride() &&
cls->getAttribute(ClassScope::NotFinal))) &&
!func->isPerfectVirtual())) {
m_funcScope = func;
func->addCaller(getScope());
}
}
}
markRefParams(func, m_name, canInvokeFewArgs());
}
// This is OK because AnalyzeFinal is guaranteed to run for a CPP
// target, regardless of opts (and we only need the following
// for CPP targets)
if (ar->getPhase() == AnalysisResult::AnalyzeFinal) {
// necessary because we set the expected type of m_object to
// Type::Some during type inference.
TypePtr at(m_object->getActualType());
TypePtr it(m_object->getImplementedType());
if (!m_object->isThis() && at && at->is(Type::KindOfObject)) {
if (at->isSpecificObject() && it && Type::IsMappedToVariant(it)) {
// fast-cast inference
ClassScopePtr scope(ar->findClass(at->getName()));
if (scope) {
// add a dependency to m_object's class type
// to allow the fast cast to succeed
addUserClass(ar, at->getName());
}
}
m_object->setExpectedType(at);
}
}
}
示例6: outputCPPImpl
//.........这里部分代码省略.........
}
}
string conInit = ":";
if (dyn) {
conInit += "DynamicObjectData(\"" + m_parent + "\", r)";
} else if (idyn) {
conInit += string(Option::ClassPrefix) + parCls->getId(cg) +
"(r?r:this)";
} else {
conInit += "root(r?r:this)";
}
cg_printf("%s%s(ObjectData* r = NULL)%s {}\n",
Option::ClassPrefix, clsName,
conInit.c_str());
}
}
cg_printf("void init();\n",
Option::ClassPrefix, clsName);
if (classScope->needLazyStaticInitializer()) {
cg_printf("static GlobalVariables *lazy_initializer"
"(GlobalVariables *g);\n");
}
classScope->getVariables()->outputCPPPropertyDecl(cg, ar,
classScope->derivesFromRedeclaring());
if (!classScope->getAttribute(ClassScope::HasConstructor)) {
FunctionScopePtr func = classScope->findFunction(ar, "__construct",
false);
if (func && !func->isAbstract() && !classScope->isInterface()) {
ar->pushScope(func);
func->outputCPPCreateDecl(cg, ar);
ar->popScope();
}
}
if (classScope->getAttribute(ClassScope::HasDestructor)) {
cg_printf("public: virtual void destruct();\n");
}
// doCall
if (classScope->getAttribute(ClassScope::HasUnknownMethodHandler)) {
cg_printf("Variant doCall(Variant v_name, Variant v_arguments, "
"bool fatal);\n");
}
// doGet
if (classScope->getAttribute(ClassScope::HasUnknownPropHandler)) {
cg_printf("Variant doGet(Variant v_name, bool error);\n");
}
if (classScope->isRedeclaring() &&
!classScope->derivesFromRedeclaring()) {
cg_printf("Variant doRootCall(Variant v_name, Variant v_arguments, "
"bool fatal);\n");
}
if (m_stmt) m_stmt->outputCPP(cg, ar);
{
set<string> done;
classScope->outputCPPStaticMethodWrappers(cg, ar, done, clsName);
}
示例7: outputCPPImpl
void MethodStatement::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
FunctionScopePtr funcScope = m_funcScope.lock();
ClassScopePtr scope = ar->getClassScope();
string origFuncName;
ar->pushScope(funcScope);
if (outputFFI(cg, ar)) return;
cg.setPHPLineNo(-1);
if (cg.getContext() == CodeGenerator::CppImplementation) {
printSource(cg);
}
switch (cg.getContext()) {
case CodeGenerator::CppDeclaration:
{
if (!m_stmt) {
cg.printf("// ");
}
m_modifiers->outputCPP(cg, ar);
if (m_name == "__offsetget_lval") {
cg.printf("virtual ");
}
TypePtr type = funcScope->getReturnType();
if (type) {
type->outputCPPDecl(cg, ar);
} else {
cg.printf("void");
}
if (m_name == "__lval") {
cg.printf(" &___lval(");
} else 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(const char* cls%s", Option::MethodImplPrefix,
m_name.c_str(),
funcScope->isVariableArgument() ||
(m_params && m_params->getCount()) ? ", " : "");
} else {
cg.printf(" %s%s(", Option::MethodPrefix, m_name.c_str());
}
funcScope->outputCPPParamsDecl(cg, ar, m_params, true);
if (m_stmt) {
cg.printf(");\n");
} else {
cg.printf(") = 0;\n");
}
if (funcScope->isConstructor(scope)
&& !funcScope->isAbstract() && !scope->isInterface()) {
funcScope->outputCPPCreateDecl(cg, ar);
}
}
break;
case CodeGenerator::CppImplementation:
if (m_stmt) {
TypePtr type = funcScope->getReturnType();
if (type) {
type->outputCPPDecl(cg, ar);
} else {
cg.printf("void");
}
origFuncName = std::string(scope->getOriginalName()) +
"::" + m_originalName;
if (Option::HotFunctions.find(origFuncName) !=
Option::HotFunctions.end()) {
cg.printf(" __attribute((__section__(\".text.hot\")))");
} else if (Option::ColdFunctions.find(origFuncName) !=
Option::ColdFunctions.end()) {
cg.printf(" __attribute((__section__(\".text.cold\")))");
}
if (m_name == "__lval") {
cg.printf(" &%s%s::___lval(",
Option::ClassPrefix, scope->getId().c_str());
} else if (m_name == "__offsetget_lval") {
cg.printf(" &%s%s::___offsetget_lval(",
Option::ClassPrefix, scope->getId().c_str());
} else if (m_modifiers->isStatic()) {
cg.printf(" %s%s::%s%s(const char* cls%s", Option::ClassPrefix,
scope->getId().c_str(),
Option::MethodImplPrefix, m_name.c_str(),
funcScope->isVariableArgument() ||
(m_params && m_params->getCount()) ? ", " : "");
} else {
cg.printf(" %s%s::%s%s(", Option::ClassPrefix, scope->getId().c_str(),
Option::MethodPrefix, m_name.c_str());
}
funcScope->outputCPPParamsDecl(cg, ar, m_params, false);
cg.indentBegin(") {\n");
if (m_modifiers->isStatic()) {
cg.printf("STATIC_METHOD_INJECTION(%s, %s::%s);\n",
scope->getOriginalName(), scope->getOriginalName(),
m_originalName.c_str());
} else {
cg.printf("INSTANCE_METHOD_INJECTION(%s, %s::%s);\n",
scope->getOriginalName(), scope->getOriginalName(),
m_originalName.c_str());
//.........这里部分代码省略.........
示例8: outputCPPImpl
//.........这里部分代码省略.........
"(r ? r : this)";
hasParam = true;
} else {
if (redec && classScope->derivedByDynamic()) {
conInit = " : root(r ? r : this)";
}
hasParam = true;
}
cg_indentBegin("%s%s(%s)%s {%s",
Option::ClassPrefix, clsName,
hasParam ? "ObjectData* r = NULL" : "",
conInit.c_str(),
hasGet || hasSet || hasCall || hasCallStatic ?
"\n" : "");
if (hasGet) cg_printf("setAttribute(UseGet);\n");
if (hasSet) cg_printf("setAttribute(UseSet);\n");
if (hasCall) cg_printf("setAttribute(HasCall);\n");
if (hasCallStatic) cg_printf("setAttribute(HasCallStatic);\n");
cg_indentEnd("}\n");
}
}
cg_printf("void init();\n");
if (classScope->needLazyStaticInitializer()) {
cg_printf("static GlobalVariables *lazy_initializer"
"(GlobalVariables *g);\n");
}
if (!classScope->getAttribute(ClassScope::HasConstructor)) {
FunctionScopePtr func = classScope->findFunction(ar, "__construct",
false);
if (func && !func->isAbstract() && !classScope->isInterface()) {
func->outputCPPCreateDecl(cg, ar);
}
}
if (classScope->getAttribute(ClassScope::HasDestructor)) {
cg_printf("public: virtual void destruct();\n");
}
// doCall
if (classScope->getAttribute(ClassScope::HasUnknownMethodHandler)) {
cg_printf("Variant doCall(Variant v_name, Variant v_arguments, "
"bool fatal);\n");
}
if (classScope->isRedeclaring() &&
!classScope->derivesFromRedeclaring() &&
classScope->derivedByDynamic()) {
cg_printf("Variant doRootCall(Variant v_name, Variant v_arguments, "
"bool fatal);\n");
}
if (m_stmt) m_stmt->outputCPP(cg, ar);
{
set<string> done;
classScope->outputCPPStaticMethodWrappers(cg, ar, done, clsName);
}
if (cg.getOutput() == CodeGenerator::SystemCPP &&
ar->isBaseSysRsrcClass(clsName) &&
!classScope->hasProperty("rsrc")) {
cg_printf("public: Variant %srsrc;\n", Option::PropertyPrefix);
}
if (Option::GenerateCPPMacros) {
示例9: 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(),
//.........这里部分代码省略.........
示例10: outputCPPImpl
//.........这里部分代码省略.........
if (disableDestructor) {
cg_printf("if (!hhvm) setAttribute(NoDestructor);\n");
}
cg_indentEnd("}\n");
hasEmitCppCtor = true;
}
if (needsCppCtor && !hasEmitCppCtor) {
cg_printf("%s%s() : ", Option::ClassPrefix, clsName);
cg.setContext(CodeGenerator::CppConstructor);
ASSERT(!cg.hasInitListFirstElem());
m_stmt->outputCPP(cg, ar);
cg.clearInitListFirstElem();
cg.setContext(CodeGenerator::CppDeclaration);
cg_printf(" {%s}\n",
disableDestructor ?
" if (!hhvm) setAttribute(NoDestructor); " : "");
}
if (needsInit) {
cg_printf("void init();\n");
}
// doCall
if (classScope->getAttribute(ClassScope::HasUnknownMethodHandler)) {
cg_printf("Variant doCall(Variant v_name, Variant v_arguments, "
"bool fatal);\n");
}
if (classScope->getAttribute(ClassScope::HasInvokeMethod)) {
FunctionScopePtr func =
classScope->findFunction(ar, "__invoke", false);
ASSERT(func);
if (!func->isAbstract()) {
cg_printf("const CallInfo *"
"t___invokeCallInfoHelper(void *&extra);\n");
}
}
if (classScope->isRedeclaring() &&
!classScope->derivesFromRedeclaring() &&
classScope->derivedByDynamic()) {
cg_printf("Variant doRootCall(Variant v_name, Variant v_arguments, "
"bool fatal);\n");
}
if (m_stmt) m_stmt->outputCPP(cg, ar);
{
std::set<string> done;
classScope->outputCPPStaticMethodWrappers(cg, ar, done, clsName);
}
if (Option::GenerateCPPMacros) {
classScope->outputCPPJumpTableDecl(cg, ar);
}
cg_indentEnd("};\n");
classScope->outputCPPDynamicClassDecl(cg);
if (m_stmt) {
cg.setContext(CodeGenerator::CppClassConstantsDecl);
m_stmt->outputCPP(cg, ar);
cg.setContext(CodeGenerator::CppDeclaration);
}
}
break;
case CodeGenerator::CppImplementation:
示例11: inferAndCheck
TypePtr ObjectMethodExpression::inferAndCheck(AnalysisResultPtr ar,
TypePtr type, bool coerce) {
assert(type);
IMPLEMENT_INFER_AND_CHECK_ASSERT(getScope());
resetTypes();
reset();
ConstructPtr self = shared_from_this();
TypePtr objectType = m_object->inferAndCheck(ar, Type::Some, false);
m_valid = true;
m_bindClass = true;
if (m_name.empty()) {
m_nameExp->inferAndCheck(ar, Type::Some, false);
setInvokeParams(ar);
// we have to use a variant to hold dynamic value
return checkTypesImpl(ar, type, Type::Variant, coerce);
}
ClassScopePtr cls;
if (objectType && !objectType->getName().empty()) {
if (m_classScope && !strcasecmp(objectType->getName().c_str(),
m_classScope->getName().c_str())) {
cls = m_classScope;
} else {
cls = ar->findExactClass(shared_from_this(), objectType->getName());
}
}
if (!cls) {
m_classScope.reset();
m_funcScope.reset();
m_valid = false;
setInvokeParams(ar);
return checkTypesImpl(ar, type, Type::Variant, coerce);
}
if (m_classScope != cls) {
m_classScope = cls;
m_funcScope.reset();
}
FunctionScopePtr func = m_funcScope;
if (!func) {
func = cls->findFunction(ar, m_name, true, true);
if (!func) {
if (!cls->isTrait() &&
!cls->getAttribute(ClassScope::MayHaveUnknownMethodHandler) &&
!cls->getAttribute(ClassScope::HasUnknownMethodHandler) &&
!cls->getAttribute(ClassScope::InheritsUnknownMethodHandler)) {
if (ar->classMemberExists(m_name, AnalysisResult::MethodName)) {
if (!Option::AllDynamic) {
setDynamicByIdentifier(ar, m_name);
}
} else {
Compiler::Error(Compiler::UnknownObjectMethod, self);
}
}
m_valid = false;
setInvokeParams(ar);
return checkTypesImpl(ar, type, Type::Variant, coerce);
}
m_funcScope = func;
func->addCaller(getScope(), !type->is(Type::KindOfAny));
}
bool valid = true;
m_bindClass = func->isStatic();
// use $this inside a static function
if (m_object->isThis()) {
FunctionScopePtr localfunc = getFunctionScope();
if (localfunc->isStatic()) {
if (getScope()->isFirstPass()) {
Compiler::Error(Compiler::MissingObjectContext, self);
}
valid = false;
}
}
// invoke() will return Variant
if (cls->isInterface() ||
(func->isVirtual() &&
(!Option::WholeProgram || func->isAbstract() ||
(func->hasOverride() && cls->getAttribute(ClassScope::NotFinal))) &&
!func->isPerfectVirtual())) {
valid = false;
}
if (!valid) {
setInvokeParams(ar);
checkTypesImpl(ar, type, Type::Variant, coerce);
m_valid = false; // so we use invoke() syntax
if (!Option::AllDynamic) {
func->setDynamic();
}
assert(m_actualType);
return m_actualType;
//.........这里部分代码省略.........
示例12: outputCPP
//.........这里部分代码省略.........
}
string conInit = ":";
if (dyn) {
conInit += "DynamicObjectData(\"" + m_parent + "\", r)";
} else if (idyn) {
conInit += string(Option::ClassPrefix) + parCls->getId() +
"(r?r:this)";
} else {
conInit += "root(r?r:this)";
}
cg.printf("%s%s(ObjectData* r = NULL)%s {}\n",
Option::ClassPrefix, clsName,
conInit.c_str());
}
}
cg.printf("void init();\n",
Option::ClassPrefix, clsName);
if (classScope->needLazyStaticInitializer()) {
cg.printf("static GlobalVariables *lazy_initializer"
"(GlobalVariables *g);\n");
}
if (!classScope->derivesFromRedeclaring()){
classScope->getVariables()->outputCPPPropertyDecl(cg, ar);
}
if (!classScope->getAttribute(ClassScope::HasConstructor)) {
FunctionScopePtr func = classScope->findFunction(ar, "__construct",
false);
if (func && !func->isAbstract() && !classScope->isInterface()) {
ar->pushScope(func);
func->outputCPPCreateDecl(cg, ar);
ar->popScope();
}
}
if (classScope->getAttribute(ClassScope::HasDestructor)) {
cg.printf("public: virtual void destruct();\n");
}
// doCall
if (classScope->getAttribute(ClassScope::HasUnknownMethodHandler)) {
cg.printf("Variant doCall(Variant v_name, Variant v_arguments, "
"bool fatal);\n");
}
if (m_stmt) m_stmt->outputCPP(cg, ar);
{
set<string> done;
classScope->outputCPPStaticMethodWrappers(cg, ar, done, clsName);
}
if (cg.getOutput() == CodeGenerator::SystemCPP &&
ar->isBaseSysRsrcClass(clsName) &&
!classScope->hasProperty("rsrc")) {
cg.printf("public: Variant %srsrc;\n", Option::PropertyPrefix);
}
cg.indentEnd("};\n");
if (redeclared) {
cg.indentBegin("class %s%s : public ClassStatics {\n",
Option::ClassStaticsPrefix, clsName);
示例13: checkParamsAndReturn
TypePtr FunctionCall::checkParamsAndReturn(AnalysisResultPtr ar,
TypePtr type, bool coerce,
FunctionScopePtr func,
bool arrayParams) {
#ifdef HPHP_DETAILED_TYPE_INF_ASSERT
assert(func->hasUser(getScope(), BlockScope::UseKindCaller));
#endif /* HPHP_DETAILED_TYPE_INF_ASSERT */
ConstructPtr self = shared_from_this();
TypePtr frt;
{
TRY_LOCK(func);
func->getInferTypesMutex().assertOwnedBySelf();
assert(!func->inVisitScopes() || getScope() == func);
frt = func->getReturnType();
}
// fix return type for generators and async functions here, keep the
// infered return type in function scope to allow further optimizations
if (func->isGenerator()) {
frt = Type::GetType(Type::KindOfObject, "Generator");
} else if (func->isAsync()) {
frt = Type::GetType(Type::KindOfObject, "WaitHandle");
}
m_voidUsed = false;
if (!frt) {
m_voidReturn = true;
setActualType(TypePtr());
if (!isUnused() && !type->is(Type::KindOfAny)) {
if (!hasContext(ReturnContext) &&
!func->isFirstPass() && !func->isAbstract()) {
if (Option::WholeProgram || !func->getContainingClass() ||
func->isStatic() || func->isFinal() || func->isPrivate()) {
m_voidUsed = true;
}
}
if (!Type::IsMappedToVariant(type)) {
setExpectedType(type);
}
}
} else {
m_voidReturn = false;
type = checkTypesImpl(ar, type, frt, coerce);
assert(m_actualType);
}
if (arrayParams) {
m_extraArg = 0;
(*m_params)[0]->inferAndCheck(ar, Type::Array, false);
} else {
m_extraArg = func->inferParamTypes(ar, self, m_params, m_valid);
}
m_variableArgument = func->allowsVariableArguments();
if (m_valid) {
m_implementedType.reset();
} else {
m_implementedType = Type::Variant;
}
assert(type);
return type;
}