当前位置: 首页>>代码示例>>C++>>正文


C++ CodeGenerator::getOutput方法代码示例

本文整理汇总了C++中CodeGenerator::getOutput方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenerator::getOutput方法的具体用法?C++ CodeGenerator::getOutput怎么用?C++ CodeGenerator::getOutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeGenerator的用法示例。


在下文中一共展示了CodeGenerator::getOutput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: outputPHP

void SimpleFunctionCall::outputPHP(CodeGenerator &cg, AnalysisResultPtr ar) {
  outputLineMap(cg, ar);

  if (!m_className.empty()) {
    cg.printf("%s::%s(", m_className.c_str(), m_name.c_str());
  } else {

    if (cg.getOutput() == CodeGenerator::InlinedPHP ||
        cg.getOutput() == CodeGenerator::TrimmedPHP) {

      if (cg.getOutput() == CodeGenerator::TrimmedPHP &&
          cg.usingStream(CodeGenerator::PrimaryStream) &&
          Option::DynamicFunctionCalls.find(m_name) !=
          Option::DynamicFunctionCalls.end()) {
        int funcNamePos = Option::DynamicFunctionCalls[m_name];
        if (m_params && m_params->getCount() &&
            m_params->getCount() >= funcNamePos + 1) {
          if (funcNamePos == -1) funcNamePos = m_params->getCount() - 1;
          ExpressionPtr funcName = (*m_params)[funcNamePos];
          if (!funcName->is(Expression::KindOfScalarExpression)) {

            cg.printf("%s(", m_name.c_str());
            for (int i = 0; i < m_params->getCount(); i++) {
              if (i > 0) cg.printf(", ");
              if (i == funcNamePos) {
                cg.printf("%sdynamic_load(", Option::IdPrefix.c_str());
                funcName->outputPHP(cg, ar);
                cg.printf(")");
              } else {
                ExpressionPtr param = (*m_params)[i];
                if (param) param->outputPHP(cg, ar);
              }
            }
            cg.printf(")");
            return;
          }
        }
      }
      /* simptodo: I dunno
      if (m_type == RenderTemplateFunction && !m_template.empty()) {
        cg.printf("%s_%s(", m_name.c_str(),
                  Util::getIdentifier(m_template).c_str());
      } else if (m_type == RenderTemplateIncludeFunction) {
        string templateName = ar->getProgram()->getCurrentTemplate();
        cg.printf("%s_%s(", m_name.c_str(),
                  Util::getIdentifier(templateName).c_str());
      } else {
      */
        cg.printf("%s(", m_name.c_str());
        //}

    } else {
      cg.printf("%s(", m_name.c_str());
    }
  }

  if (m_params) m_params->outputPHP(cg, ar);
  cg.printf(")");
}
开发者ID:scottmac,项目名称:hiphop-dev,代码行数:59,代码来源:simple_function_call.cpp

示例2: outputCPPArrayCreate

bool ExpressionList::outputCPPArrayCreate(CodeGenerator &cg,
                                          AnalysisResultPtr ar,
                                          bool isVector,
                                          bool pre) {
  ASSERT(pre == !m_cppTemp.empty());
  if (!Option::GenArrayCreate || cg.getOutput() == CodeGenerator::SystemCPP) {
    return false;
  }
  if (hasNonArrayCreateValue()) return false;

  unsigned int n = isVector ? m_exps.size() : 0;
  bool uniqLitstrKeys = false;
  if (isVector) {
    n = m_exps.size();
  } else {
    n = checkLitstrKeys();
    if (n > 0 && n == m_exps.size()) uniqLitstrKeys = true;
  }
  if (isVector) {
    if (ar->m_arrayIntegerKeyMaxSize < (int)n) ar->m_arrayIntegerKeyMaxSize = n;
  } else if (uniqLitstrKeys) {
    if (ar->m_arrayLitstrKeyMaxSize < (int)n) ar->m_arrayLitstrKeyMaxSize = n;
  } else {
    return false;
  }
  if (pre) {
    Expression::preOutputCPP(cg, ar, StashKidVars);
    cg_printf("ArrayInit %s(", m_cppTemp.c_str());
    outputCPPUniqLitKeyArrayInit(cg, ar, uniqLitstrKeys, n);
    cg_printf(");\n");
  } else {
    outputCPPUniqLitKeyArrayInit(cg, ar, uniqLitstrKeys, n);
  }
  return true;
}
开发者ID:DenisBazhan,项目名称:hiphop-php,代码行数:35,代码来源:expression_list.cpp

示例3: outputPHP

///////////////////////////////////////////////////////////////////////////////
// code generation functions
void DynamicFunctionCall::outputPHP(CodeGenerator &cg, AnalysisResultPtr ar) {
  outputLineMap(cg, ar);

  if (m_class || !m_className.empty()) {
    StaticClassName::outputPHP(cg, ar);
    cg_printf("::");
    m_nameExp->outputPHP(cg, ar);
  } else {
    const char *prefix = Option::IdPrefix.c_str();
    if (cg.getOutput() == CodeGenerator::TrimmedPHP &&
        cg.usingStream(CodeGenerator::PrimaryStream) &&
        !m_nameExp->is(Expression::KindOfScalarExpression)) {
      cg_printf("${%sdynamic_load($%stmp = (", prefix, prefix);
      m_nameExp->outputPHP(cg, ar);
      cg_printf("), '%stmp'", prefix);
      cg_printf(")}");
    } else {
      m_nameExp->outputPHP(cg, ar);
    }
  }

  cg_printf("(");
  if (m_params) m_params->outputPHP(cg, ar);
  cg_printf(")");
}
开发者ID:eliotsolomon,项目名称:hiphop-php,代码行数:27,代码来源:dynamic_function_call.cpp

示例4: outputCPPArguments

void FunctionScope::outputCPPArguments(ExpressionListPtr params,
                                       CodeGenerator &cg,
                                       AnalysisResultPtr ar, int extraArg,
                                       bool variableArgument,
                                       int extraArgArrayId /* = -1 */) {
  int paramCount = params ? params->getOutputCount() : 0;
  ASSERT(extraArg <= paramCount);
  int iMax = paramCount - extraArg;
  bool extra = false;

  if (variableArgument) {
    if (paramCount == 0) {
      cg.printf("0");
    } else {
      cg.printf("%d, ", paramCount);
    }
  }
  int firstExtra = 0;
  for (int i = 0; i < paramCount; i++) {
    ExpressionPtr param = (*params)[i];
    cg.setItemIndex(i);
    if (i > 0) cg.printf(extra ? "." : ", ");
    if (!extra && (i == iMax || extraArg < 0)) {
      if (extraArgArrayId != -1) {
        if (cg.getOutput() == CodeGenerator::SystemCPP) {
          cg.printf("SystemScalarArrays::%s[%d]",
                    Option::SystemScalarArrayName, extraArgArrayId);
        } else {
          cg.printf("ScalarArrays::%s[%d]",
                    Option::ScalarArrayName, extraArgArrayId);
        }
        break;
      }
      extra = true;
      // Parameter arrays are always vectors.
      cg.printf("Array(ArrayInit(%d, true).", paramCount - i);
      firstExtra = i;
    }
    if (extra) {
      bool needRef = param->hasContext(Expression::RefValue) &&
                     !param->hasContext(Expression::NoRefWrapper) &&
                     param->isRefable();
      cg.printf("set%s(%d, ", needRef ? "Ref" : "", i - firstExtra);
      if (needRef) {
        // The parameter itself shouldn't be wrapped with ref() any more.
        param->setContext(Expression::NoRefWrapper);
      }
      param->outputCPP(cg, ar);
      cg.printf(")");
    } else {
      param->outputCPP(cg, ar);
    }
  }
  if (extra) {
    cg.printf(".create())");
  }
}
开发者ID:yigithub,项目名称:hiphop-php,代码行数:57,代码来源:function_scope.cpp

示例5: outputCPP

void ConstantTable::outputCPP(CodeGenerator &cg, AnalysisResultPtr ar) {
  bool decl = true;
  if (cg.getContext() == CodeGenerator::CppConstantsDecl) {
    decl = false;
  }

  bool printed = false;
  for (StringToSymbolMap::iterator iter = m_symbolMap.begin(),
         end = m_symbolMap.end(); iter != end; ++iter) {
    Symbol *sym = &iter->second;
    if (!sym->declarationSet() || sym->isDynamic()) continue;
    if (sym->isSystem() && cg.getOutput() != CodeGenerator::SystemCPP) continue;
    const string &name = sym->getName();
    ConstructPtr value = sym->getValue();
    printed = true;

    cg_printf(decl ? "extern const " : "const ");
    TypePtr type = sym->getFinalType();
    bool isString = type->is(Type::KindOfString);
    if (isString) {
      cg_printf("StaticString");
    } else {
      type->outputCPPDecl(cg, ar);
    }
    if (decl) {
      cg_printf(" %s%s", Option::ConstantPrefix,
                cg.formatLabel(name).c_str());
    } else {
      cg_printf(" %s%s", Option::ConstantPrefix,
                cg.formatLabel(name).c_str());
      cg_printf(isString ? "(" : " = ");
      if (value) {
        ExpressionPtr exp = dynamic_pointer_cast<Expression>(value);
        ASSERT(!exp->getExpectedType());
        ScalarExpressionPtr scalarExp =
          dynamic_pointer_cast<ScalarExpression>(exp);
        if (isString && scalarExp) {
          cg_printf("LITSTR_INIT(%s)",
                    scalarExp->getCPPLiteralString(cg).c_str());
        } else {
          exp->outputCPP(cg, ar);
        }
      } else {
        cg_printf("\"%s\"", cg.escapeLabel(name).c_str());
      }
      if (isString) {
        cg_printf(")");
      }
    }
    cg_printf(";\n");
  }
  if (printed) {
    cg_printf("\n");
  }
}
开发者ID:F4m3uS,项目名称:hiphop-php,代码行数:55,代码来源:constant_table.cpp

示例6: outputPHP

void InterfaceStatement::outputPHP(CodeGenerator &cg, AnalysisResultPtr ar) {
    ClassScopeRawPtr classScope = getClassScope();

    if (cg.getOutput() == CodeGenerator::InlinedPHP ||
            cg.getOutput() == CodeGenerator::TrimmedPHP) {
        if (!classScope->isUserClass()) {
            return;
        }
    }

    cg_printf("interface %s", m_originalName.c_str());
    if (m_base) {
        cg_printf(" extends ");
        m_base->outputPHP(cg, ar);
    }
    cg_indentBegin(" {\n");
    classScope->outputPHP(cg, ar);
    if (m_stmt) m_stmt->outputPHP(cg, ar);
    cg_indentEnd("}\n");
}
开发者ID:jaggedsoft,项目名称:hhvm,代码行数:20,代码来源:interface_statement.cpp

示例7: outputCPPCreateImpl

void FunctionScope::outputCPPCreateImpl(CodeGenerator &cg,
                                        AnalysisResultPtr ar) {
  ClassScopePtr scope = ar->getClassScope();
  string clsNameStr = scope->getId(cg);
  const char *clsName = clsNameStr.c_str();
  const char *consName = scope->classNameCtor() ? scope->getName().c_str()
                                                : "__construct";

  cg_printf("%s%s *%s%s::create(",
            Option::ClassPrefix, clsName, Option::ClassPrefix, clsName);
  outputCPPParamsImpl(cg, ar);
  cg_indentBegin(") {\n");
  cg_printf("CountableHelper h(this);\n");
  cg_printf("init();\n");
  cg_printf("%s%s(", Option::MethodPrefix, consName);
  outputCPPParamsCall(cg, ar, false);
  cg_printf(");\n");
  cg_printf("return this;\n");
  cg_indentEnd("}\n");
  cg_indentBegin("ObjectData *%s%s::dynCreate(CArrRef params, "
                 "bool construct /* = true */) {\n",
                 Option::ClassPrefix, clsName);
  cg_printf("init();\n");
  cg_indentBegin("if (construct) {\n");
  cg_printf("CountableHelper h(this);\n");
  OutputCPPDynamicInvokeCount(cg);
  outputCPPDynamicInvoke(cg, ar, Option::MethodPrefix,
                         cg.formatLabel(consName).c_str(),
                         true, false, false, NULL, true);
  cg_indentEnd("}\n");
  cg_printf("return this;\n");
  cg_indentEnd("}\n");
  if (isDynamic() || isSepExtension()) {
    cg_indentBegin("void %s%s::dynConstruct(CArrRef params) {\n",
                   Option::ClassPrefix, clsName);
    OutputCPPDynamicInvokeCount(cg);
    outputCPPDynamicInvoke(cg, ar, Option::MethodPrefix,
                           cg.formatLabel(consName).c_str(),
                           true, false, false, NULL, true);
    cg_indentEnd("}\n");
    if (cg.getOutput() == CodeGenerator::SystemCPP ||
        Option::EnableEval >= Option::LimitedEval) {
      cg_indentBegin("void %s%s::dynConstructFromEval("
                     "Eval::VariableEnvironment &env, "
                     "const Eval::FunctionCallExpression *caller) {\n",
                     Option::ClassPrefix, clsName);
      outputCPPEvalInvoke(cg, ar, Option::MethodPrefix,
                          cg.formatLabel(consName).c_str(), NULL, false);
      cg_indentEnd("}\n");
    }
  }
}
开发者ID:param108,项目名称:hiphop-php,代码行数:52,代码来源:function_scope.cpp

示例8: outputCPPJumpTable

void ConstantTable::outputCPPJumpTable(CodeGenerator &cg,
                                       AnalysisResultPtr ar,
                                       bool needsGlobals,
                                       bool ret) {
  bool system = cg.getOutput() == CodeGenerator::SystemCPP;
  vector<const char *> strings;
  if (!m_symbolVec.empty()) {
    strings.reserve(m_symbolVec.size());
    BOOST_FOREACH(Symbol *sym, m_symbolVec) {
      // Extension defined constants have no value but we are sure they exist
      if (!system && !sym->getValue()) continue;
      strings.push_back(sym->getName().c_str());
    }
  }
开发者ID:F4m3uS,项目名称:hiphop-php,代码行数:14,代码来源:constant_table.cpp

示例9: outputCPPJumpTable

void ConstantTable::outputCPPJumpTable(CodeGenerator &cg,
                                       AnalysisResultPtr ar,
                                       bool ret /* = true */) {
  bool system = cg.getOutput() == CodeGenerator::SystemCPP;
  bool hasDynamic = m_dynamic.size() > 0;
  vector<const char *> strings;
  if (!m_symbols.empty()) {
    strings.reserve(m_symbols.size());
    BOOST_FOREACH(string s, m_symbols) {
      // Extension defined constants have no value but we are sure they exist
      if (!system && !getValue(s)) continue;
      strings.push_back(s.c_str());
    }
  }
开发者ID:Neomeng,项目名称:hiphop-php,代码行数:14,代码来源:constant_table.cpp

示例10: outputCPPImpl

void IncludeExpression::outputCPPImpl(CodeGenerator &cg,
                                      AnalysisResultPtr ar) {
  bool linemap = outputLineMap(cg, ar, true);

  // Includes aren't really supported in system mode
  if (cg.getOutput() == CodeGenerator::SystemCPP) {
    cg_printf("true");
    if (linemap) cg_printf(")");
    return;
  }
  const char *vars = m_privateScope ?
    "lvar_ptr(LVariableTable())" : "variables";
  bool require = (m_op == T_REQUIRE || m_op == T_REQUIRE_ONCE);
  bool once = (m_op == T_INCLUDE_ONCE || m_op == T_REQUIRE_ONCE);
  if (!getCurrentInclude(ar).empty()) {
    FileScopePtr fs = ar->findFileScope(getCurrentInclude(ar), false);
    if (fs) {
      cg_printf("%s%s(%s, %s)", Option::PseudoMainPrefix,
                fs->pseudoMainName().c_str(),
                once ? "true" : "false",
                vars);
      if (linemap) cg_printf(")");
      return;
    }
  }

  // include() and require() need containing file's directory
  string currentDir = "NULL";
  if (m_loc && m_loc->file && *m_loc->file) {
    string file = m_loc->file;
    size_t pos = file.rfind('/');
    if (pos != string::npos) {
      currentDir = '"';
      currentDir += file.substr(0, pos + 1);
      currentDir += '"';
    }
  }

  // fallback to dynamic include
  cg_printf("%s(", require ? "require" : "include");
  m_exp->outputCPP(cg, ar);
  cg_printf(", %s, %s, %s)",
            once ? "true" : "false",
            vars,
            currentDir.c_str());
  if (linemap) cg_printf(")");
}
开发者ID:GunioRobot,项目名称:hiphop-php,代码行数:47,代码来源:include_expression.cpp

示例11: outputCPPArgInjections

void MethodStatement::outputCPPArgInjections(CodeGenerator &cg,
                                             AnalysisResultPtr ar,
                                             const char *name,
                                             ClassScopePtr cls,
                                             FunctionScopePtr funcScope) {
  if (cg.getOutput() != CodeGenerator::SystemCPP) {
    if (m_params) {
      int n = m_params->getCount();
      cg_printf("INTERCEPT_INJECTION(\"%s\", ", name);
      if (Option::GenArrayCreate && !hasRefParam()) {
        ar->m_arrayIntegerKeySizes.insert(n);
        outputParamArrayCreate(cg, true);
        cg_printf(", %s);\n", funcScope->isRefReturn() ? "ref(r)" : "r");
      } else {
        cg_printf("(Array(ArrayInit(%d, true)", n);
        for (int i = 0; i < n; i++) {
          ParameterExpressionPtr param =
            dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
          const string &paramName = param->getName();
          cg_printf(".set%s(%d, %s%s)", param->isRef() ? "Ref" : "",
                    i, Option::VariablePrefix, paramName.c_str());
        }
        cg_printf(".create())), %s);\n",
                  funcScope->isRefReturn() ? "ref(r)" : "r");
      }
    } else {
      cg_printf("INTERCEPT_INJECTION(\"%s\", null_array, %s);\n",
                name, funcScope->isRefReturn() ? "ref(r)" : "r");
    }
  }

  if (Option::GenRTTIProfileData && m_params) {
    for (int i = 0; i < m_params->getCount(); i++) {
      ParameterExpressionPtr param =
        dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
      if (param->hasRTTI()) {
        const string &paramName = param->getName();
        int id = ar->getParamRTTIEntryId(cls, funcScope, paramName);
        if (id != -1) {
          cg_printf("RTTI_INJECTION(%s%s, %d);\n",
                    Option::VariablePrefix, paramName.c_str(), id);
        }
      }
    }
  }
}
开发者ID:oxromantic,项目名称:hiphop-php,代码行数:46,代码来源:method_statement.cpp

示例12: outputCPPArrayCreate

bool ExpressionList::outputCPPArrayCreate(CodeGenerator &cg,
                                          AnalysisResultPtr ar,
                                          bool isVector,
                                          bool pre) {
  ASSERT(pre == !m_cppTemp.empty());
  if (!Option::GenArrayCreate || cg.getOutput() == CodeGenerator::SystemCPP) {
    return false;
  }
  if (hasNonArrayCreateValue()) return false;

  int64 max = m_exps.size();
  unsigned int n = isVector ? m_exps.size() : checkIntegerKeys(max);
  bool uniqIntegerKeys = false;
  bool uniqLitstrKeys = false;
  if (n > 0 && n == m_exps.size()) {
    uniqIntegerKeys = true;
  } else if (!isVector) {
    n = checkLitstrKeys();
    if (n > 0 && n == m_exps.size()) uniqLitstrKeys = true;
  }
  if (uniqIntegerKeys) {
    ar->m_arrayIntegerKeySizes.insert(n);
  } else if (uniqLitstrKeys) {
    ar->m_arrayLitstrKeySizes.insert(n);
  } else {
    return false;
  }

  if (pre) {
    for (unsigned i = 0; i < m_exps.size(); i++) {
      if (ExpressionPtr exp = m_exps[i]) {
        exp->preOutputCPP(cg, ar, 0);
      }
    }
    cg_printf("ArrayInit %s(", m_cppTemp.c_str());
    outputCPPUniqLitKeyArrayInit(cg, ar, uniqIntegerKeys ? max : 0);
    cg_printf(");\n");
  } else if (uniqIntegerKeys) {
    outputCPPUniqLitKeyArrayInit(cg, ar, max);
  } else {
    outputCPPUniqLitKeyArrayInit(cg, ar, 0);
  }
  return true;
}
开发者ID:eliotsolomon,项目名称:hiphop-php,代码行数:44,代码来源:expression_list.cpp

示例13: outputCPPImpl

void ReturnStatement::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
  bool braced = false;
  FunctionScopePtr func = getFunctionScope();
  ClassScopePtr cls = getClassScope();
  if (func->isConstructor(cls)) {
    cg_indentBegin("{\n"); braced = true;
    cg_printf("gasInCtor(oldInCtor);\n");
  }
  if (m_exp) {
    if (m_exp->hasContext(Expression::RefValue)) {
      m_exp->setContext(Expression::NoRefWrapper);
    }
    m_exp->outputCPPBegin(cg, ar);
  }

  cg_printf("return");
  if (m_exp) {
    bool close = false;
    cg_printf(" ");
    if (m_exp->hasContext(Expression::RefValue) && m_exp->isRefable()) {
      cg_printf("strongBind(");
      close = true;
    } else if (checkCopyElision(func, m_exp)) {
      cg_printf("wrap_variant(");
      close = true;
    }
    m_exp->outputCPP(cg, ar);
    if (close) cg_printf(")");
    cg_printf(";\n");
    cg.setReferenceTempUsed(false);
    m_exp->outputCPPEnd(cg, ar);
  } else if (func &&
             !(func->inPseudoMain() && !Option::GenerateCPPMain &&
               cg.getOutput() != CodeGenerator::SystemCPP)) {
    TypePtr type = func->getReturnType();
    if (type) {
      const char *initializer = type->getCPPInitializer();
      cg_printf(" %s", initializer ? initializer : "null");
    }
    cg_printf(";\n");
  }

  if (braced) cg_indentEnd("}\n");
}
开发者ID:SimplProduction,项目名称:hiphop-php,代码行数:44,代码来源:return_statement.cpp

示例14: outputCPP

void ConstantTable::outputCPP(CodeGenerator &cg, AnalysisResultPtr ar) {
  bool decl = true;
  if (cg.getContext() == CodeGenerator::CppConstantsDecl) {
    decl = false;
  }

  bool printed = false;
  for (StringToConstructPtrMap::const_iterator iter = m_declarations.begin();
       iter != m_declarations.end(); ++iter) {
    const string &name = iter->first;
    if (isSystem(name) && cg.getOutput() != CodeGenerator::SystemCPP) continue;

    ConstructPtr value = getValue(name);
    if (isDynamic(name)) continue;
    printed = true;

    cg.printf(decl ? "extern const " : "const ");
    TypePtr type = getFinalType(name);
    if (type->is(Type::KindOfString)) {
      cg.printf("StaticString");
    } else {
      type->outputCPPDecl(cg, ar);
    }
    const char *nameStr = name.c_str();
    if (decl) {
      cg.printf(" %s%s", Option::ConstantPrefix, nameStr);
    } else {
      cg.printf(" %s%s = ", Option::ConstantPrefix, nameStr);
      if (value) {
        ExpressionPtr exp = dynamic_pointer_cast<Expression>(value);
        ASSERT(!exp->getExpectedType());
        exp->outputCPP(cg, ar);
      } else {
        cg.printf("\"%s\"", nameStr);
      }
    }
    cg.printf(";\n");
  }
  if (printed) {
    cg.printf("\n");
  }
}
开发者ID:Neomeng,项目名称:hiphop-php,代码行数:42,代码来源:constant_table.cpp

示例15: outputCPPInvokeArgCountCheck

bool FunctionScope::outputCPPInvokeArgCountCheck(CodeGenerator &cg,
    AnalysisResultPtr ar, bool ret, bool constructor) {
  bool variable = isVariableArgument();
  // system function has different handling of argument counts
  bool system = (m_system || m_sep ||
                 cg.getOutput() == CodeGenerator::SystemCPP);
  if (!system) {
    ClassScopePtr scope = ar->getClassScope();
    if (scope) system = (!scope->isUserClass() || scope->isExtensionClass() ||
                         scope->isSepExtension());
  }

  bool checkMissing = (m_minParam > 0);
  bool checkTooMany = (!variable && (system ||
                                     RuntimeOption::ThrowTooManyArguments));
  const char *sysret = (system && ret) ? "return " : "";
  const char *level = (system ? (constructor ? ", 2" : ", 1") : "");
  bool guarded = system && (ret || constructor);
  string fullname = getOriginalFullName();
  if (checkMissing && checkTooMany) {
    if (!variable && m_minParam == m_maxParam) {
      cg_printf("if (count != %d)"
                " %sthrow_wrong_arguments(\"%s\", count, %d, %d%s);\n",
                m_minParam, sysret, fullname.c_str(), m_minParam, m_maxParam,
                level);
    } else {
      cg_printf("if (count < %d || count > %d)"
                " %sthrow_wrong_arguments(\"%s\", count, %d, %d%s);\n",
                m_minParam, m_maxParam, sysret, fullname.c_str(),
                m_minParam, variable ? -1 : m_maxParam, level);
    }
  } else if (checkMissing) {
    cg_printf("if (count < %d)"
              " %sthrow_missing_arguments(\"%s\", count+1%s);\n",
              m_minParam, sysret, fullname.c_str(), level);
  } else if (checkTooMany) {
    cg_printf("if (count > %d)"
              " %sthrow_toomany_arguments(\"%s\", %d%s);\n",
              m_maxParam, sysret, fullname.c_str(), m_maxParam, level);
  }
  return guarded;
}
开发者ID:param108,项目名称:hiphop-php,代码行数:42,代码来源:function_scope.cpp


注:本文中的CodeGenerator::getOutput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。