Skip to content
Permalink
Browse files
allow nil,true,false to be modified when frozen
  • Loading branch information
chuckremes committed Oct 12, 2015
1 parent c1f479d commit a2d76f56c3cecd886632d0f5d02b98b07e3fc106
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
@@ -49,7 +49,7 @@ namespace rubinius {

Object* recv = args.recv();

if(CBOOL(recv->frozen_p(state))) {
if(CBOOL(recv->frozen_p(state)) && CBOOL(recv->frozen_mod_disallowed(state))) {
Exception::frozen_error(state, call_frame, recv);
return 0;
}
@@ -66,7 +66,7 @@ namespace rubinius {

/* The writer case. */
if(access->write()->true_p()) {
if(CBOOL(self->frozen_p(state))) {
if(CBOOL(self->frozen_p(state)) && CBOOL(self->frozen_mod_disallowed(state))) {
Exception::frozen_error(state, call_frame, self);
return 0;
}
@@ -183,10 +183,17 @@ namespace rubinius {
}

void Object::check_frozen(STATE) {
if(CBOOL(frozen_p(state))) {
if(CBOOL(frozen_p(state)) && CBOOL(frozen_mod_disallowed(state))) {
Exception::frozen_error(state, this);
}
}

Object* Object::frozen_mod_disallowed(STATE) {
if(this->nil_p() || this->true_p() || this->false_p()) {
return cFalse;
}
return cTrue;
}

Object* Object::get_field(STATE, size_t index) {
return type_info(state)->get_field(state, this, index);
@@ -390,6 +390,13 @@ namespace rubinius {
* Similar to CRuby rb_check_frozen
*/
void check_frozen(STATE);

/**
* Returns true unless one of the objects is nil, true, or
* false. Those objects are allowed to be modified when
* frozen.
*/
Object* frozen_mod_disallowed(STATE);

public: /* accessors */

0 comments on commit a2d76f5

Please sign in to comment.