本文整理汇总了C++中CodeGenerator::checkHoistedClass方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenerator::checkHoistedClass方法的具体用法?C++ CodeGenerator::checkHoistedClass怎么用?C++ CodeGenerator::checkHoistedClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator::checkHoistedClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputCPPImpl
void InterfaceStatement::outputCPPImpl(CodeGenerator &cg,
AnalysisResultPtr ar) {
ClassScopeRawPtr classScope = getClassScope();
if (cg.getContext() == CodeGenerator::NoContext) {
if (classScope->isVolatile()) {
const vector<string> &bases = classScope->getBases();
for (unsigned i = 0; i < bases.size(); ++i) {
const string &name = bases[i];
if (cg.checkHoistedClass(name) ||
classScope->hasKnownBase(i)) {
continue;
}
ClassScopePtr base = ar->findClass(name);
if (base && base->isVolatile()) {
cg_printf("checkClassExistsThrow(");
cg_printString(name, ar, shared_from_this());
cg_printf(", &%s->CDEC(%s));\n",
cg.getGlobals(ar),
CodeGenerator::FormatLabel(base->getName()).c_str());
}
}
classScope->outputCPPDef(cg);
cg.addHoistedClass(m_name);
}
return;
}
string clsNameStr = classScope->getId();
const char *clsName = clsNameStr.c_str();
switch (cg.getContext()) {
case CodeGenerator::CppDeclaration:
{
printSource(cg);
if (Option::GenerateCPPMacros) {
classScope->outputForwardDeclaration(cg);
}
if (classScope->isRedeclaring()) {
classScope->outputCPPGlobalTableWrappersDecl(cg, ar);
}
cg_printf("class %s%s", Option::ClassPrefix, clsName);
if (m_base && Option::UseVirtualDispatch &&
!classScope->isRedeclaring()) {
const char *sep = " :";
for (int i = 0; i < m_base->getCount(); i++) {
ScalarExpressionPtr exp =
dynamic_pointer_cast<ScalarExpression>((*m_base)[i]);
const char *intf = exp->getString().c_str();
ClassScopePtr intfClassScope = ar->findClass(intf);
if (intfClassScope && !intfClassScope->isRedeclaring() &&
classScope->derivesDirectlyFrom(intf)) {
string id = intfClassScope->getId();
cg_printf("%s public %s%s", sep, Option::ClassPrefix, id.c_str());
sep = ",";
}
}
}
cg_indentBegin(" {\n");
if (m_stmt) m_stmt->outputCPP(cg, ar);
bool hasPropTable = classScope->checkHasPropTable(ar);
if (hasPropTable) {
cg_printf("public: static const ClassPropTable %sprop_table;\n",
Option::ObjectStaticPrefix);
}
cg_indentEnd("};\n");
if (hasPropTable) {
classScope->outputCPPGlobalTableWrappersDecl(cg, ar);
}
if (m_stmt) {
cg.setContext(CodeGenerator::CppClassConstantsDecl);
m_stmt->outputCPP(cg, ar);
cg.setContext(CodeGenerator::CppDeclaration);
}
}
break;
case CodeGenerator::CppImplementation:
{
if (m_stmt) {
cg.setContext(CodeGenerator::CppClassConstantsImpl);
m_stmt->outputCPP(cg, ar);
cg.setContext(CodeGenerator::CppImplementation);
}
cg.addClass(getClassScope()->getName(), getClassScope());
if (classScope->isRedeclaring() || classScope->checkHasPropTable(ar)) {
classScope->outputCPPGlobalTableWrappersImpl(cg, ar);
}
}
break;
case CodeGenerator::CppFFIDecl:
case CodeGenerator::CppFFIImpl:
// do nothing
break;
case CodeGenerator::JavaFFI:
{
// TODO support PHP namespaces, once HPHP supports it
string packageName = Option::JavaFFIRootPackage;
//.........这里部分代码省略.........
示例2: outputCPPImpl
void ClassStatement::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
ClassScopeRawPtr classScope = getClassScope();
if (cg.getContext() == CodeGenerator::NoContext) {
if (classScope->isVolatile()) {
string name = cg.formatLabel(m_name);
if (classScope->isRedeclaring()) {
cg_printf("g->%s%s = ClassStaticsPtr(NEWOBJ(%s%s)());\n",
Option::ClassStaticsObjectPrefix,
name.c_str(),
Option::ClassStaticsPrefix, classScope->getId(cg).c_str());
cg_printf("g->%s%s = &%s%s;\n",
Option::ClassStaticsCallbackPrefix,
name.c_str(),
Option::ClassWrapperFunctionPrefix,
classScope->getId(cg).c_str());
}
cg_printf("g->CDEC(%s) = true;\n", name.c_str());
const vector<string> &bases = classScope->getBases();
for (vector<string>::const_iterator it = bases.begin();
it != bases.end(); ++it) {
if (cg.checkHoistedClass(*it)) continue;
ClassScopePtr base = ar->findClass(*it);
if (base && base->isVolatile()) {
cg_printf("checkClassExists(");
cg_printString(base->getOriginalName(), ar, shared_from_this());
string lname = Util::toLower(base->getOriginalName());
cg_printf(", &%s->CDEC(%s), %s->FVF(__autoload));\n",
cg.getGlobals(ar), cg.formatLabel(lname).c_str(),
cg.getGlobals(ar));
}
}
}
return;
}
if (cg.getContext() != CodeGenerator::CppForwardDeclaration) {
printSource(cg);
}
string clsNameStr = classScope->getId(cg);
const char *clsName = clsNameStr.c_str();
bool redeclared = classScope->isRedeclaring();
switch (cg.getContext()) {
case CodeGenerator::CppDeclaration:
{
if (Option::GenerateCPPMacros) {
classScope->outputForwardDeclaration(cg);
}
bool system = cg.getOutput() == CodeGenerator::SystemCPP;
ClassScopePtr parCls;
if (!m_parent.empty()) {
parCls = ar->findClass(m_parent);
if (parCls && parCls->isRedeclaring()) parCls.reset();
}
if (Option::GenerateCppLibCode) {
cg.printDocComment(classScope->getDocComment());
}
cg_printf("class %s%s", Option::ClassPrefix, clsName);
if (!m_parent.empty() && classScope->derivesDirectlyFrom(m_parent)) {
if (!parCls) {
cg_printf(" : public DynamicObjectData");
} else {
cg_printf(" : public %s%s", Option::ClassPrefix,
parCls->getId(cg).c_str());
}
} else {
if (classScope->derivesFromRedeclaring()) {
cg_printf(" : public DynamicObjectData");
} else if (system) {
cg_printf(" : public ExtObjectData");
} else {
cg_printf(" : public ObjectData");
}
}
if (m_base && Option::UseVirtualDispatch) {
for (int i = 0; i < m_base->getCount(); i++) {
ScalarExpressionPtr exp =
dynamic_pointer_cast<ScalarExpression>((*m_base)[i]);
const char *intf = exp->getString().c_str();
ClassScopePtr intfClassScope = ar->findClass(intf);
if (intfClassScope && !intfClassScope->isRedeclaring() &&
classScope->derivesDirectlyFrom(intf) &&
(!parCls || !parCls->derivesFrom(ar, intf, true, false))) {
string id = intfClassScope->getId(cg);
cg_printf(", public %s%s", Option::ClassPrefix, id.c_str());
}
}
}
cg_indentBegin(" {\n");
cg_printf("public:\n");
cg.printSection("Properties");
classScope->getVariables()->outputCPPPropertyDecl(cg, ar,
classScope->derivesFromRedeclaring());
if (Option::GenerateCppLibCode) {
cg.printSection("Methods");
classScope->outputMethodWrappers(cg, ar);
//.........这里部分代码省略.........
示例3: outputCPPImpl
void ClassStatement::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
ClassScopeRawPtr classScope = getClassScope();
if (cg.getContext() == CodeGenerator::NoContext) {
if (classScope->isVolatile()) {
string name = CodeGenerator::FormatLabel(m_name);
if (classScope->isRedeclaring()) {
cg_printf("g->%s%s = &%s%s;\n",
Option::ClassStaticsCallbackPrefix,
name.c_str(),
Option::ClassStaticsCallbackPrefix,
classScope->getId().c_str());
}
cg_printf("g->CDEC(%s) = true;\n", name.c_str());
cg.addHoistedClass(name);
const vector<string> &bases = classScope->getBases();
for (vector<string>::const_iterator it = bases.begin();
it != bases.end(); ++it) {
if (cg.checkHoistedClass(*it)) continue;
ClassScopePtr base = ar->findClass(*it);
if (base && base->isVolatile()) {
cg_printf("checkClassExistsThrow(");
cg_printString(*it, ar, shared_from_this());
string lname = Util::toLower(*it);
cg_printf(", &%s->CDEC(%s));\n",
cg.getGlobals(ar),
CodeGenerator::FormatLabel(lname).c_str());
}
}
}
return;
}
if (cg.getContext() != CodeGenerator::CppForwardDeclaration) {
printSource(cg);
}
string clsNameStr = classScope->getId();
const char *clsName = clsNameStr.c_str();
switch (cg.getContext()) {
case CodeGenerator::CppDeclaration:
{
if (Option::GenerateCPPMacros) {
classScope->outputForwardDeclaration(cg);
}
classScope->outputCPPGlobalTableWrappersDecl(cg, ar);
bool system = cg.getOutput() == CodeGenerator::SystemCPP;
ClassScopePtr parCls;
if (!m_parent.empty()) {
parCls = ar->findClass(m_parent);
if (parCls && parCls->isRedeclaring()) parCls.reset();
}
if (Option::GenerateCppLibCode) {
cg.printDocComment(classScope->getDocComment());
}
cg_printf("class %s%s", Option::ClassPrefix, clsName);
if (!m_parent.empty() && classScope->derivesDirectlyFrom(m_parent)) {
if (!parCls) {
cg_printf(" : public DynamicObjectData");
} else {
cg_printf(" : public %s%s", Option::ClassPrefix,
parCls->getId().c_str());
}
} else {
if (classScope->derivesFromRedeclaring()) {
cg_printf(" : public DynamicObjectData");
} else if (system) {
cg_printf(" : public ExtObjectData");
} else {
cg_printf(" : public ObjectData");
}
}
if (m_base && Option::UseVirtualDispatch) {
for (int i = 0; i < m_base->getCount(); i++) {
ScalarExpressionPtr exp =
dynamic_pointer_cast<ScalarExpression>((*m_base)[i]);
const char *intf = exp->getString().c_str();
ClassScopePtr intfClassScope = ar->findClass(intf);
if (intfClassScope && !intfClassScope->isRedeclaring() &&
classScope->derivesDirectlyFrom(intf) &&
(!parCls || !parCls->derivesFrom(ar, intf, true, false))) {
string id = intfClassScope->getId();
cg_printf(", public %s%s", Option::ClassPrefix, id.c_str());
}
}
}
cg_indentBegin(" {\n");
cg_printf("public:\n");
cg.printSection("Properties");
classScope->getVariables()->outputCPPPropertyDecl(cg, ar,
classScope->derivesFromRedeclaring());
if (Option::GenerateCppLibCode) {
cg.printSection("Methods");
classScope->outputMethodWrappers(cg, ar);
cg.printSection(">>>>>>>>>> Internal Implementation <<<<<<<<<<");
cg_printf("// NOTE: Anything below is subject to change. "
//.........这里部分代码省略.........