Exemple #1
0
/* Emit jit instructions to set the current sourceline and sourcefile.
 */
static VALUE function_set_ruby_source(VALUE self, VALUE node_v)
{
#ifndef RUBY_VM
  NODE * n;
  jit_function_t function;

  Data_Get_Struct(self, struct _jit_function, function);
  Data_Get_Struct(node_v, NODE, n); // TODO: type check

  VALUE value_objects = (VALUE)jit_function_get_meta(function, RJT_VALUE_OBJECTS);

  jit_constant_t c;

  c.type = jit_type_int;
  c.un.int_value = nd_line(n);
  jit_value_t line = jit_value_create_constant(function, &c);

  c.type = jit_type_void_ptr;
  c.un.ptr_value = n->nd_file;
  jit_value_t file = jit_value_create_constant(function, &c);

  c.type = jit_type_void_ptr;
  c.un.ptr_value = n;
  jit_value_t node = jit_value_create_constant(function, &c);

  c.type = jit_type_void_ptr;
  c.un.ptr_value = &ruby_sourceline;
  jit_value_t ruby_sourceline_ptr = jit_value_create_constant(function, &c);

  c.type = jit_type_void_ptr;
  c.un.ptr_value = &ruby_sourcefile;
  jit_value_t ruby_sourcefile_ptr = jit_value_create_constant(function, &c);

  c.type = jit_type_void_ptr;
  c.un.ptr_value = &ruby_current_node;
  jit_value_t ruby_current_node_ptr = jit_value_create_constant(function, &c);

  jit_insn_store_relative(function, ruby_sourceline_ptr, 0, line);
  jit_insn_store_relative(function, ruby_sourcefile_ptr, 0, file);
  jit_insn_store_relative(function, ruby_current_node_ptr, 0, node);

  rb_ary_push(value_objects, node_v);

#else
  /* TODO: Not sure what to do on 1.9 yet */
#endif

  return Qnil;
}
/*@
 * @deftypemethod jit_function {static jit_function *} from_raw (jit_function_t @var{func})
 * Find the C++ @code{jit_function} object that is associated with a
 * raw C @code{jit_function_t} pointer.  Returns NULL if there is
 * no such object.
 * @end deftypemethod
@*/
jit_function *jit_function::from_raw(jit_function_t func)
{
	return (jit_function *)jit_function_get_meta(func, JITPP_MAPPING);
}