mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Revert "Revert "This commit implements the Object Shapes technique in CRuby.""
This reverts commit 9a6803c90b
.
This commit is contained in:
parent
5ffbb2be18
commit
ad63b668e2
41 changed files with 2311 additions and 893 deletions
10
marshal.c
10
marshal.c
|
@ -39,6 +39,7 @@
|
|||
#include "ruby/st.h"
|
||||
#include "ruby/util.h"
|
||||
#include "builtin.h"
|
||||
#include "shape.h"
|
||||
|
||||
#define BITSPERSHORT (2*CHAR_BIT)
|
||||
#define SHORTMASK ((1<<BITSPERSHORT)-1)
|
||||
|
@ -622,10 +623,6 @@ w_obj_each(st_data_t key, st_data_t val, st_data_t a)
|
|||
}
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
if (!ivarg->num_ivar) {
|
||||
rb_raise(rb_eRuntimeError, "instance variable added to %"PRIsVALUE" instance",
|
||||
CLASS_OF(arg->obj));
|
||||
}
|
||||
--ivarg->num_ivar;
|
||||
w_symbol(ID2SYM(id), arg->arg);
|
||||
w_object(value, arg->arg, arg->limit);
|
||||
|
@ -720,6 +717,7 @@ has_ivars(VALUE obj, VALUE encname, VALUE *ivobj)
|
|||
static void
|
||||
w_ivar_each(VALUE obj, st_index_t num, struct dump_call_arg *arg)
|
||||
{
|
||||
shape_id_t shape_id = rb_shape_get_shape_id(arg->obj);
|
||||
struct w_ivar_arg ivarg = {arg, num};
|
||||
if (!num) return;
|
||||
rb_ivar_foreach(obj, w_obj_each, (st_data_t)&ivarg);
|
||||
|
@ -727,6 +725,10 @@ w_ivar_each(VALUE obj, st_index_t num, struct dump_call_arg *arg)
|
|||
rb_raise(rb_eRuntimeError, "instance variable removed from %"PRIsVALUE" instance",
|
||||
CLASS_OF(arg->obj));
|
||||
}
|
||||
if (shape_id != rb_shape_get_shape_id(arg->obj)) {
|
||||
rb_raise(rb_eRuntimeError, "instance variable added to %"PRIsVALUE" instance",
|
||||
CLASS_OF(arg->obj));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue