Skip to content

Commit

Permalink
Generalize test for nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Jan 8, 2016
1 parent 161a645 commit da81b5d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vm/oop.hpp
Expand Up @@ -93,7 +93,10 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);

// Indicates the mask to use to check if a value is ruby false.
// This mask matches both false and nil ONLY.
#define FALSE_MASK 0xf
#define FALSE_MASK 0xf

// The bits that identify any nil value.
#define NIL_MASK 0x1f

#define CBOOL(v) (((uintptr_t)(v) & FALSE_MASK) != (uintptr_t)cFalse)
#define RBOOL(v) ((v) ? cTrue : cFalse)
Expand Down Expand Up @@ -586,7 +589,7 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
void wait(STATE);

bool nil_p() const {
return this == reinterpret_cast<ObjectHeader*>(cNil);
return (reinterpret_cast<intptr_t>(this) & NIL_MASK) == reinterpret_cast<intptr_t>(cNil);
}

bool true_p() const {
Expand Down

0 comments on commit da81b5d

Please sign in to comment.