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:

  • (RubyVM::InstructionSequence, nil)


69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'ext/internal/vm/control_frame/control_frame.c', line 69

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.

Returns:

  • (RubyVM::InstructionSequence)


43
44
45
46
47
48
# File 'ext/internal/vm/control_frame/control_frame.c', line 43

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)


131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'ext/internal/vm/control_frame/control_frame.c', line 131

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)


102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'ext/internal/vm/control_frame/control_frame.c', line 102

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.



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'ext/internal/vm/control_frame/control_frame.c', line 153

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.



89
90
91
92
93
94
# File 'ext/internal/vm/control_frame/control_frame.c', line 89

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:



56
57
58
59
60
61
# File 'ext/internal/vm/control_frame/control_frame.c', line 56

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