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


C++ Func::isAllowOverride方法代码示例

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


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

示例1: rename

bool RenamedFuncDict::rename(const StringData* old, const StringData* n3w) {
  assert(isFunctionRenameable(old) ||
         isFunctionRenameable(n3w));

  NamedEntity *oldNe = const_cast<NamedEntity *>(Unit::GetNamedEntity(old));
  NamedEntity *newNe = const_cast<NamedEntity *>(Unit::GetNamedEntity(n3w));

  Func* func = Unit::lookupFunc(oldNe);
  if (!func) {
      // It's the caller's responsibility to ensure that the old function
      // exists.
      not_reached();
  }

  if (!(func->attrs() & AttrDynamicInvoke)) {
    // When EvalJitEnableRenameFunction is false, the translator may wire
    // non-DynamicInvoke Func*'s into the TC. Don't rename functions.
    if (RuntimeOption::EvalJit && !RuntimeOption::EvalJitEnableRenameFunction) {
      raise_error("You must explicitly enable fb_rename_function in the JIT "
                  "(-v Eval.JitEnableRenameFunction=true)");
    }
  }

  Func *fnew = Unit::lookupFunc(newNe);
  if (fnew && fnew != func) {
    // To match hphpc, we silently ignore functions defined in user code that
    // have the same name as a function defined in a separable extension
    if (!fnew->isAllowOverride()) {
      raise_error("Function already defined: %s", n3w->data());
    } else {
      return false;
    }
  }

  oldNe->setCachedFunc(nullptr);
  if (UNLIKELY(newNe->m_cachedFuncOffset == 0)) {
    Transl::TargetCache::allocFixedFunction(newNe, false);
  }
  newNe->setCachedFunc(func);

  if (RuntimeOption::EvalJit) {
    Transl::TargetCache::invalidateForRename(old);
  }

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

示例2: rename_function

void rename_function(const String& old_name, const String& new_name) {
  auto const old = old_name.get();
  auto const n3w = new_name.get();
  auto const oldNe = const_cast<NamedEntity*>(Unit::GetNamedEntity(old));
  auto const newNe = const_cast<NamedEntity*>(Unit::GetNamedEntity(n3w));

  Func* func = Unit::lookupFunc(oldNe);
  if (!func) {
    // It's the caller's responsibility to ensure that the old function
    // exists.
    not_reached();
  }

  if (!(func->attrs() & AttrDynamicInvoke)) {
    // When EvalJitEnableRenameFunction is false, the translator may wire
    // non-DynamicInvoke Func*'s into the TC. Don't rename functions.
    if (RuntimeOption::EvalJit && !RuntimeOption::EvalJitEnableRenameFunction) {
      raise_error("You must explicitly enable fb_rename_function in the JIT "
                  "(-v Eval.JitEnableRenameFunction=true)");
    }
  }

  Func *fnew = Unit::lookupFunc(newNe);
  if (fnew && fnew != func) {
    // To match hphpc, we silently ignore functions defined in user code that
    // have the same name as a function defined in a separable extension
    if (!fnew->isAllowOverride()) {
      raise_error("Function already defined: %s", n3w->data());
    }
    return;
  }

  oldNe->setCachedFunc(nullptr);
  newNe->m_cachedFunc.bind();
  newNe->setCachedFunc(func);

  if (RuntimeOption::EvalJit) {
    JIT::invalidateForRenameFunction(old);
  }
}
开发者ID:artursmolarek,项目名称:hhvm,代码行数:40,代码来源:intercept.cpp


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