MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / retstat

Function retstat

libraries/AP_Scripting/lua/src/lparser.c:1504–1534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1502
1503
1504static void retstat (LexState *ls) {
1505 /* stat -> RETURN [explist] [';'] */
1506 FuncState *fs = ls->fs;
1507 expdesc e;
1508 int first, nret; /* registers with returned values */
1509 if (block_follow(ls, 1) || ls->t.token == ';')
1510 first = nret = 0; /* return no values */
1511 else {
1512 nret = explist(ls, &e); /* optional return values */
1513 if (hasmultret(e.k)) {
1514 luaK_setmultret(fs, &e);
1515 if (e.k == VCALL && nret == 1) { /* tail call? */
1516 SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL);
1517 lua_assert(GETARG_A(getinstruction(fs,&e)) == fs->nactvar);
1518 }
1519 first = fs->nactvar;
1520 nret = LUA_MULTRET; /* return all values */
1521 }
1522 else {
1523 if (nret == 1) /* only one single value? */
1524 first = luaK_exp2anyreg(fs, &e);
1525 else {
1526 luaK_exp2nextreg(fs, &e); /* values must go to the stack */
1527 first = fs->nactvar; /* return all active values */
1528 lua_assert(nret == fs->freereg - first);
1529 }
1530 }
1531 }
1532 luaK_ret(fs, first, nret);
1533 testnext(ls, ';'); /* skip optional semicolon */
1534}
1535
1536
1537static void statement (LexState *ls) {

Callers 1

statementFunction · 0.85

Calls 6

block_followFunction · 0.85
explistFunction · 0.85
luaK_exp2anyregFunction · 0.85
luaK_exp2nextregFunction · 0.85
luaK_retFunction · 0.85
testnextFunction · 0.85

Tested by

no test coverage detected