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


C++ VariableScope::parent方法代码示例

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


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

示例1: synthesize

  VariableScope* VariableScope::synthesize(STATE, CompiledMethod* method,
                                           Module* module, Object* parent,
                                           Object* self, Object* block,
                                           Tuple* locals)
  {
    VariableScope* scope = state->new_object<VariableScope>(G(variable_scope));

    scope->block(state, block);
    scope->module(state, module);
    scope->method(state, method);

    if(VariableScope* vs = try_as<VariableScope>(parent)) {
      scope->parent(state, vs);
    } else {
      scope->parent(state, nil<VariableScope>());
    }

    scope->heap_locals(state, locals);
    scope->last_match(state, cNil);

    scope->self(state, self);
    scope->number_of_locals_ = locals->num_fields();
    scope->isolated_ = true;
    scope->locals_ = 0;
    scope->block_as_method_ = 0;

    return scope;
  }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: create_heap_alias

  VariableScope* StackVariables::create_heap_alias(STATE,
      CallFrame* call_frame, bool full)
  {
    if(on_heap_) return on_heap_;

    VMMethod* vmm = call_frame->cm->backend_method();
    VariableScope* scope = state->new_struct<VariableScope>(
        G(variable_scope), vmm->number_of_locals * sizeof(Object*));

    if(parent_) {
      scope->parent(state, parent_);
    } else {
      scope->parent(state, (VariableScope*)Qnil);
    }

    scope->self(state, self_);
    scope->block(state, block_);
    scope->module(state, module_);
    scope->method(state, call_frame->cm);

    scope->number_of_locals_ = vmm->number_of_locals;

    if(full) {
      scope->isolated_ = false;
      scope->point_locals_to(locals_);
    } else {
      scope->isolated_ = true;
      scope->point_locals_to(scope->heap_locals_);
    }

    on_heap_ = scope;

    return scope;
  }
开发者ID:vasco,项目名称:rubinius,代码行数:34,代码来源:stack_variables.cpp

示例3: push_local_depth

    inline bool push_local_depth(STATE, CallFrame* call_frame, intptr_t depth, intptr_t index) {
      if(depth == 0) {
        Exception::internal_error(state, "illegal push_local_depth usage");
        return false;
      } else {
        VariableScope* scope = call_frame->scope->parent();

        if(!scope || scope->nil_p()) {
          Exception::internal_error(state, "illegal push_local_depth usage, no parent");
          return false;
        }

        for(int j = 1; j < depth; j++) {
          scope = scope->parent();
          if(!scope || scope->nil_p()) {
            Exception::internal_error(state, "illegal push_local_depth usage, no parent");
            return false;
          }
        }

        if(index >= scope->number_of_locals()) {
          Exception::internal_error(state, "illegal push_local_depth usage, bad index");
          return false;
        }

        stack_push(scope->get_local(state, index));
        return true;
      }
    }
开发者ID:chuckremes,项目名称:rubinius,代码行数:29,代码来源:push_local_depth.hpp

示例4: set_locked

 Object* VariableScope::set_locked(STATE) {
   _flags_ |= CallFrame::cScopeLocked;
   VariableScope* parent = this->parent();
   while(parent && !parent->nil_p()) {
     parent->set_locked(state);
     parent = parent->parent();
   }
   return cNil;
 }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:9,代码来源:variable_scope.cpp

示例5: create_heap_alias

  VariableScope* StackVariables::create_heap_alias(STATE, CallFrame* call_frame,
                                                   bool full)
  {
    if(on_heap_) return on_heap_;

    MachineCode* mcode = call_frame->compiled_code->machine_code();
    VariableScope* scope =
      state->memory()->new_object<VariableScope>(state, G(variable_scope));

    if(parent_) {
      scope->parent(state, parent_);
    } else {
      scope->parent(state, nil<VariableScope>());
    }

    scope->self(state, self_);
    scope->block(state, block_);
    scope->module(state, module_);
    scope->method(state, call_frame->compiled_code);
    scope->heap_locals(state, nil<Tuple>());
    scope->last_match(state, last_match_);
    scope->fiber(state, state->vm()->thread()->current_fiber());

    scope->number_of_locals(mcode->number_of_locals);
    scope->isolated(0);
    scope->flags(call_frame->flags);
    scope->_lock_.init();

    if(!full) {
      scope->isolated(1);
      scope->heap_locals(state, Tuple::create(state, mcode->number_of_locals));
      for(int i = 0; i < scope->number_of_locals(); i++) {
        scope->set_local(state, i, locals_[i]);
      }
    }

    scope->locals(locals_);
    scope->dynamic_locals(state, nil<LookupTable>());

    on_heap_ = scope;

    return scope;
  }
开发者ID:Justme0,项目名称:rubinius,代码行数:43,代码来源:stack_variables.cpp

示例6: last_match

  Object* StackVariables::last_match(STATE) {
    // For closures, get back to the top of the chain and get that
    // last_match.
    if(parent_) {
      VariableScope* scope = parent_;
      while(RTEST(scope->parent())) {
        scope = scope->parent();
      }

      return scope->last_match();
    }

    // Otherwise, if this has a heap alias, get the last_match from there.
    if(on_heap_) {
      return on_heap_->last_match();

    // Lastly, use the local one. This is where a last_match begins life.
    } else {
      return last_match_;
    }
  }
开发者ID:AndreMeira,项目名称:rubinius,代码行数:21,代码来源:stack_variables.cpp

示例7: create_heap_alias

  VariableScope* StackVariables::create_heap_alias(STATE, CallFrame* call_frame,
                                                   bool full)
  {
    if(on_heap_) return on_heap_;

    MachineCode* mcode = call_frame->compiled_code->machine_code();
    VariableScope* scope = state->new_object_dirty<VariableScope>(G(variable_scope));

    if(parent_) {
      scope->parent(state, parent_);
    } else {
      scope->parent(state, nil<VariableScope>());
    }

    scope->self(state, self_);
    scope->block(state, block_);
    scope->module(state, module_);
    scope->method(state, call_frame->compiled_code);
    scope->heap_locals(state, Tuple::create(state, mcode->number_of_locals));
    scope->last_match(state, last_match_);
    scope->fiber(state, state->vm()->current_fiber.get());

    scope->number_of_locals_ = mcode->number_of_locals;

    if(full) {
      scope->isolated_ = false;
    } else {
      scope->isolated_ = true;
    }

    scope->locals_ = locals_;
    scope->dynamic_locals(state, nil<LookupTable>());

    scope->set_block_as_method(call_frame->block_as_method_p());

    on_heap_ = scope;

    return scope;
  }
开发者ID:,项目名称:,代码行数:39,代码来源:

示例8: promote

  VariableScope* VariableScope::promote(STATE) {
    VariableScope* scope = state->new_struct<VariableScope>(
        G(variable_scope), number_of_locals_ * sizeof(Object*));

    scope->block(state, block_);
    scope->method(state, method_);
    scope->module(state, module_);
    if(parent_) {
      scope->parent(state, parent_);
    } else {
      scope->parent(state, (VariableScope*)Qnil);
    }
    scope->self(state, self_);

    scope->number_of_locals_ = number_of_locals_;

    for(int i = 0; i < number_of_locals_; i++) {
      scope->set_local(state, i, locals_[i]);
    }

    return scope;
  }
开发者ID:,项目名称:,代码行数:22,代码来源:

示例9: synthesize

  VariableScope* VariableScope::synthesize(STATE, CompiledCode* method,
      Module* module, Object* parent, Object* self, Object* block, Tuple* locals)
  {
    VariableScope* scope =
      state->memory()->new_object<VariableScope>(state, G(variable_scope));

    scope->block(state, block);
    scope->module(state, module);
    scope->method(state, method);

    if(VariableScope* vs = try_as<VariableScope>(parent)) {
      scope->parent(state, vs);
    } else {
      scope->parent(state, nil<VariableScope>());
    }

    scope->heap_locals(state, locals);

    scope->self(state, self);
    scope->number_of_locals(locals->num_fields());

    return scope;
  }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:23,代码来源:variable_scope.cpp

示例10: create_heap_alias

  VariableScope* StackVariables::create_heap_alias(STATE, CallFrame* call_frame,
                                                   bool full)
  {
    if(on_heap_) return on_heap_;

    VMMethod* vmm = call_frame->cm->backend_method();
    VariableScope* scope = state->new_object<VariableScope>(G(variable_scope));

    if(parent_) {
      scope->parent(state, parent_);
    } else {
      scope->parent(state, nil<VariableScope>());
    }

    scope->self(state, self_);
    scope->block(state, block_);
    scope->module(state, module_);
    scope->method(state, call_frame->cm);
    scope->heap_locals(state, Tuple::create(state, vmm->number_of_locals));
    scope->last_match(state, last_match_);

    scope->number_of_locals_ = vmm->number_of_locals;

    if(full) {
      scope->isolated_ = false;
    } else {
      scope->isolated_ = true;
    }

    scope->locals_ = locals_;

    scope->set_block_as_method(call_frame->block_as_method_p());

    on_heap_ = scope;

    return scope;
  }
开发者ID:AndreMeira,项目名称:rubinius,代码行数:37,代码来源:stack_variables.cpp

示例11: set_last_match

  void StackVariables::set_last_match(STATE, Object* obj) {
    // For closures, get back to the top of the chain and set the
    // last_match there. This means that the last_match is shared
    // amongst all closures in a method, but thats how it's implemented
    // in ruby.
    if(parent_) {
      VariableScope* scope = parent_;
      while(RTEST(scope->parent())) {
        scope = scope->parent();
      }

      return scope->last_match(state, obj);
    }

    // Use a heap alias if there is one.
    if(on_heap_) {
      on_heap_->last_match(state, obj);

    // Otherwise, use the local one. This is where a last_match usually
    // first appears.
    } else {
      last_match_ = obj;
    }
  }
开发者ID:AndreMeira,项目名称:rubinius,代码行数:24,代码来源:stack_variables.cpp

示例12: method_scope

  VariableScope* CallFrame::method_scope(STATE) {
    VariableScope* current = promote_scope(state);
    if(!multiple_scopes_p()) return current;

    for(;;) {
      if(current->block_as_method_p()) return current;
      VariableScope* parent = current->parent();
      if(!parent->nil_p()) {
        current = parent;
      } else {
        return current;
      }
    }

    assert("should not be here" && 0);
  }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例13: method_scope

  VariableScope* CallFrame::method_scope(STATE) {
    VariableScope* current = promote_scope(state);
    if(!multiple_scopes_p()) return current;

    for(;;) {
      if(current->block_as_method_p()) return current;
      VariableScope* parent = current->parent();
      if(!parent->nil_p()) {
        current = parent;
      } else {
        return current;
      }
    }

    // Shouldn't ever get here.
    return 0;
  }
开发者ID:Emily,项目名称:rubinius,代码行数:17,代码来源:call_frame.cpp


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