function luaY.retstat(u,e)local R=e.fs local p={}local j,q luaX:next(e)if u:block_follow(e.t.token)or e.t.token=="\059"then j,q=0,0 else q=u:explist1(e,p)if u:hasmultret(p.k)then luaK:setmultret(R,p)if p.k=="\086\067\065\076\076"and q==1 then luaP:SET_OPCODE(luaK:getcode(R,p),"\079\080\095\084\065\073\076\067\065\076\076")assert(luaP:GETARG_A(luaK:getcode(R,p))==R.nactvar)end j=R.nactvar q=u.LUA_MULTRET else if q==1 then j=luaK:exp2anyreg(R,p)else luaK:exp2nextreg(R,p)j=R.nactvar assert(q==R.freereg-j)end end end luaK:ret(R,j,q)end

function luaY:retstat(ls)
  -- stat -> RETURN explist
  local fs = ls.fs
  local e = {}  -- expdesc
  local first, nret  -- registers with returned values
  luaX:next(ls)  -- skip RETURN
  if self:block_follow(ls.t.token) or ls.t.token == ";" then
    first, nret = 0, 0  -- return no values
  else
    nret = self:explist1(ls, e)  -- optional return values
    if self:hasmultret(e.k) then
      luaK:setmultret(fs, e)
      if e.k == "VCALL" and nret == 1 then  -- tail call?
        luaP:SET_OPCODE(luaK:getcode(fs, e), "OP_TAILCALL")
        assert(luaP:GETARG_A(luaK:getcode(fs, e)) == fs.nactvar)
      end
      first = fs.nactvar
      nret = self.LUA_MULTRET  -- return all values
    else
      if nret == 1 then  -- only one single value?
        first = luaK:exp2anyreg(fs, e)
      else
        luaK:exp2nextreg(fs, e)  -- values must go to the 'stack'
        first = fs.nactvar  -- return all 'active' values
        assert(nret == fs.freereg - first)
      end
    end--if
  end--if
  luaK:ret(fs, first, nret)
end
