From 940a80d9bbad7af1c63d7d2fe93af602037e6387 Mon Sep 17 00:00:00 2001 From: Dibyendu Majumdar Date: Sat, 8 Aug 2020 19:50:45 +0100 Subject: [PATCH] On returning from a function the results are copied to the registers starting at at the function's reference in CallInfo->func --- readthedocs/lua_bytecode_reference.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/readthedocs/lua_bytecode_reference.rst b/readthedocs/lua_bytecode_reference.rst index 97f5a16..0117ba8 100644 --- a/readthedocs/lua_bytecode_reference.rst +++ b/readthedocs/lua_bytecode_reference.rst @@ -55,6 +55,7 @@ All register addressing is done as offset from ``base`` - so ``R(0)`` is at ``ba The figure above shows how the stack is related to other Lua objects. +When the function returns the return values are copied to location starting at the function reference. Instruction Notation ==================== @@ -262,9 +263,9 @@ Thus upon entry to a function ``base`` is always the location of the first fixed R(A+3) CI->base [ fixed arg 1 ] CI->base [ local 1 ] R(A+4) [ local 1 ] -Results returned by the function call are placed in a range of registers starting from R(A). -If C is 1, no return results are saved. If C is 2 or more, (C-1) return values are saved. -If C is 0, then multiple return results are saved. In this case the number of values to save is +Results returned by the function call are placed in a range of registers starting from ``CI->func``. +If ``C`` is ``1``, no return results are saved. If ``C`` is 2 or more, ``(C-1)`` return values are saved. +If ``C`` is ``0``, then multiple return results are saved. In this case the number of values to save is determined by one of following ways: * A C function returns an integer value indicating number of results returned so for C function calls