| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1642,7 +1642,7 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe) | |||
| 1642 | 1642 | { | |
| 1643 | 1643 | mrb_sym sym = name ? name : nsym(tree->cdr->car); | |
| 1644 | 1644 | int skip = 0; | |
| 1645 | - int n = 0, nk = 0, st = 0, noop = 0, blk = 0; | ||
| 1645 | + int n = 0, nk = 0, noop = 0, blk = 0, sp_save = cursp(); | ||
| 1646 | 1646 | ||
| 1647 | 1647 | codegen(s, tree->car, VAL); /* receiver */ | |
| 1648 | 1648 | if (safe) { | |
@@ -1653,9 +1653,8 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe) | |||
| 1653 | 1653 | tree = tree->cdr->cdr->car; | |
| 1654 | 1654 | if (tree) { | |
| 1655 | 1655 | if (tree->car) { /* positional arguments */ | |
| 1656 | - st = n = gen_values(s, tree->car, VAL, sp?1:0, 14); | ||
| 1656 | + n = gen_values(s, tree->car, VAL, sp?1:0, 14); | ||
| 1657 | 1657 | if (n < 0) { /* variable length */ | |
| 1658 | - st = 1; /* one stack element */ | ||
| 1659 | 1658 | noop = 1; /* not operator */ | |
| 1660 | 1659 | n = 15; | |
| 1661 | 1660 | push(); | |
@@ -1664,12 +1663,22 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe) | |||
| 1664 | 1663 | if (tree->cdr->car) { /* keyword arguments */ | |
| 1665 | 1664 | noop = 1; | |
| 1666 | 1665 | nk = gen_hash(s, tree->cdr->car->cdr, VAL, 14); | |
| 1667 | - if (nk < 0) {st++; nk = 15;} | ||
| 1668 | - else st += 2*nk; | ||
| 1666 | + if (nk < 0) nk = 15; | ||
| 1669 | 1667 | } | |
| 1670 | 1668 | } | |
| 1671 | 1669 | if (sp) { /* last argument pushed (attr=, []=) */ | |
| 1670 | + /* pack keyword arguments */ | ||
| 1671 | + if (nk > 0 && nk < 15) { | ||
| 1672 | + pop_n(nk*2); | ||
| 1673 | + genop_2(s, OP_HASH, cursp(), nk); | ||
| 1674 | + push(); | ||
| 1675 | + } | ||
| 1672 | 1676 | if (n == CALL_MAXARGS) { | |
| 1677 | + if (nk > 0) { | ||
| 1678 | + pop(); pop(); | ||
| 1679 | + genop_2(s, OP_ARYPUSH, cursp(), 1); | ||
| 1680 | + push(); | ||
| 1681 | + } | ||
| 1673 | 1682 | gen_move(s, cursp(), sp, 0); | |
| 1674 | 1683 | pop(); | |
| 1675 | 1684 | genop_2(s, OP_ARYPUSH, cursp(), 1); | |
@@ -1678,8 +1687,10 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe) | |||
| 1678 | 1687 | else { | |
| 1679 | 1688 | gen_move(s, cursp(), sp, 0); | |
| 1680 | 1689 | push(); | |
| 1681 | - n++; st++; | ||
| 1690 | + if (nk > 0) n++; | ||
| 1691 | + n++; | ||
| 1682 | 1692 | } | |
| 1693 | + nk = 0; | ||
| 1683 | 1694 | } | |
| 1684 | 1695 | if (tree && tree->cdr && tree->cdr->cdr) { | |
| 1685 | 1696 | codegen(s, tree->cdr->cdr, VAL); | |
@@ -1688,7 +1699,7 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe) | |||
| 1688 | 1699 | blk = 1; | |
| 1689 | 1700 | } | |
| 1690 | 1701 | push();pop(); | |
| 1691 | - pop_n(st+1); | ||
| 1702 | + s->sp = sp_save; | ||
| 1692 | 1703 | if (!noop && sym == MRB_OPSYM_2(s->mrb, add) && n == 1) { | |
| 1693 | 1704 | gen_addsub(s, OP_ADD, cursp()); | |
| 1694 | 1705 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments