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


C++ MethodTableBucket::get_method方法代码示例

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


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

示例1: hierarchy_resolve

  static bool hierarchy_resolve(STATE, Symbol* name, Dispatch& msg, LookupData& lookup) {
    Module* module = lookup.from;
    MethodTableBucket* entry;
    bool skip_vis_check = false;

    do {

      if(module != module->origin()) {
        module = module->superclass();
      }

      entry = module->method_table()->find_entry(state, name);

      /* Nothing, there? Ok, keep looking. */
      if(!entry) goto keep_looking;

      /* A 'false' method means to terminate method lookup.
       * (eg. undef_method) */
      if(entry->undef_p(state)) {
        msg.method_missing = eNormal;
        return false;
      }

      /* If this was a private send, then we can handle use
       * any method seen. */
      if(lookup.min_visibility == G(sym_private) || skip_vis_check) {
        /* The method was callable, but we need to keep looking
         * for the implementation, so make the invocation bypass all further
         * visibility checks. If we are skipping visibility checks we
         * shouldn't update visibility anymore because the implementation
         * might have a different visibility than the original lookup.
         */
        if(!skip_vis_check) {
          msg.visibility = entry->visibility();
        }
        if(entry->method()->nil_p() && entry->method_id()->nil_p()) {
        // TODO: fix using method() == cNil for this
        // if(entry->method()->nil_p()) {
          skip_vis_check = true;
          goto keep_looking;
        }

        if(Alias* alias = try_as<Alias>(entry->method())) {
          if(alias->original_exec()->nil_p()) {
            name           = alias->original_name();
            msg.visibility = entry->visibility();
            skip_vis_check = true;
          } else {
            msg.method = alias->original_exec();
            msg.module = alias->original_module();
          }
        } else {
          msg.method = entry->get_method(state);
          msg.module = module;
        }
        if(msg.method) return true;
      } else {
        /* The method is private, but this wasn't a private send. */
        if(entry->private_p(state)) {
          msg.method_missing = ePrivate;
          return false;
        } else if(entry->protected_p(state)) {
          /* The method is protected, but it's not being called from
           * the same module, or we only want public methods. */
          Module* check_mod;
          if(IncludedModule* im = try_as<IncludedModule>(module)) {
            check_mod = im->module();
          } else {
            check_mod = module;
          }

          if(lookup.min_visibility == G(sym_public) && !lookup.recv->kind_of_p(state, check_mod)) {
            msg.method_missing = eProtected;
            return false;
          }
        }

        /* The method was callable, but we need to keep looking
         * for the implementation, so make the invocation bypass all further
         * visibility checks. If we are skipping visibility checks we
         * shouldn't update visibility anymore because the implementation
         * might have a different visibility than the original lookup.
         */
        if(!skip_vis_check) {
          msg.visibility = entry->visibility();
        }
        if(entry->method()->nil_p() && entry->method_id()->nil_p()) {
        // TODO: fix using method() == cNil for this
        // if(entry->method()->nil_p()) {
          skip_vis_check = true;
          goto keep_looking;
        }

        if(Alias* alias = try_as<Alias>(entry->method())) {
          if(alias->original_exec()->nil_p()) {
            name           = alias->original_name();
            msg.visibility = entry->visibility();
            skip_vis_check = true;
          } else {
            msg.method = alias->original_exec();
//.........这里部分代码省略.........
开发者ID:Omosofe,项目名称:rubinius,代码行数:101,代码来源:global_cache.cpp


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