Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch '2.2' into fix-process-spawn
* 2.2:
  allow nil,true,false to be modified when frozen
  • Loading branch information
tak1n committed Oct 15, 2015
2 parents 29674df + a2d76f5 commit 3a4c3fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions vm/builtin/access_variable.cpp
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
9 changes: 8 additions & 1 deletion vm/builtin/object.cpp
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions vm/builtin/object.hpp
Expand Up @@ -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 */

Expand Down

0 comments on commit 3a4c3fd

Please sign in to comment.