Class: JIT::Context

Inherits:
Object
  • Object
show all
Defined in:
ext/jit_ext.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build {|context| ... } ⇒ Object

Create a context and acquire a lock on it, then yield the context to the block.

Yields:

  • (context)


205
206
207
208
# File 'ext/jit_ext.c', line 205

static VALUE context_s_build(VALUE klass)
{
  return context_build(context_s_new(klass));
}

.context=(Context) ⇒ Object

Create a new context.



151
152
153
154
155
156
# File 'ext/jit_ext.c', line 151

static VALUE context_s_new(VALUE klass)
{
  jit_context_t context = jit_context_create();
  jit_context_set_meta(context, RJT_FUNCTIONS, (void*)rb_ary_new(), 0);
  return Data_Wrap_Struct(rb_cContext, context_mark, jit_context_destroy, context);
}

Instance Method Details

#build { ... } ⇒ Object

Acquire a lock on the context so it can be used to build a function.

Yields:



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'ext/jit_ext.c', line 164

static VALUE context_build(VALUE self)
{
  jit_context_t context;
  Data_Get_Struct(self, struct _jit_context, context);
  jit_context_build_start(context);
#ifdef HAVE_RB_ENSURE
  return rb_ensure(
      rb_yield,
      self,
      RUBY_METHOD_FUNC(jit_context_build_end),
      (VALUE)context);
#else
  /* Rubinius does not yet have rb_ensure */
  rb_yield(self);
  jit_context_build_end(context);
#endif
}

#function=(context) {|f| ... } ⇒ Object

Acquire a lock on the context so it can be used to build a function.

Yields:

  • (f)


190
191
192
193
194
195
196
# File 'ext/jit_ext.c', line 190

static VALUE context_compile_function(VALUE self, VALUE signature)
{
  /* TODO: support passing in parent function */
  VALUE argv[] = { self, signature };
  int argc = 2;
  return function_s_compile(argc, argv, rb_cFunction);
}