Class: RubyVM::ControlFrame

Inherits:
Object show all
Defined in:
ext/internal/vm/control_frame/control_frame.c

Instance Method Summary collapse

Instance Method Details

#block_iseqRubyVM::InstructionSequence?

Return the frame’s block_iseq member.

Returns:



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'ext/internal/vm/control_frame/control_frame.c', line 53

static VALUE control_frame_block_iseq(VALUE control_frame)
{
  struct RubyInternalControlFrame * cfp;
  Data_Get_Struct(control_frame, struct RubyInternalControlFrame, cfp);
  if(cfp->control_frame->proc)
  {
    return (VALUE)cfp->control_frame->block_iseq;
  }
  else
  {
    return Qfalse;
  }
}

#iseqRubyVM::InstructionSequence

Return the frame’s iseq member.



27
28
29
30
31
32
# File 'ext/internal/vm/control_frame/control_frame.c', line 27

static VALUE control_frame_iseq(VALUE control_frame)
{
  struct RubyInternalControlFrame * cfp;
  Data_Get_Struct(control_frame, struct RubyInternalControlFrame, cfp);
  return (VALUE)cfp->control_frame->iseq;
}

#method_classClass

Return the frame’s method_class member.

Returns:

  • (Class)


115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'ext/internal/vm/control_frame/control_frame.c', line 115

static VALUE control_frame_method_class(VALUE control_frame)
{
  VALUE klass;
  struct RubyInternalControlFrame * cfp;

  Data_Get_Struct(control_frame, struct RubyInternalControlFrame, cfp);

#if RUBY_VERSION_CODE >= 192
  klass = cfp->control_frame->me->klass; /* TODO: right? */
#else
  klass = cfp->control_frame->method_class;
#endif

  return klass;
}

#method_idSymbol?

Return the frame’s method_id member.

Returns:

  • (Symbol, nil)


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'ext/internal/vm/control_frame/control_frame.c', line 86

static VALUE control_frame_method_id(VALUE control_frame)
{
  ID method_id;
  struct RubyInternalControlFrame * cfp;

  Data_Get_Struct(control_frame, struct RubyInternalControlFrame, cfp);

#if RUBY_VERSION_CODE >= 192
  method_id = cfp->control_frame->me->called_id; /* TODO: right? */
#else
  method_id = cfp->control_frame->method_id;
#endif

  if(method_id)
  {
    return ID2SYM(method_id);
  }
  else
  {
    return Qnil;
  }
}

#prevRubyVM::ControlFrame

Return the frame’s prev member.



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'ext/internal/vm/control_frame/control_frame.c', line 137

static VALUE control_frame_prev(VALUE control_frame)
{
  struct RubyInternalControlFrame * cfp;
  rb_thread_t * th;
  rb_control_frame_t * prev_cfp;

  Data_Get_Struct(control_frame, struct RubyInternalControlFrame, cfp);

  GetThreadPtr(cfp->thread, th);

  prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp->control_frame);

  printf("current: %p\n", cfp->control_frame);
  printf("prev: %p\n", prev_cfp);
  printf("th->stack: %p\n", th->stack);
  printf("th->stack + th->stack_size: %p\n", th->stack + th->stack_size);

  if((void *)(th->stack + th->stack_size) == (void *)prev_cfp)
  {
    return Qnil;
  }
  else
  {
    VALUE cfp_v;
    struct RubyInternalControlFrame * new_cfp;

    cfp_v = Data_Make_Struct(
        rb_cVmControlFrame,
        struct RubyInternalControlFrame,
        mark_ruby_internal_control_frame,
        free,
        new_cfp);

    new_cfp->control_frame = prev_cfp;
    new_cfp->thread = cfp->thread;

    return cfp_v;
  }
}

#procObject

Return the frame’s proc member.



73
74
75
76
77
78
# File 'ext/internal/vm/control_frame/control_frame.c', line 73

static VALUE control_frame_proc(VALUE control_frame)
{
  struct RubyInternalControlFrame * cfp;
  Data_Get_Struct(control_frame, struct RubyInternalControlFrame, cfp);
  return cfp->control_frame->proc;
}

#selfObject

Return the frame’s self member.

Returns:



40
41
42
43
44
45
# File 'ext/internal/vm/control_frame/control_frame.c', line 40

static VALUE control_frame_self(VALUE control_frame)
{
  struct RubyInternalControlFrame * cfp;
  Data_Get_Struct(control_frame, struct RubyInternalControlFrame, cfp);
  return cfp->control_frame->self;
}