Yukihiro "Matz" Matsumoto
cb3a6dd168
ISO C99 doesn't support unnamed unions; fix #5354
2021-03-08 11:50:52 +09:00
Yukihiro "Matz" Matsumoto
b64ec814d6
Fix a signed shift bug on 32 bit platforms; ref e1c9e7e
2021-01-12 16:26:05 +09:00
Yukihiro "Matz" Matsumoto
9fbf0ef886
Refactoring integer ranges.
...
- Remove `mrb_ssize`
- Fix `MRB_FIXNUM_{MIN,MAX}` to 32 bits on `MRB_NAN_BOXING`
2020-11-17 12:41:10 +09:00
Yukihiro "Matz" Matsumoto
3107d1caae
Allow int size combinations for MRB_WORD_BOXING.
...
- `MRB_64BIT` and `MRB_INT32`
- `MRB_32BIT` and `MRB_INT64`
2020-11-16 22:49:55 +09:00
KOBAYASHI Shuji
8a019106c0
Use uintptr_t instead of unsigned long in include/mruby/boxing_word.h
...
`mrb_bool` on LLP64 environment seems to become false if, for example,
`mrb_value` is a pointer whose lower 32 bits are 0.
2020-11-16 16:04:05 +09:00
dearblue
926ec1dc7e
Define mrb_value in struct for Word/NaN boxing
...
This is to make it possible to distinguish between `mrb_value` and `mrb_sym` in C++ "Function overloading" and C11 "Generic selection".
2020-11-08 14:14:00 +09:00
Yukihiro "Matz" Matsumoto
9b8e5658ce
Fix integer casting on 64 bit platforms.
...
On platforms where `sizeof(long)` is 4, casting `(long)` can lose data
or sign information.
2020-10-12 18:20:18 +09:00
Yukihiro "Matz" Matsumoto
2b188ed8a1
Reorganize Integer system.
...
- Integrate `Fixnum` and `Integer`
- Remove `Integral`
- `int / int -> int`
- Replace `mrb_fixnum()` to `mrb_int()`
- Replace `mrb_fixnum_value()` to `mrb_int_value()`.
- Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12 18:19:54 +09:00
Yukihiro "Matz" Matsumoto
5a7cbebc8a
Remove MRB_NO_FLOAT_INLINE and MRB_WBOX_FLOAT_INLINE configuration.
...
They are not used from the beginning.
2020-10-12 16:21:49 +09:00
Yukihiro "Matz" Matsumoto
55163a8a0a
Rename MRB_TT_FIXNUM to MRB_TT_INTEGER.
...
We still have `#define MRB_TT_FIXNUM MRB_TT_INTEGER` for compatibility.
2020-10-12 16:21:47 +09:00
Yukihiro "Matz" Matsumoto
8a87549315
Rename float configuration option names.
...
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT`
- `MRB_USE_FLOAT` => `MRB_USE_FLOAT32`
The former is to use `USE_XXX` naming convention. The latter is to make
sure `float` is 32bit float and not floating point number in general.
2020-10-12 16:21:40 +09:00
Yukihiro "Matz" Matsumoto
4e56e0defc
Rename union mrb_value to union mrb_value_.
...
Since some compiler complains when we `typedef` `mrb_value`.
2020-10-12 16:21:30 +09:00
Yukihiro "Matz" Matsumoto
53e46be7e2
Simplify mrb_value structure for MRB_WORD_BOXING.
2020-10-12 16:21:29 +09:00
Yukihiro "Matz" Matsumoto
3d8a38bea4
You don't need to keep index in local variables info in irep.
2020-10-12 16:21:22 +09:00
Yukihiro "Matz" Matsumoto
d428fa0c4a
Replace entire irep->pool.
...
Changes:
- `pool format is completely replaced
- supported types: `STR`, `INT32`, `INT64`, `FLOAT`
- `FLOAT` may be replaced by binary representation in the future
- insert `NUL` after string literals in `mrb` files
- `irep->pool` no longer store values in `mrb_value`
- instead it stores in `mrb_pool_value`
- less allocation
- `mrb_irep` can be stored in ROM
2020-10-12 16:21:08 +09:00
Yukihiro "Matz" Matsumoto
f93dffb5ee
Remove unused MRB_TT_FILE.
2020-06-15 07:47:22 +09:00
dearblue
d0501c69b0
Fix MRB_TT_CPTR object with MRB_NAN_BOXING
...
Previously, if `MRB_NAN_BOXING` is defined, for example,
`mrb_cptr_value()` could not keep an odd address.
If it is `MRB_32BIT`, it can be embedded in `NaN` as it is.
If it is `MRB_64BIT`, some operations are shared with `MRB_WORD_BOXING`.
In this case, the MRB_API function `mrb_nan_boxing_cptr_value()` is
defined.
2020-04-13 23:12:09 +09:00
Yukihiro "Matz" Matsumoto
ff57c0278f
Remove broken MRB_INT16 configuration option.
2020-01-15 21:32:00 +09:00
KOBAYASHI Shuji
a53f28275e
Fix MRB_FIXNUM_SHIFT with MRB_WORD_BOXING, MRB_INT32 and MRB_64BIT
...
### Example
```ruby
# example.rb
max32 = 2**30 - 1 + 2**30
min32 = -max32-1
[max32, max32+1, min32, min32-1].each{|n| p [n, n.class]}
```
#### Before this patch:
```
$ bin/mruby example.rb
[2147483647, Float]
[2147483648, Float]
[-2147483648, Float]
[-2147483649, Float]
```
#### After this patch:
```
$ bin/mruby example.rb
[2147483647, Fixnum]
[2147483648, Float]
[-2147483648, Fixnum]
[-2147483649, Float]
```
2019-12-01 22:09:38 +09:00
KOBAYASHI Shuji
375c1ebc41
Rename BITSIZE to BIT and BIT to BIT_POS for consistency
...
The bit width terminology is unified to `BIT` according to `MRB_INT_BIT`
and `CHAR_BIT`. Also the bit position terminology is unified to `BIT_POS`.
2019-11-23 20:40:23 +09:00
KOBAYASHI Shuji
feaf80d899
Use type predicate macros instead of mrb_type if possible
...
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for
all `enum mrb_vtype`).
2019-09-26 22:23:27 +09:00
KOBAYASHI Shuji
5dda4f5da3
Implement all type predicate macros for MRB_WORD_BOXING
...
The default implementations of type predicate macros use `mrb_type`.
But `mrb_type` with `MRB_WORD_BOXING` isn't very efficient, so the new
implementations avoid `mrb_type`.
2019-09-22 22:36:12 +09:00
KOBAYASHI Shuji
7fcda585bc
Refactor mrb_type in include/mruby/boxing_word.h
2019-09-15 18:11:16 +09:00
KOBAYASHI Shuji
d47bd0a2cd
Optimize mrb_bool() with MRB_WORD_BOXING
2019-09-08 12:17:25 +09:00
KOBAYASHI Shuji
17c53040ab
Increase symbol bit size on 32-bit mode with MRB_WORD_BOXING
...
This change increases the max length of lower inline symbols to 5 bytes.
2019-09-07 21:38:11 +09:00
KOBAYASHI Shuji
19e2cc187b
Avoid bit fields in mrb_value; ref b2c3d88f
...
The changes at b2c3d88f were inappropriate because the memory layout of bit
fields are implementation defined. Therefor, I fixed it not to use bit
fields.
2019-09-06 13:24:35 +09:00
KOBAYASHI Shuji
b2c3d88fbf
Implement mrb_immediate_p macro for MRB_WORD_BOXING
...
The default implementation of `mrb_immediate_p` uses `mrb_type`. However,
in `MRB_WORD_BOXING`, `mrb_type` has many branches and is inefficient, so
provide an implementation that does not use `mrb_type`.
2019-08-31 16:55:57 +09:00
David Siaw
b5299b1c58
fix up documentation for values
2019-08-18 20:12:44 +09:00
KOBAYASHI Shuji
4d9d6faf0d
Remove unneeded statement in SET_OBJ_VALUE with boxing_word.h
...
`(r).value.bp` and `v` have the same value due to assignment of the line
preceding the removed line.
2019-06-19 17:50:20 +09:00
Yukihiro "Matz" Matsumoto
49cb149033
Merge pull request #4391 from dearblue/inlines
...
Change modifier to `MRB_INLINE` from `static inline`
2019-04-22 21:17:27 +09:00
KOBAYASHI Shuji
b212050026
Expand BOXWORD_SET_VALUE() macro in include/mruby/boxing_word.h
...
In `SET_OBJ_VALUE()`, branch isn't removed because `switch` condition isn't
constant expression.
2019-04-20 21:23:58 +09:00
dearblue
125c3bef19
Add mrb_true_p() and mrb_false_p() macro functions
2019-04-19 22:50:05 +09:00
dearblue
6907e97fa1
Change modifier to MRB_INLINE from static inline
2019-04-19 22:24:22 +09:00
dearblue
e19353be25
Fix macro expressions with paren
2018-12-18 23:14:26 +09:00
dearblue
14133f4057
Fix macro arguments with paren
2018-12-18 23:05:36 +09:00
dearblue
ca01c8792d
Fix mrb_value size with MRB_WORD_BOXING on 32-bit mode
2018-08-05 20:33:44 +09:00
YAMAMOTO Masaya
acdc2d1f24
Add MRB_WITHOUT_FLOAT
2017-10-11 17:58:11 +09:00
Yukihiro "Matz" Matsumoto
9e40586d43
Add cast to mrb_int in mrb_fixnum() when MRB_WORD_BOXING.
...
Without this cast, `long int:63` can cause warnings.
2017-05-26 02:16:18 +09:00
Yukihiro "Matz" Matsumoto
51d7a69ab0
Clear (o).w first for MRB_WORD_BOXING; ref #3396
2017-01-25 11:07:57 +09:00
Tomasz Dabrowski
3fdfd8cb4a
Safeguard against using MRB_INT64 with MRB_WORD_BOXING in 32-bit mode
2016-11-27 12:49:36 +01:00
cremno
4c868a9562
remove SET_PROC_VALUE() macro
...
It isn't used anymore since the #2791 merge. It's also unlikely to be
needed again as it wasn't before (its usage was unnecessary).
2015-05-17 22:25:55 +02:00
furunkel
99a00cf417
Avoid unnecessary stores and reloads
2015-05-12 13:46:56 +02:00
Yukihiro "Matz" Matsumoto
2b3675bca1
word_boxing.h used int to represent symbols; use mrb_sym instead
2014-10-03 11:02:06 +09:00
Yukihiro "Matz" Matsumoto
206f89e209
add MRB_API modifiers to mruby API functions
2014-08-04 00:47:08 +09:00
take_cheeze
fc8b48faf8
Move word boxing structs to "mruby/boxing_word.h".
2014-07-20 23:02:04 +09:00
Yukihiro "Matz" Matsumoto
61bba9accf
rename word boxing functions
2014-07-09 06:40:56 +09:00
Yukihiro "Matz" Matsumoto
0cf86dea0e
rename SET_FIXNUM_VALUE to SET_INT_VALUE since it sets mrb_int value
2014-07-09 06:40:19 +09:00
David Turnbull
249f05e7d7
Clean up value.h and mrb_value boxing
2014-07-09 06:32:11 +09:00