diff options
| -rw-r--r-- | mrblib/compar.rb | 52 | ||||
| -rw-r--r-- | src/codegen.c | 3 |
2 files changed, 47 insertions, 8 deletions
diff --git a/mrblib/compar.rb b/mrblib/compar.rb index 3badf57de..9f2ab887d 100644 --- a/mrblib/compar.rb +++ b/mrblib/compar.rb @@ -1,5 +1,15 @@ +## +# Comparable +# +# ISO 15.3.3 module Comparable - # 15.3.3.2.1 + + ## + # Return true if +self+ is less + # than +other+. Otherwise return + # false. + # + # ISO 15.3.3.2.1 def < other cmp = self <=> other if cmp.nil? @@ -11,7 +21,12 @@ module Comparable end end - # 15.3.3.2.2 + ## + # Return true if +self+ is less + # than or equal to +other+. + # Otherwise return false. + # + # ISO 15.3.3.2.2 def <= other cmp = self <=> other if cmp.nil? @@ -23,7 +38,12 @@ module Comparable end end - # 15.3.3.2.3 + ## + # Return true if +self+ is equal + # to +other+. Otherwise return + # false. + # + # ISO 15.3.3.2.3 def == other cmp = self <=> other if cmp == 0 @@ -33,7 +53,12 @@ module Comparable end end - # 15.3.3.2.4 + ## + # Return true if +self+ is greater + # than +other+. Otherwise return + # false. + # + # ISO 15.3.3.2.4 def > other cmp = self <=> other if cmp.nil? @@ -45,9 +70,14 @@ module Comparable end end - # 15.3.3.2.5 + ## + # Return true if +self+ is greater + # than or equal to +other+. + # Otherwise return false. + # + # ISO 15.3.3.2.5 def >= other - cmp = self <=> other + cmp = self <=> other if cmp.nil? false elsif cmp >= 0 @@ -57,8 +87,14 @@ module Comparable end end - # 15.3.3.2.6 - def between?(min,max) + ## + # Return true if +self+ is greater + # than or equal to +min+ and + # less than or equal to +max+. + # Otherwise return false. + # + # ISO 15.3.3.2.6 + def between?(min, max) if self < min or self > max false else diff --git a/src/codegen.c b/src/codegen.c index 5e2b7083f..11e9eb236 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -64,6 +64,7 @@ typedef struct scope { int nlocals; int nregs; + int ai; int idx; } codegen_scope; @@ -1849,6 +1850,7 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *lv) p->lv = lv; p->sp += node_len(lv)+2; p->nlocals = p->sp; + p->ai = mrb->arena_idx; p->idx = mrb->irep_len++; @@ -1882,6 +1884,7 @@ scope_finish(codegen_scope *s, int idx) irep->nlocals = s->nlocals; irep->nregs = s->nregs; + s->mrb->arena_idx = s->ai; mrb_pool_close(s->mpool); } |
