Skip to content
Permalink
Browse files
Generalize test for nil.
  • Loading branch information
brixen committed Jan 8, 2016
1 parent 161a645 commit da81b5daf4bf4633944caef8b898762eabada5ea
Showing with 5 additions and 2 deletions.
  1. +5 −2 vm/oop.hpp
@@ -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)
@@ -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 {

0 comments on commit da81b5d

Please sign in to comment.