Compare commits

...

4 Commits

Author SHA1 Message Date
Hiroshi Mimaki 1a9bdfcde5 Update release date. 2020-08-06 12:45:59 +09:00
KOBAYASHI Shuji 112120969d Use type tag for hash code in ht_hash_func()
The function corresponding to `ht_hash_func()` was as follows in the days of
khash implementation (before d78acc7a).

  ```c
  mrb_hash_ht_hash_func(mrb_state *mrb, mrb_value key)
  {
    enum mrb_vtype t = mrb_type(key);
    ...
    switch (t) {
    ...
    default:
      hv = mrb_funcall(mrb, key, "hash", 0);
      h = (khint_t)t ^ (khint_t)mrb_fixnum(hv);
      break;
    }
    ...
  }
  ```

When switched to the segmented list implementation (d78acc7a), this function
was changed as follows.

  ```c
  sg_hash_func(mrb_state *mrb, seglist *t, mrb_value key)
  {
    enum mrb_vtype tt = mrb_type(key);
    ...
    switch (tt) {
    ...
    default:
      hv = mrb_funcall(mrb, key, "hash", 0);
      h = (size_t)t ^ (size_t)mrb_fixnum(hv);
      break;
    }
    ...
  }
  ```

Since the argument `t` was added, the variable for type tag was changed from
`t` to `tt`, but the variable used in the expression of `h` remained `t`.

Probably this is an omission of change, so fixed it.
2020-07-29 09:17:32 +09:00
Yukihiro "Matz" Matsumoto 63956036e1 Fix the VM stack handling bug in 'mrb_yield_with_class()`; fix #5042 2020-07-29 09:09:37 +09:00
dearblue cdf45438f0 Fixed shift width for MRB_ENV_SET_BIDX()
ref c07f24cd1 and close #5035
2020-07-29 09:05:29 +09:00
7 changed files with 36 additions and 20 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option:
```bash
$ mrdb --version
mruby 2.1.2 (2020-07-10)
mruby 2.1.2 (2020-08-06)
```
## 2.2 Basic Operation
+9 -9
View File
@@ -38,7 +38,7 @@ puts [1,2,3]
3
```
#### mruby [2.1.2 (2020-07-10)]
#### mruby [2.1.2 (2020-08-06)]
```
[1, 2, 3]
@@ -61,7 +61,7 @@ end
`ZeroDivisionError` is raised.
#### mruby [2.1.2 (2020-07-10)]
#### mruby [2.1.2 (2020-08-06)]
No exception is raised.
@@ -89,7 +89,7 @@ p Liste.new "foobar"
` [] `
#### mruby [2.1.2 (2020-07-10)]
#### mruby [2.1.2 (2020-08-06)]
`ArgumentError` is raised.
@@ -119,7 +119,7 @@ false
true
```
#### mruby [2.1.2 (2020-07-10)]
#### mruby [2.1.2 (2020-08-06)]
```
true
@@ -156,7 +156,7 @@ p 'ok'
ok
```
#### mruby [2.1.2 (2020-07-10)]
#### mruby [2.1.2 (2020-08-06)]
```
test.rb:8: undefined method 'test_func' (NoMethodError)
@@ -178,7 +178,7 @@ defined?(Foo)
nil
```
#### mruby [2.1.2 (2020-07-10)]
#### mruby [2.1.2 (2020-08-06)]
`NameError` is raised.
@@ -195,7 +195,7 @@ alias $a $__a__
` nil `
#### mruby [2.1.2 (2020-07-10)]
#### mruby [2.1.2 (2020-08-06)]
Syntax error
@@ -217,7 +217,7 @@ end
`ArgumentError` is raised.
The re-defined `+` operator does not accept any arguments.
#### mruby [2.1.2 (2020-07-10)]
#### mruby [2.1.2 (2020-08-06)]
` 'ab' `
Behavior of the operator wasn't changed.
@@ -233,7 +233,7 @@ $ ruby -e 'puts Proc.new {}.binding'
#<Binding:0x00000e9deabb9950>
```
#### mruby [2.1.2 (2020-07-10)]
#### mruby [2.1.2 (2020-08-06)]
```
$ ./bin/mruby -e 'puts Proc.new {}.binding'
+1 -1
View File
@@ -34,7 +34,7 @@ struct REnv {
#define MRB_ENV_HEAP_P(e) ((e)->flags & MRB_ENV_HEAPED)
#define MRB_ENV_ONSTACK_P(e) (((e)->flags & MRB_ENV_CLOSED) == 0)
#define MRB_ENV_BIDX(e) (((e)->flags >> 8) & 0xff)
#define MRB_ENV_SET_BIDX(e,idx) ((e)->flags = (((e)->flags & ~(0xff<<8))|((unsigned int)(idx) & 0xff)<<10))
#define MRB_ENV_SET_BIDX(e,idx) ((e)->flags = (((e)->flags & ~(0xff<<8))|((unsigned int)(idx) & 0xff)<<8))
void mrb_env_unshare(mrb_state*, struct REnv*);
+2 -2
View File
@@ -67,12 +67,12 @@ MRB_BEGIN_DECL
/*
* Release month.
*/
#define MRUBY_RELEASE_MONTH 7
#define MRUBY_RELEASE_MONTH 8
/*
* Release day.
*/
#define MRUBY_RELEASE_DAY 10
#define MRUBY_RELEASE_DAY 6
/*
* Release date as a string.
+1 -1
View File
@@ -73,7 +73,7 @@ ht_hash_func(mrb_state *mrb, htable *t, mrb_value key)
default:
hv = mrb_funcall(mrb, key, "hash", 0);
h = (size_t)t ^ (size_t)mrb_fixnum(hv);
h = (size_t)tt ^ (size_t)mrb_fixnum(hv);
break;
}
if (index && (index != t->index || capa != index->capa)) {
+15 -6
View File
@@ -754,16 +754,25 @@ mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value
ci = cipush(mrb);
ci->mid = mid;
ci->proc = p;
ci->stackent = mrb->c->stack;
ci->argc = (int)argc;
ci->target_class = c;
ci->acc = CI_ACC_SKIP;
n = MRB_PROC_CFUNC_P(p) ? (int)(argc+2) : p->body.irep->nregs;
mrb->c->stack = mrb->c->stack + n;
ci->stackent = mrb->c->stack;
mrb->c->stack += n;
if (argc >= CALL_MAXARGS) {
ci->argc = -1;
n = 3;
}
else {
ci->argc = (int)argc;
n = argc + 2;
}
mrb_stack_extend(mrb, n);
mrb->c->stack[0] = self;
if (argc > 0) {
if (ci->argc < 0) {
mrb->c->stack[1] = mrb_ary_new_from_values(mrb, argc, argv);
argc = 1;
}
else if (argc > 0) {
stack_copy(mrb->c->stack+1, argv, argc);
}
mrb->c->stack[argc+1] = mrb_nil_value();
+7
View File
@@ -116,6 +116,13 @@ assert('Kernel#block_given?', '15.3.1.3.6') do
"block"
end
end
def bg_try_in_block
-> { block_given? }[]
end
assert_false bg_try_in_block
assert_true bg_try_in_block{}
end
assert('Kernel#class', '15.3.1.3.7') do