mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Move "special consts" so Qundef
and Qnil
differ just 1 bit
This commit is contained in:
parent
1e66d3b853
commit
f55212bce9
Notes:
git
2022-10-20 13:05:47 +00:00
5 changed files with 18 additions and 18 deletions
|
@ -24,7 +24,7 @@
|
||||||
* In released versions of Ruby, this number is not defined since teeny
|
* In released versions of Ruby, this number is not defined since teeny
|
||||||
* versions of Ruby should guarantee ABI compatibility.
|
* versions of Ruby should guarantee ABI compatibility.
|
||||||
*/
|
*/
|
||||||
#define RUBY_ABI_VERSION 2
|
#define RUBY_ABI_VERSION 3
|
||||||
|
|
||||||
/* Windows does not support weak symbols so ruby_abi_version will not exist
|
/* Windows does not support weak symbols so ruby_abi_version will not exist
|
||||||
* in the shared library. */
|
* in the shared library. */
|
||||||
|
|
|
@ -94,9 +94,9 @@ ruby_special_consts {
|
||||||
RUBY_SYMBOL_FLAG, /**< Flag to denote a static symbol. */
|
RUBY_SYMBOL_FLAG, /**< Flag to denote a static symbol. */
|
||||||
#elif USE_FLONUM
|
#elif USE_FLONUM
|
||||||
RUBY_Qfalse = 0x00, /* ...0000 0000 */
|
RUBY_Qfalse = 0x00, /* ...0000 0000 */
|
||||||
|
RUBY_Qnil = 0x04, /* ...0000 0100 */
|
||||||
RUBY_Qtrue = 0x14, /* ...0001 0100 */
|
RUBY_Qtrue = 0x14, /* ...0001 0100 */
|
||||||
RUBY_Qnil = 0x08, /* ...0000 1000 */
|
RUBY_Qundef = 0x24, /* ...0010 0100 */
|
||||||
RUBY_Qundef = 0x34, /* ...0011 0100 */
|
|
||||||
RUBY_IMMEDIATE_MASK = 0x07, /* ...0000 0111 */
|
RUBY_IMMEDIATE_MASK = 0x07, /* ...0000 0111 */
|
||||||
RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */
|
RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */
|
||||||
RUBY_FLONUM_MASK = 0x03, /* ...0000 0011 */
|
RUBY_FLONUM_MASK = 0x03, /* ...0000 0011 */
|
||||||
|
@ -104,9 +104,9 @@ ruby_special_consts {
|
||||||
RUBY_SYMBOL_FLAG = 0x0c, /* ...xxxx 1100 */
|
RUBY_SYMBOL_FLAG = 0x0c, /* ...xxxx 1100 */
|
||||||
#else
|
#else
|
||||||
RUBY_Qfalse = 0x00, /* ...0000 0000 */
|
RUBY_Qfalse = 0x00, /* ...0000 0000 */
|
||||||
RUBY_Qtrue = 0x02, /* ...0000 0010 */
|
RUBY_Qnil = 0x02, /* ...0000 0010 */
|
||||||
RUBY_Qnil = 0x04, /* ...0000 0100 */
|
RUBY_Qtrue = 0x06, /* ...0000 0110 */
|
||||||
RUBY_Qundef = 0x06, /* ...0000 0110 */
|
RUBY_Qundef = 0x0a, /* ...0000 1010 */
|
||||||
RUBY_IMMEDIATE_MASK = 0x03, /* ...0000 0011 */
|
RUBY_IMMEDIATE_MASK = 0x03, /* ...0000 0011 */
|
||||||
RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */
|
RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */
|
||||||
RUBY_FLONUM_MASK = 0x00, /* any values ANDed with FLONUM_MASK cannot be FLONUM_FLAG */
|
RUBY_FLONUM_MASK = 0x00, /* any values ANDed with FLONUM_MASK cannot be FLONUM_FLAG */
|
||||||
|
@ -138,20 +138,20 @@ RB_TEST(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* if USE_FLONUM
|
* if USE_FLONUM
|
||||||
* Qfalse: ....0000 0000
|
* Qfalse: ....0000 0000
|
||||||
* Qnil: ....0000 1000
|
|
||||||
* ~Qnil: ....1111 0111
|
|
||||||
* v ....xxxx xxxx
|
|
||||||
* ----------------------------
|
|
||||||
* RTEST(v) ....xxxx 0xxx
|
|
||||||
*
|
|
||||||
* if ! USE_FLONUM
|
|
||||||
* Qfalse: ....0000 0000
|
|
||||||
* Qnil: ....0000 0100
|
* Qnil: ....0000 0100
|
||||||
* ~Qnil: ....1111 1011
|
* ~Qnil: ....1111 1011
|
||||||
* v ....xxxx xxxx
|
* v ....xxxx xxxx
|
||||||
* ----------------------------
|
* ----------------------------
|
||||||
* RTEST(v) ....xxxx x0xx
|
* RTEST(v) ....xxxx x0xx
|
||||||
*
|
*
|
||||||
|
* if ! USE_FLONUM
|
||||||
|
* Qfalse: ....0000 0000
|
||||||
|
* Qnil: ....0000 0010
|
||||||
|
* ~Qnil: ....1111 1101
|
||||||
|
* v ....xxxx xxxx
|
||||||
|
* ----------------------------
|
||||||
|
* RTEST(v) ....xxxx xx0x
|
||||||
|
*
|
||||||
* RTEST(v) can be 0 if and only if (v == Qfalse || v == Qnil).
|
* RTEST(v) can be 0 if and only if (v == Qfalse || v == Qnil).
|
||||||
*/
|
*/
|
||||||
return obj & ~RUBY_Qnil;
|
return obj & ~RUBY_Qnil;
|
||||||
|
|
1
ruby.c
1
ruby.c
|
@ -64,6 +64,7 @@
|
||||||
|
|
||||||
#define singlebit_only_p(x) !((x) & ((x)-1))
|
#define singlebit_only_p(x) !((x) & ((x)-1))
|
||||||
STATIC_ASSERT(Qnil_1bit_from_Qfalse, singlebit_only_p(Qnil^Qfalse));
|
STATIC_ASSERT(Qnil_1bit_from_Qfalse, singlebit_only_p(Qnil^Qfalse));
|
||||||
|
STATIC_ASSERT(Qundef_1bit_from_Qnil, singlebit_only_p(Qundef^Qnil));
|
||||||
|
|
||||||
#ifndef MAXPATHLEN
|
#ifndef MAXPATHLEN
|
||||||
# define MAXPATHLEN 1024
|
# define MAXPATHLEN 1024
|
||||||
|
|
|
@ -3219,8 +3219,7 @@ fn gen_branchif(
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test if any bit (outside of the Qnil bit) is on
|
// Test if any bit (outside of the Qnil bit) is on
|
||||||
// RUBY_Qfalse /* ...0000 0000 */
|
// See RB_TEST()
|
||||||
// RUBY_Qnil /* ...0000 1000 */
|
|
||||||
let val_type = ctx.get_opnd_type(StackOpnd(0));
|
let val_type = ctx.get_opnd_type(StackOpnd(0));
|
||||||
let val_opnd = ctx.stack_pop(1);
|
let val_opnd = ctx.stack_pop(1);
|
||||||
|
|
||||||
|
|
|
@ -597,11 +597,11 @@ where
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub const Qfalse: VALUE = VALUE(0);
|
pub const Qfalse: VALUE = VALUE(0);
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub const Qnil: VALUE = VALUE(8);
|
pub const Qnil: VALUE = VALUE(4);
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub const Qtrue: VALUE = VALUE(20);
|
pub const Qtrue: VALUE = VALUE(20);
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub const Qundef: VALUE = VALUE(52);
|
pub const Qundef: VALUE = VALUE(0x24);
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
mod manual_defs {
|
mod manual_defs {
|
||||||
|
|
Loading…
Reference in a new issue