MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / separateparts

Function separateparts

other_src/lua/src/lpeg.cpp:1538–1569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1536
1537
1538static Instruction *separateparts (lua_State *L, Instruction *p1, int l1,
1539 int l2, int *size, CharsetTag *st2) {
1540 int sp = firstpart(p1, l1);
1541 if (sp == 0) /* first part is entire p1? */
1542 return basicUnion(L, p1, l1, l2, size, st2);
1543 else if ((p1 + sp - 1)->i.code == ICommit || !interfere(p1, sp, st2)) {
1544 Instruction *p;
1545 int init = *size;
1546 int end = init + sp;
1547 *size = end;
1548 p = separateparts(L, p1 + sp, l1 - sp, l2, size, st2);
1549 copypatt(p + init, p1, sp);
1550 (p + end - 1)->i.offset = *size - (end - 1);
1551 return p;
1552 }
1553 else { /* must change back to non-optimized choice */
1554 Instruction *p;
1555 int init = *size;
1556 int end = init + sp + 1; /* needs one extra instruction (choice) */
1557 int sizefirst = sizei(p1); /* size of p1's first instruction (the test) */
1558 *size = end;
1559 p = separateparts(L, p1 + sp, l1 - sp, l2, size, st2);
1560 copypatt(p + init, p1, sizefirst); /* copy the test */
1561 (p + init)->i.offset++; /* correct jump (because of new instruction) */
1562 init += sizefirst;
1563 setinstaux(p + init, IChoice, sp - sizefirst + 1, 1); init++;
1564 copypatt(p + init, p1 + sizefirst, sp - sizefirst - 1);
1565 init += sp - sizefirst - 1;
1566 setinst(p + init, ICommit, *size - (end - 1));
1567 return p;
1568 }
1569}
1570
1571
1572static int union_l (lua_State *L) {

Callers 1

union_lFunction · 0.85

Calls 5

firstpartFunction · 0.85
basicUnionFunction · 0.85
interfereFunction · 0.85
sizeiFunction · 0.85
setinstauxFunction · 0.85

Tested by

no test coverage detected