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


C++ CodeGenerator类代码示例

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


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

示例1: preOutputCPP

bool ListAssignment::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
                                  int state) {
  assert(m_array);

  if (!cg.inExpression()) return true;

  if (m_variables) {
    preOutputVariables(cg, ar, m_variables->hasEffect() ||
                       m_array->hasEffect() ? FixOrder : 0);
  }
  m_array->preOutputCPP(cg, ar, 0);

  bool isArray = false, notArray = false;
  bool simpleVar = m_array->is(KindOfSimpleVariable) &&
    !static_pointer_cast<SimpleVariable>(m_array)->getAlwaysStash();
  bool needsUse = false;
  if (TypePtr type = m_array->getActualType()) {
    isArray = type->is(Type::KindOfArray);
    notArray = !isArray &&
      (type->isPrimitive() ||
       m_rhsKind == Null ||
      (m_rhsKind == Checked && (type->is(Type::KindOfString) ||
                                type->is(Type::KindOfObject))));
  }
  cg.wrapExpressionBegin();
  if (outputLineMap(cg, ar)) cg_printf("0);\n");
  if (notArray && isUnused()) {
    if (m_array->outputCPPUnneeded(cg, ar)) cg_printf(";\n");
    m_cppTemp = "null";
  } else {
    m_cppTemp = genCPPTemp(cg, ar);
    needsUse = simpleVar || m_array->isTemporary();
    const char *decl;
    if (isArray && m_array->getCPPType()->is(Type::KindOfArray)) {
      decl = needsUse ? "CArrRef" : "Array";
    } else {
      decl = needsUse ? "CVarRef" : "Variant";
    }
    cg_printf("%s %s((", decl, m_cppTemp.c_str());
    m_array->outputCPP(cg, ar);
    cg_printf("));\n");
  }
  std::string tmp;
  if (notArray) {
    tmp = "null_variant";
    if (needsUse) cg_printf("id(%s);\n", m_cppTemp.c_str());
    needsUse = false;
  } else if (m_rhsKind != Checked || isArray) {
    tmp = m_cppTemp;
  } else {
    tmp = genCPPTemp(cg, ar);
    cg_printf("CVarRef %s(f_is_array(%s)?%s:null_variant);\n",
              tmp.c_str(), m_cppTemp.c_str(), m_cppTemp.c_str());
    needsUse = true;
  }
  if (!outputCPPAssignment(cg, ar, tmp, simpleVar) && needsUse) {
    cg_printf("id(%s);\n", tmp.c_str());
  }

  return true;
}
开发者ID:BauerBox,项目名称:hiphop-php,代码行数:61,代码来源:list_assignment.cpp

示例2: outputCodeModel

void ArrayElementExpression::outputCodeModel(CodeGenerator &cg) {
  if (m_offset) {
    cg.printObjectHeader("BinaryOpExpression", 4);
    cg.printPropertyHeader("expression1");
    m_variable->outputCodeModel(cg);
    cg.printPropertyHeader("expression2");
    cg.printExpression(m_offset, false);
    cg.printPropertyHeader("operation");
    cg.printValue(PHP_ARRAY_ELEMENT);
    cg.printPropertyHeader("sourceLocation");
    cg.printLocation(this);
    cg.printObjectFooter();
  } else {
    cg.printObjectHeader("UnaryOpExpression", 3);
    cg.printPropertyHeader("expression");
    m_variable->outputCodeModel(cg);
    cg.printPropertyHeader("operation");
    cg.printValue(PHP_ARRAY_APPEND_POINT_OP);
    cg.printPropertyHeader("sourceLocation");
    cg.printLocation(this);
    cg.printObjectFooter();
  }
}
开发者ID:jaggedsoft,项目名称:hhvm,代码行数:23,代码来源:array_element_expression.cpp

示例3: codegen_declarations

 void Switch::codegen_declarations(CodeGenerator& g) const {
   for (casadi_int k=0; k<=f_.size(); ++k) {
     const Function& fk = k<f_.size() ? f_[k] : f_def_;
     g.add_dependency(fk);
   }
 }
开发者ID:casadi,项目名称:casadi,代码行数:6,代码来源:switch.cpp

示例4: preOutputCPP

bool DynamicFunctionCall::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
                                       int state) {
    bool nonStatic = !m_class && m_className.empty();
    if (!nonStatic && !m_class && !m_classScope && !isRedeclared()) {
        // call to an unknown class
        // set m_noStatic to avoid pointlessly wrapping the call
        // in STATIC_CLASS_NAME_CALL()
        m_noStatic = true;
        cg.pushCallInfo(-1);
        bool ret = FunctionCall::preOutputCPP(cg, ar, state);
        cg.popCallInfo();
        return ret;
    }
    // Short circuit out if inExpression() returns false
    if (!cg.inExpression()) return true;

    cg.wrapExpressionBegin();

    m_ciTemp = cg.createNewLocalId(shared_from_this());

    if (!m_classScope && !m_className.empty() && m_cppTemp.empty() &&
            !isSelf() && ! isParent() && !isStatic()) {
        // Create a temporary to hold the class name, in case it is not a
        // StaticString.
        m_clsNameTemp = cg.createNewLocalId(shared_from_this());
        cg_printf("CStrRef clsName%d(", m_clsNameTemp);
        cg_printString(m_origClassName, ar, shared_from_this());
        cg_printf(");\n");
    }

    if (m_class) {
        int s = m_class->hasEffect() || m_nameExp->hasEffect() ?
                FixOrder : 0;
        m_class->preOutputCPP(cg, ar, s);
    }
    m_nameExp->preOutputCPP(cg, ar, 0);

    if (nonStatic) {
        cg_printf("const CallInfo *cit%d;\n", m_ciTemp);
        cg_printf("void *vt%d;\n", m_ciTemp);
        cg_printf("get_call_info_or_fail(cit%d, vt%d, ", m_ciTemp, m_ciTemp);

        if (m_nameExp->is(Expression::KindOfSimpleVariable)) {
            m_nameExp->outputCPP(cg, ar);
        } else {
            cg_printf("(");
            m_nameExp->outputCPP(cg, ar);
            cg_printf(")");
        }
        cg_printf(");\n");
    } else {
        cg_printf("MethodCallPackage mcp%d;\n", m_ciTemp);
        if (m_class) {
            if (m_class->is(KindOfScalarExpression)) {
                ASSERT(strcasecmp(dynamic_pointer_cast<ScalarExpression>(m_class)->
                                  getString().c_str(), "static") == 0);
                cg_printf("CStrRef cls%d = "
                          "FrameInjection::GetStaticClassName(fi.getThreadInfo())",
                          m_ciTemp);
            } else {
                cg_printf("C%sRef cls%d = ",
                          m_class->getActualType() &&
                          m_class->getActualType()->is(Type::KindOfString) ?
                          "Str" : "Var", m_ciTemp);
                m_class->outputCPP(cg, ar);
            }
        } else if (m_classScope) {
            cg_printf("CStrRef cls%d = ", m_ciTemp);
            cg_printString(m_classScope->getId(), ar, shared_from_this());
        } else {
            cg_printf("CStrRef cls%d = ", m_ciTemp);
            cg_printString(m_className, ar, shared_from_this());
        }
        cg_printf(";\n");

        cg_printf("CStrRef mth%d = ", m_ciTemp);
        if (m_nameExp->is(Expression::KindOfSimpleVariable)) {
            m_nameExp->outputCPP(cg, ar);
        } else {
            cg_printf("(");
            m_nameExp->outputCPP(cg, ar);
            cg_printf(")");
        }
        cg_printf(";\n");

        bool dynamic = true;
        if (!m_class) {
            ClassScopeRawPtr origClass = getOriginalClass();
            if (!origClass) {
                dynamic = false;
            } else {
                FunctionScopeRawPtr origFunc = getOriginalFunction();
                if (origFunc) {
                    if (origFunc->isStatic() ||
                            (m_classScope != origClass &&
                             (m_className.empty() || !origClass->derivesFrom(
                                  ar, m_className, true, true)))) {
                        dynamic = false;
                    }
                }
//.........这里部分代码省略.........
开发者ID:nishant-shrivastava,项目名称:hiphop-php,代码行数:101,代码来源:dynamic_function_call.cpp

示例5: outputCodeModel

void MethodStatement::outputCodeModel(CodeGenerator &cg) {
  auto isAnonymous = ParserBase::IsClosureName(m_originalName);
  auto numProps = 4;
  if (m_attrList != nullptr) numProps++;
  if (m_ref) numProps++;
  if (m_params != nullptr) numProps++;
  if (m_retTypeAnnotation != nullptr) numProps++;
  if (!m_docComment.empty()) numProps++;
  cg.printObjectHeader("FunctionStatement", numProps);
  if (m_attrList != nullptr) {
    cg.printPropertyHeader("attributes");
    cg.printExpressionVector(m_attrList);
  }
  cg.printPropertyHeader("modifiers");
  m_modifiers->outputCodeModel(cg);
  if (m_ref) {
    cg.printPropertyHeader("returnsReference");
    cg.printBool(true);
  }
  cg.printPropertyHeader("name");
  cg.printValue(isAnonymous ? "" : m_originalName);
  //TODO: type parameters (task 3262469)
  if (m_params != nullptr) {
    cg.printPropertyHeader("parameters");
    cg.printExpressionVector(m_params);
  }
  if (m_retTypeAnnotation != nullptr) {
    cg.printPropertyHeader("returnType");
    m_retTypeAnnotation->outputCodeModel(cg);
  }
  cg.printPropertyHeader("block");
  if (m_stmt != nullptr) {
    auto stmt = m_stmt;
    if (m_autoPropCount > 0) {
      stmt = static_pointer_cast<StatementList>(stmt->clone());
      for (int i = m_autoPropCount; i > 0; i--) {
        stmt->removeElement(0);
      }
    }
    cg.printAsEnclosedBlock(stmt);
  } else {
    cg.printAsBlock(nullptr);
  }
  cg.printPropertyHeader("sourceLocation");
  cg.printLocation(this);
  if (!m_docComment.empty()) {
    cg.printPropertyHeader("comments");
    cg.printValue(m_docComment);
  }
  cg.printObjectFooter();
}
开发者ID:jazzdan,项目名称:hhvm,代码行数:51,代码来源:method_statement.cpp

示例6: getClassScope

void ClassStatement::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
  ClassScopeRawPtr classScope = getClassScope();
  if (cg.getContext() == CodeGenerator::NoContext) {
    if (classScope->isRedeclaring()) {
      cg_printf("g->%s%s = ClassStaticsPtr(NEW(%s%s)());\n",
                Option::ClassStaticsObjectPrefix,
                cg.formatLabel(m_name).c_str(),
                Option::ClassStaticsPrefix, classScope->getId(cg).c_str());
      cg_printf("g->%s%s = &%s%s;\n",
                Option::ClassStaticsCallbackPrefix,
                cg.formatLabel(m_name).c_str(),
                Option::ClassWrapperFunctionPrefix,
                classScope->getId(cg).c_str());
    }
    if (classScope->isVolatile()) {
      cg_printf("g->CDEC(%s) = true;\n", m_name.c_str());
    }
    const vector<string> &bases = classScope->getBases();
    for (vector<string>::const_iterator it = bases.begin();
         it != bases.end(); ++it) {
      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);
        cg.printSection(">>>>>>>>>> Internal Implementation <<<<<<<<<<");
        cg_printf("// NOTE: Anything below is subject to change. "
                  "Use everything above instead.\n");
//.........这里部分代码省略.........
开发者ID:akia,项目名称:hiphop-php,代码行数:101,代码来源:class_statement.cpp

示例7: outputCPPClassDecl

void ClassStatement::outputCPPClassDecl(CodeGenerator &cg,
                                        AnalysisResultPtr ar,
                                        const char *clsName,
                                        const char *originalName,
                                        const char *parent) {
  ClassScopeRawPtr classScope = getClassScope();
  VariableTablePtr variables = classScope->getVariables();
  ConstantTablePtr constants = classScope->getConstants();
  if (variables->hasAllJumpTables() && constants->hasJumpTable() &&
      classScope->hasAllJumpTables()) {
    cg_printf("DECLARE_CLASS(%s, %s, %s)\n", clsName, originalName, parent);
    return;
  }

  // Now we start to break down DECLARE_CLASS into lines of code that could
  // be generated differently...

  cg_printf("DECLARE_CLASS_COMMON(%s, %s)\n", clsName,
            cg.escapeLabel(originalName).c_str());
  cg_printf("DECLARE_INVOKE_EX%s(%s, %s, %s)\n",
      Option::UseMethodIndex ? "WITH_INDEX" : "", clsName,
            cg.escapeLabel(originalName).c_str(), parent);

  cg.printSection("DECLARE_STATIC_PROP_OPS");
  cg_printf("public:\n");
  if (classScope->needStaticInitializer()) {
    cg_printf("static void os_static_initializer();\n");
  }
  if (variables->hasJumpTable(VariableTable::JumpTableClassStaticGetInit)) {
    cg_printf("static Variant os_getInit(CStrRef s);\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_GETINIT_%s 1\n", clsName);
  }
  if (variables->hasJumpTable(VariableTable::JumpTableClassStaticGet)) {
    cg_printf("static Variant os_get(CStrRef s);\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_GET_%s 1\n", clsName);
  }
  if (variables->hasJumpTable(VariableTable::JumpTableClassStaticLval)) {
    cg_printf("static Variant &os_lval(CStrRef s);\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_LVAL_%s 1\n", clsName);
  }
  if (constants->hasJumpTable()) {
    cg_printf("static Variant os_constant(const char *s);\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_CONSTANT_%s 1\n", clsName);
  }

  cg.printSection("DECLARE_INSTANCE_PROP_OPS");
  cg_printf("public:\n");

  if (variables->hasJumpTable(VariableTable::JumpTableClassGetArray)) {
    cg_printf("virtual void o_getArray(Array &props, bool pubOnly = false) "
              "const;\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_GETARRAY_%s 1\n", clsName);
  }
  if (variables->hasJumpTable(VariableTable::JumpTableClassSetArray)) {
    cg_printf("virtual void o_setArray(CArrRef props);\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_SETARRAY_%s 1\n", clsName);
  }

  if (variables->hasJumpTable(VariableTable::JumpTableClassRealProp)) {
    cg_printf("virtual Variant *o_realProp(CStrRef s, int flags,\n");
    cg_printf("                            CStrRef context = null_string) "
              "const;\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_realProp_%s 1\n", clsName);
  }
  if (variables->hasNonStaticPrivate()) {
    cg_printf("Variant *o_realPropPrivate(CStrRef s, int flags) const;\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_realProp_PRIVATE_%s 1\n", clsName);
  }

  cg.printSection("DECLARE_INSTANCE_PUBLIC_PROP_OPS");
  cg_printf("public:\n");
  if (variables->hasJumpTable(VariableTable::JumpTableClassRealPropPublic)) {
    cg_printf("virtual Variant *o_realPropPublic(CStrRef s, "
              "int flags) const;\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_realProp_PUBLIC_%s 1\n", clsName);
  }

  cg.printSection("DECLARE_COMMON_INVOKE");
  cg.printf("static bool os_get_call_info(MethodCallPackage &mcp, "
      "int64 hash = -1);\n");
  if (Option::UseMethodIndex) {
    cg.printf("virtual bool o_get_call_info_with_index(MethodCallPackage &mcp,"
        " MethodIndex mi, int64 hash = -1);\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_INVOKE_%s 1\n", clsName);
  }
  if (classScope->hasJumpTable(ClassScope::JumpTableInvoke)) {
    cg.printf("virtual bool o_get_call_info(MethodCallPackage &mcp, "
        "int64 hash = -1);\n");
  } else {
    cg_printf("#define OMIT_JUMP_TABLE_CLASS_INVOKE_%s 1\n", clsName);
//.........这里部分代码省略.........
开发者ID:akia,项目名称:hiphop-php,代码行数:101,代码来源:class_statement.cpp

示例8: preOutputCPP

bool QOpExpression::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
                                 int state) {
  if (!hasEffect()) {
    return Expression::preOutputCPP(cg, ar, state);
  }

  bool fix_condition = m_condition->preOutputCPP(cg, ar, 0);
  if (!cg.inExpression()) {
    return fix_condition || (state & FixOrder) ||
      (!m_expYes || m_expYes->preOutputCPP(cg, ar, 0)) ||
      m_expNo->preOutputCPP(cg, ar, 0);
  }

  cg.setInExpression(false);
  bool fix_yes = (!m_expYes || m_expYes->preOutputCPP(cg, ar, 0));
  bool fix_no = m_expNo->preOutputCPP(cg, ar, 0);
  cg.setInExpression(true);

  if (fix_yes || fix_no) {
    cg.wrapExpressionBegin();
    if (isUnused()) {
      cg_printf("if (");
      wrapBoolean(cg, ar, m_condition);
      cg_indentBegin(") {\n");
      if (m_expYes) {
        m_expYes->preOutputCPP(cg, ar, 0);
        if (m_expYes->outputCPPUnneeded(cg, ar)) cg_printf(";\n");
      }
      cg_indentEnd("\n");
      cg_indentBegin("} else {\n");
      m_expNo->preOutputCPP(cg, ar, 0);
      if (m_expNo->outputCPPUnneeded(cg, ar)) cg_printf(";\n");
      cg_indentEnd("}\n");
      m_cppValue = "null_variant";
    } else {
      std::string tmp = genCPPTemp(cg, ar);

      if (m_expYes) {
        TypePtr typeYes = m_expYes->getActualType();
        TypePtr typeNo = m_expNo->getActualType();
        TypePtr type =
          typeYes && typeNo && Type::SameType(typeYes, typeNo) &&
          !typeYes->is(Type::KindOfVariant) &&
          m_expYes->isLiteralString() == m_expNo->isLiteralString() ?
          typeYes : Type::Variant;

        type->outputCPPDecl(cg, ar, getScope());
        cg_printf(" %s;\n", tmp.c_str());
        cg_printf("if (");
        wrapBoolean(cg, ar, m_condition);
        cg_indentBegin(") {\n");
        m_expYes->preOutputCPP(cg, ar, 0);
        cg_printf("%s = (", tmp.c_str());
        m_expYes->outputCPP(cg, ar);
        cg_indentEnd(");\n");
      } else {
        TypePtr typeYes = m_condition->getActualType();
        TypePtr typeNo = m_expNo->getActualType();
        TypePtr type =
          typeYes && typeNo && Type::SameType(typeYes, typeNo) &&
          !typeYes->is(Type::KindOfVariant) &&
          m_condition->isLiteralString() == m_expNo->isLiteralString() ?
          typeYes : Type::Variant;

        type->outputCPPDecl(cg, ar, getScope());
        cg_printf(" %s = ", tmp.c_str());
        m_condition->outputCPP(cg, ar);
        cg_printf(";\n");
        cg_printf("if (toBoolean(%s)) {\n", tmp.c_str());
      }

      cg_indentBegin("} else {\n");
      m_expNo->preOutputCPP(cg, ar, 0);
      cg_printf("%s = (", tmp.c_str());
      m_expNo->outputCPP(cg, ar);
      cg_printf(");\n");
      cg_indentEnd("}\n");
      m_cppValue = tmp;
    }
  } else if (state & FixOrder) {
    preOutputStash(cg, ar, state);
    return true;
  }
  return false;
}
开发者ID:AviMoto,项目名称:hiphop-php,代码行数:85,代码来源:qop_expression.cpp

示例9: preOutputCPP

bool ExpressionList::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
                                  int state) {
  if (m_kind == ListKindParam && !m_arrayElements) {
    return Expression::preOutputCPP(cg, ar, state|StashKidVars);
  }

  unsigned n = m_exps.size();
  bool inExpression = cg.inExpression();
  if (!inExpression && (state & FixOrder)) {
    return true;
  }

  cg.setInExpression(false);
  bool ret = false;
  if (m_arrayElements) {
    /*
     * would like to do:
     *  ret = Expression::preOutputCPP(cg, ar, state);
     * but icc has problems with the generated code.
     */
    ret = hasEffect();
  } else if (n > 1 && m_kind == ListKindLeft) {
    ret = true;
  } else {
    for (unsigned int i = 0; i < n; i++) {
      if (m_exps[i]->preOutputCPP(cg, ar, 0)) {
        ret = true;
        break;
      }
    }
    if (!ret) {
      ExpressionPtr e = m_exps[n - 1];
      if (hasContext(LValue) && !hasAnyContext(RefValue|InvokeArgument) &&
          !(e->hasContext(LValue) &&
            !e->hasAnyContext(RefValue|InvokeArgument))) {
        ret = true;
      } else if (hasContext(RefValue) &&
                 !e->hasAllContext(LValue|ReturnContext) &&
                 !e->hasContext(RefValue)) {
        ret = true;
      }
    }
  }

  if (!inExpression) return ret;

  cg.setInExpression(true);
  if (!ret) {
    if (state & FixOrder) {
      preOutputStash(cg, ar, state);
      return true;
    }
    return false;
  }

  cg.wrapExpressionBegin();
  if (m_arrayElements) {
    setCPPTemp(genCPPTemp(cg, ar));
    outputCPPInternal(cg, ar, true, true);
  } else {
    unsigned ix = isUnused() ? (unsigned)-1 :
      m_kind == ListKindLeft ? 0 : n - 1;
    for (unsigned int i = 0; i < n; i++) {
      ExpressionPtr e = m_exps[i];
      if (i != ix) e->setUnused(true);
      e->preOutputCPP(cg, ar, i == ix ? state : 0);
      if (i != ix) {
        if (e->outputCPPUnneeded(cg, ar)) {
          cg_printf(";\n");
        }
        e->setCPPTemp("/**/");
        continue;
      }
      /*
        We inlined a by-value function into the rhs of a by-ref assignment.
      */
      bool noRef = hasContext(RefValue) &&
        !e->hasAllContext(LValue|ReturnContext) &&
        !e->hasContext(RefValue) &&
        !e->isTemporary() &&
        Type::IsMappedToVariant(e->getActualType());
      /*
        If we need a non-const reference, but the expression is
        going to generate a const reference, fix it
      */
      bool lvSwitch =
        hasContext(LValue) && !hasAnyContext(RefValue|InvokeArgument) &&
        !(e->hasContext(LValue) &&
          !e->hasAnyContext(RefValue|InvokeArgument));

      if (e->hasAllContext(LValue|ReturnContext) && i + 1 == n) {
        e->clearContext(ReturnContext);
      }

      if (noRef || lvSwitch || (!i && n > 1)) {
        e->Expression::preOutputStash(cg, ar, state | FixOrder | StashAll);
        if (!(state & FixOrder)) {
          cg_printf("id(%s);\n", e->cppTemp().c_str());
        }
      }
//.........这里部分代码省略.........
开发者ID:Chuwiey,项目名称:hiphop-php,代码行数:101,代码来源:expression_list.cpp

示例10:

 virtual PPMutationListener *GetPPMutationListener() {
     return CG->GetPPMutationListener();
 }
开发者ID:jameshegarty,项目名称:terra,代码行数:3,代码来源:tcwrapper.cpp

示例11: shouldSkipFunctionBody

 virtual bool shouldSkipFunctionBody(Decl *D) {
     return CG->shouldSkipFunctionBody(D);
 }
开发者ID:jameshegarty,项目名称:terra,代码行数:3,代码来源:tcwrapper.cpp

示例12: HandleInterestingDecl

 virtual void HandleInterestingDecl(DeclGroupRef D) {
     CG->HandleInterestingDecl(D);
 }
开发者ID:jameshegarty,项目名称:terra,代码行数:3,代码来源:tcwrapper.cpp

示例13: HandleTranslationUnit

 virtual void HandleTranslationUnit(ASTContext &Ctx) {
     Decl * Decl = Visitor.GetLivenessFunction();
     DeclGroupRef R = DeclGroupRef::Create(Ctx, &Decl, 1);
     CG->HandleTopLevelDecl(R);
     CG->HandleTranslationUnit(Ctx);
 }
开发者ID:jameshegarty,项目名称:terra,代码行数:6,代码来源:tcwrapper.cpp

示例14: Initialize

 virtual void Initialize(ASTContext &Context) {
     Visitor.SetContext(&Context);
     CG->Initialize(Context);
 }
开发者ID:jameshegarty,项目名称:terra,代码行数:4,代码来源:tcwrapper.cpp

示例15: HandleTopLevelDecl

 virtual bool HandleTopLevelDecl(DeclGroupRef D) {
     for (DeclGroupRef::iterator b = D.begin(), e = D.end();
             b != e; ++b)
         Visitor.TraverseDecl(*b);
     return CG->HandleTopLevelDecl(D);
 }
开发者ID:jameshegarty,项目名称:terra,代码行数:6,代码来源:tcwrapper.cpp


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