MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / codeconcat

Function codeconcat

lib/lua/src/lcode.c:1685–1699  ·  view source on GitHub ↗

** Create code for '(e1 .. e2)'. ** For '(e1 .. e2.1 .. e2.2)' (which is '(e1 .. (e2.1 .. e2.2))', ** because concatenation is right associative), merge both CONCATs. */

Source from the content-addressed store, hash-verified

1683** because concatenation is right associative), merge both CONCATs.
1684*/
1685static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) {
1686 Instruction *ie2 = previousinstruction(fs);
1687 if (GET_OPCODE(*ie2) == OP_CONCAT) { /* is 'e2' a concatenation? */
1688 int n = GETARG_B(*ie2); /* # of elements concatenated in 'e2' */
1689 lua_assert(e1->u.info + 1 == GETARG_A(*ie2));
1690 freeexp(fs, e2);
1691 SETARG_A(*ie2, e1->u.info); /* correct first element ('e1') */
1692 SETARG_B(*ie2, n + 1); /* will concatenate one more element */
1693 }
1694 else { /* 'e2' is not a concatenation */
1695 luaK_codeABC(fs, OP_CONCAT, e1->u.info, 2, 0); /* new concat opcode */
1696 freeexp(fs, e2);
1697 luaK_fixline(fs, line);
1698 }
1699}
1700
1701
1702/*

Callers 1

luaK_posfixFunction · 0.85

Calls 3

previousinstructionFunction · 0.85
freeexpFunction · 0.85
luaK_fixlineFunction · 0.85

Tested by

no test coverage detected