aot_table_push Subroutine

public subroutine aot_table_push(L, thandle, key, pos, toptype)

This subroutine tries to push the value of the entry given by key or pos within the table thandle onto the Lua stack.

If no corresponding value is found, a nil value is pushed to the stack. Key, pos and thandle are all optional. If no thandle is provided, the key will be obtained as a global variable. When none of thandle, key and pos are provided, the subroutine does nothing and the resulting type returned in toptype is the type of the current top entry in the Lua stack. Passing only pos without thandle is illegal and will result in a NIL value on the top of the stack.

Arguments

Type IntentOptional Attributes Name
type(flu_State) :: L

Handle for the Lua script.

integer, intent(in), optional :: thandle

Handle to the table to look in.

character(len=*), intent(in), optional :: key

Name of the entry to push to the stack.

integer, intent(in), optional :: pos

Position of the entry to push to the stack.

integer, intent(out), optional :: toptype

Calls

proc~~aot_table_push~~CallsGraph proc~aot_table_push aot_table_push interface~flu_pushinteger flu_pushinteger proc~aot_table_push->interface~flu_pushinteger proc~flu_getfield flu_getfield proc~aot_table_push->proc~flu_getfield proc~flu_getglobal flu_getglobal proc~aot_table_push->proc~flu_getglobal proc~flu_gettable flu_gettable proc~aot_table_push->proc~flu_gettable proc~flu_pop flu_pop proc~aot_table_push->proc~flu_pop proc~flu_pushnil flu_pushnil proc~aot_table_push->proc~flu_pushnil proc~flu_type flu_type proc~aot_table_push->proc~flu_type proc~flu_pushint flu_pushint interface~flu_pushinteger->proc~flu_pushint proc~flu_pushlong flu_pushlong interface~flu_pushinteger->proc~flu_pushlong interface~lua_getfield lua_getfield proc~flu_getfield->interface~lua_getfield interface~lua_getglobal lua_getglobal proc~flu_getglobal->interface~lua_getglobal interface~lua_gettable lua_gettable proc~flu_gettable->interface~lua_gettable interface~lua_settop lua_settop proc~flu_pop->interface~lua_settop interface~lua_pushnil lua_pushnil proc~flu_pushnil->interface~lua_pushnil interface~lua_type lua_type proc~flu_type->interface~lua_type interface~lua_pushinteger lua_pushinteger proc~flu_pushint->interface~lua_pushinteger proc~flu_pushlong->interface~lua_pushinteger

Called by

proc~~aot_table_push~~CalledByGraph proc~aot_table_push aot_table_push interface~aot_push aot_push interface~aot_push->proc~aot_table_push proc~aot_exists aot_exists proc~aot_exists->proc~aot_table_push proc~aot_fun_table aot_fun_table proc~aot_fun_table->proc~aot_table_push proc~aot_reference_for aot_reference_for proc~aot_reference_for->proc~aot_table_push proc~aot_table_open aot_table_open proc~aot_table_open->proc~aot_table_push proc~aot_type_of aot_type_of proc~aot_type_of->proc~aot_table_push proc~get_table_double get_table_double proc~get_table_double->proc~aot_table_push proc~get_table_extdouble get_table_extdouble proc~get_table_extdouble->proc~aot_table_push proc~get_table_extdouble_v get_table_extdouble_v proc~get_table_extdouble_v->proc~aot_table_push proc~get_table_extdouble_vvect get_table_extdouble_vvect proc~get_table_extdouble_vvect->proc~aot_table_push proc~get_table_integer get_table_integer proc~get_table_integer->proc~aot_table_push proc~get_table_logical get_table_logical proc~get_table_logical->proc~aot_table_push proc~get_table_long get_table_long proc~get_table_long->proc~aot_table_push proc~get_table_quadruple get_table_quadruple proc~get_table_quadruple->proc~aot_table_push proc~get_table_quadruple_v get_table_quadruple_v proc~get_table_quadruple_v->proc~aot_table_push proc~get_table_quadruple_vvect get_table_quadruple_vvect proc~get_table_quadruple_vvect->proc~aot_table_push proc~get_table_real get_table_real proc~get_table_real->proc~aot_table_push proc~get_table_string get_table_string proc~get_table_string->proc~aot_table_push proc~get_table_userdata get_table_userdata proc~get_table_userdata->proc~aot_table_push interface~aot_fun_open aot_fun_open interface~aot_fun_open->proc~aot_fun_table interface~aot_get_val aot_get_val interface~aot_get_val->proc~get_table_double interface~aot_get_val->proc~get_table_integer interface~aot_get_val->proc~get_table_logical interface~aot_get_val->proc~get_table_long interface~aot_get_val->proc~get_table_real interface~aot_get_val->proc~get_table_string interface~aot_get_val->proc~get_table_userdata interface~aot_get_val~2 aot_get_val interface~aot_get_val~2->proc~get_table_quadruple_vvect interface~aot_get_val~3 aot_get_val interface~aot_get_val~3->proc~get_table_quadruple_v interface~aot_get_val~4 aot_get_val interface~aot_get_val~4->proc~get_table_quadruple interface~aot_get_val~7 aot_get_val interface~aot_get_val~7->proc~get_table_extdouble interface~aot_get_val~8 aot_get_val interface~aot_get_val~8->proc~get_table_extdouble_vvect interface~aot_get_val~9 aot_get_val interface~aot_get_val~9->proc~get_table_extdouble_v interface~aot_table_get_val aot_table_get_val interface~aot_table_get_val->proc~get_table_double interface~aot_table_get_val->proc~get_table_integer interface~aot_table_get_val->proc~get_table_logical interface~aot_table_get_val->proc~get_table_long interface~aot_table_get_val->proc~get_table_real interface~aot_table_get_val->proc~get_table_string interface~aot_table_get_val->proc~get_table_userdata interface~aot_table_get_val~2 aot_table_get_val interface~aot_table_get_val~2->proc~get_table_quadruple_vvect interface~aot_table_get_val~3 aot_table_get_val interface~aot_table_get_val~3->proc~get_table_quadruple_v interface~aot_table_get_val~4 aot_table_get_val interface~aot_table_get_val~4->proc~get_table_quadruple interface~aot_table_get_val~7 aot_table_get_val interface~aot_table_get_val~7->proc~get_table_extdouble interface~aot_table_get_val~8 aot_table_get_val interface~aot_table_get_val~8->proc~get_table_extdouble_vvect interface~aot_table_get_val~9 aot_table_get_val interface~aot_table_get_val~9->proc~get_table_extdouble_v proc~aot_path_open_table aot_path_open_table proc~aot_path_open_table->proc~aot_table_open proc~aot_require_buffer aot_require_buffer proc~aot_require_buffer->proc~aot_table_open proc~get_table_double_v get_table_double_v proc~get_table_double_v->proc~aot_type_of proc~get_table_double_vvect get_table_double_vvect proc~get_table_double_vvect->proc~aot_type_of proc~get_table_integer_v get_table_integer_v proc~get_table_integer_v->proc~aot_type_of proc~get_table_integer_vvect get_table_integer_vvect proc~get_table_integer_vvect->proc~aot_type_of proc~get_table_logical_v get_table_logical_v proc~get_table_logical_v->proc~aot_type_of proc~get_table_logical_vvect get_table_logical_vvect proc~get_table_logical_vvect->proc~aot_type_of proc~get_table_long_v get_table_long_v proc~get_table_long_v->proc~aot_type_of proc~get_table_long_vvect get_table_long_vvect proc~get_table_long_vvect->proc~aot_type_of proc~get_table_real_v get_table_real_v proc~get_table_real_v->proc~aot_type_of proc~get_table_real_vvect get_table_real_vvect proc~get_table_real_vvect->proc~aot_type_of proc~get_table_string_v get_table_string_v proc~get_table_string_v->proc~aot_type_of proc~get_table_string_vvect get_table_string_vvect proc~get_table_string_vvect->proc~aot_type_of interface~aot_get_val~5 aot_get_val interface~aot_get_val~5->proc~get_table_double_vvect interface~aot_get_val~5->proc~get_table_integer_vvect interface~aot_get_val~5->proc~get_table_logical_vvect interface~aot_get_val~5->proc~get_table_long_vvect interface~aot_get_val~5->proc~get_table_real_vvect interface~aot_get_val~5->proc~get_table_string_vvect interface~aot_get_val~6 aot_get_val interface~aot_get_val~6->proc~get_table_double_v interface~aot_get_val~6->proc~get_table_integer_v interface~aot_get_val~6->proc~get_table_logical_v interface~aot_get_val~6->proc~get_table_long_v interface~aot_get_val~6->proc~get_table_real_v interface~aot_get_val~6->proc~get_table_string_v interface~aot_path_open aot_path_open interface~aot_path_open->proc~aot_path_open_table proc~aot_path_open_fun aot_path_open_fun interface~aot_path_open->proc~aot_path_open_fun interface~aot_table_get_val~5 aot_table_get_val interface~aot_table_get_val~5->proc~get_table_double_vvect interface~aot_table_get_val~5->proc~get_table_integer_vvect interface~aot_table_get_val~5->proc~get_table_logical_vvect interface~aot_table_get_val~5->proc~get_table_long_vvect interface~aot_table_get_val~5->proc~get_table_real_vvect interface~aot_table_get_val~5->proc~get_table_string_vvect interface~aot_table_get_val~6 aot_table_get_val interface~aot_table_get_val~6->proc~get_table_double_v interface~aot_table_get_val~6->proc~get_table_integer_v interface~aot_table_get_val~6->proc~get_table_logical_v interface~aot_table_get_val~6->proc~get_table_long_v interface~aot_table_get_val~6->proc~get_table_real_v interface~aot_table_get_val~6->proc~get_table_string_v proc~aot_path_open_fun->interface~aot_fun_open proc~aot_path_open_fun->proc~aot_path_open_table

Source Code

  subroutine aot_table_push(L, thandle, key, pos, toptype)
    type(flu_state) :: L !! Handle for the Lua script.

    !> Handle to the table to look in.
    integer, intent(in), optional :: thandle

    !> Name of the entry to push to the stack.
    character(len=*), intent(in), optional :: key

    !> Position of the entry to push to the stack.
    integer, intent(in), optional :: pos

    integer, intent(out), optional :: toptype

    integer :: loctype

    loctype = FLU_TNIL

    istable: if (present(thandle)) then

      if (thandle /= 0) then
        ! Only proceed if thandle is actually a table
        ! (Should be received with aot_table_global or aot_table_top)

        if (present(key)) then
          ! Try to look up the given key first
          loctype = flu_getfield(L, thandle, key)
          if ((loctype == FLU_TNONE) .or. (loctype == FLU_TNIL)) then
            ! If this is not found, try to retrieve
            ! the value at the given position
            if (present(pos)) then
              call flu_pop(L)
              call flu_pushInteger(L, pos)
              loctype = flu_getTable(L, thandle)
            end if
          end if
        else
          ! No key to look up, just check the given position
          if (present(pos)) then
            call flu_pushInteger(L, pos)
            loctype = flu_getTable(L, thandle)
          else
            ! Neither key nor pos present, nothing to look up
            ! Just push a NIL onto the stack as a result
            call flu_pushnil(L)
          end if
        end if

      else

        call flu_pushnil(L)

      end if

    else istable

      if (present(key)) then
        ! Try to look up the given key as a global variable
        loctype = flu_getglobal(L, key)
      else
        ! No key, no thandle, treat this as a no-op if also no pos is provided
        ! and return the type of the current top of the Lua stack.
        if (present(pos)) then
          ! Passing pos without thandle is illegal, and we always push a NIL
          ! in this case.
          call flu_pushnil(L)
        else
          loctype = flu_type(L, -1)
        end if
      end if

    end if istable

    if (present(toptype)) then
      toptype = loctype
    end if

  end subroutine aot_table_push