diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-21 09:18:10 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-21 09:18:10 +0900 |
| commit | 45b0e1f788e9085be5039bb4b83aa4bbfaa2d1ca (patch) | |
| tree | 208b2fc7f56dc078e1e789d59706b4a2377bc98e | |
| parent | c2d8b0303db286a8d025844fbff2ee0685789977 (diff) | |
| download | mruby-45b0e1f788e9085be5039bb4b83aa4bbfaa2d1ca.tar.gz mruby-45b0e1f788e9085be5039bb4b83aa4bbfaa2d1ca.zip | |
should be able to create hash with 127+ entries; close #1894
| -rw-r--r-- | src/codegen.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/codegen.c b/src/codegen.c index 317ce6232..9b14d1530 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -1501,16 +1501,32 @@ codegen(codegen_scope *s, node *tree, int val) case NODE_HASH: { int len = 0; + mrb_bool update = FALSE; while (tree) { codegen(s, tree->car->car, val); codegen(s, tree->car->cdr, val); len++; tree = tree->cdr; + if (val && len == 126) { + pop_n(len*2); + genop(s, MKOP_ABC(OP_HASH, cursp(), cursp(), len)); + if (update) { + pop(); + genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "merge")), 1)); + } + push(); + update = TRUE; + len = 0; + } } if (val) { pop_n(len*2); genop(s, MKOP_ABC(OP_HASH, cursp(), cursp(), len)); + if (update) { + pop(); + genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "merge")), 1)); + } push(); } } |
