MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / codeconcat

Function codeconcat

xrepo/packages/l/lua/port/lua/src/lcode.c:1640–1654  ·  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

1638** because concatenation is right associative), merge both CONCATs.
1639*/
1640static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) {
1641 Instruction *ie2 = previousinstruction(fs);
1642 if (GET_OPCODE(*ie2) == OP_CONCAT) { /* is 'e2' a concatenation? */
1643 int n = GETARG_B(*ie2); /* # of elements concatenated in 'e2' */
1644 lua_assert(e1->u.info + 1 == GETARG_A(*ie2));
1645 freeexp(fs, e2);
1646 SETARG_A(*ie2, e1->u.info); /* correct first element ('e1') */
1647 SETARG_B(*ie2, n + 1); /* will concatenate one more element */
1648 }
1649 else { /* 'e2' is not a concatenation */
1650 luaK_codeABC(fs, OP_CONCAT, e1->u.info, 2, 0); /* new concat opcode */
1651 freeexp(fs, e2);
1652 luaK_fixline(fs, line);
1653 }
1654}
1655
1656
1657/*

Callers 1

luaK_posfixFunction · 0.85

Calls 3

previousinstructionFunction · 0.85
freeexpFunction · 0.85
luaK_fixlineFunction · 0.85

Tested by

no test coverage detected