Defines | Typedefs | Functions

# lua/ldo.h File Reference

`#include "lobject.h"`
`#include "lstate.h"`
`#include "lzio.h"`
Include dependency graph for ldo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | luaD_checkstack(L, n)
#define | incr_top(L) {luaD_checkstack(L,1); L->top++;}
#define | savestack(L, p) ((char *)(p) - (char *)L->stack)
#define | restorestack(L, n) ((TValue *)((char *)L->stack + (n)))
#define | saveci(L, p) ((char *)(p) - (char *)L->base_ci)
#define | restoreci(L, n) ((CallInfo *)((char *)L->base_ci + (n)))
#define | PCRLUA 0
#define | PCRC 1
#define | PCRYIELD 2
## Typedefs
typedef void(* | Pfunc )(lua_State *L, void *ud)
## Functions
LUAI_FUNC int | luaD_protectedparser (lua_State *L, ZIO *z, const char *name)
LUAI_FUNC void | luaD_callhook (lua_State *L, int event, int line)
LUAI_FUNC int | luaD_precall (lua_State *L, StkId func, int nresults)
LUAI_FUNC void | luaD_call (lua_State *L, StkId func, int nResults)
LUAI_FUNC int | luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t oldtop, ptrdiff_t ef)
LUAI_FUNC int | luaD_poscall (lua_State *L, StkId firstResult)
LUAI_FUNC void | luaD_reallocCI (lua_State *L, int newsize)
LUAI_FUNC void | luaD_reallocstack (lua_State *L, int newsize)
LUAI_FUNC void | luaD_growstack (lua_State *L, int n)
LUAI_FUNC void | luaD_throw (lua_State *L, int errcode)
LUAI_FUNC int | luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud)
LUAI_FUNC void | luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop)

## Define Documentation

#define incr_top | ( |  | L ) | {luaD_checkstack(L,1); L->top++;}

Definition at line 22 of file ldo.h.

Referenced by collectvalidlines(), f_parser(), LoadFunction(), lua_getinfo(), luaG_errormsg(), luaO_pushvfstring(), open_func(), pushstr(), resume_error(), and tryfuncTM().

#define luaD_checkstack | ( |  | L,
|  |  | n
| ) |  |

Value:

    if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
        luaD_growstack(L, n); \
      else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));

Definition at line 16 of file ldo.h.

Referenced by callTM(), callTMres(), lua_checkstack(), luaD_callhook(), luaD_precall(), and luaV_execute().

#define PCRC 1

Definition at line 33 of file ldo.h.

Referenced by luaD_precall(), and luaV_execute().

#define PCRLUA 0

Definition at line 32 of file ldo.h.

Referenced by luaD_call(), luaD_precall(), luaV_execute(), and resume().

#define PCRYIELD 2

Definition at line 34 of file ldo.h.

Referenced by luaD_precall().

#define restoreci | ( |  | L,
|  |  | n
| ) |  | ((CallInfo *)((char *)L->base_ci + (n)))

Definition at line 28 of file ldo.h.

Referenced by luaD_pcall().

#define restorestack | ( |  | L,
|  |  | n
| ) |  | ((TValue *)((char *)L->stack + (n)))

Definition at line 25 of file ldo.h.

Referenced by callrethooks(), callTMres(), luaD_callhook(), luaD_pcall(), luaD_precall(), luaG_errormsg(), and tryfuncTM().

#define saveci | ( |  | L,
|  |  | p
| ) |  | ((char *)(p) - (char *)L->base_ci)

Definition at line 27 of file ldo.h.

Referenced by luaD_pcall().

#define savestack | ( |  | L,
|  |  | p
| ) |  | ((char *)(p) - (char *)L->stack)

Definition at line 24 of file ldo.h.

Referenced by callrethooks(), callTMres(), lua_cpcall(), lua_pcall(), luaD_callhook(), luaD_precall(), luaD_protectedparser(), and tryfuncTM().

## Typedef Documentation

typedef void(* Pfunc)(lua_State *L, void *ud)

Definition at line 38 of file ldo.h.

## Function Documentation

LUAI_FUNC void luaD_call | ( | lua_State * | L,
|  | StkId | func,
|  | int | nResults
| ) |  |

Definition at line 369 of file ldo.c.

References luaC_checkGC, luaD_precall(), luaD_throw(), luaG_runerror(), luaV_execute(), lua_State::nCcalls, and PCRLUA.

Referenced by callTM(), callTMres(), f_call(), f_Ccall(), GCTM(), lua_call(), luaG_errormsg(), and luaV_execute().

LUAI_FUNC void luaD_callhook | ( | lua_State * | L,
|  | int | event,
|  | int | line
| ) |  |

Definition at line 181 of file ldo.c.

References lua_State::allowhook, lua_State::base_ci, cast_int, lua_State::ci, lua_State::hook, lua_assert, lua_lock, lua_unlock, luaD_checkstack, restorestack, savestack, lua_State::stack_last, CallInfo::top, and lua_State::top.

Referenced by callrethooks(), luaD_precall(), and traceexec().

LUAI_FUNC void luaD_growstack | ( | lua_State * | L,
|  | int | n
| ) |  |

Definition at line 161 of file ldo.c.

References luaD_reallocstack(), and lua_State::stacksize.

LUAI_FUNC int luaD_pcall | ( | lua_State * | L,
|  | Pfunc | func,
|  | void * | u,
|  | ptrdiff_t | oldtop,
|  | ptrdiff_t | ef
| ) |  |

Definition at line 453 of file ldo.c.

References lua_State::allowhook, CallInfo::base, lua_State::base, lua_State::ci, lua_State::errfunc, luaD_rawrunprotected(), luaD_seterrorobj(), luaF_close(), lua_State::nCcalls, restore_stack_limit(), restoreci, restorestack, saveci, CallInfo::savedpc, lua_State::savedpc, and lua_longjmp::status.

Referenced by lua_cpcall(), lua_pcall(), and luaD_protectedparser().

LUAI_FUNC int luaD_poscall | ( | lua_State * | L,
|  | StkId | firstResult
| ) |  |

Definition at line 342 of file ldo.c.

References lua_State::base, callrethooks(), lua_State::ci, CallInfo::func, lua_State::hookmask, CallInfo::nresults, lua_State::savedpc, setnilvalue, setobjs2s, and lua_State::top.

Referenced by luaD_precall(), luaV_execute(), and resume().

LUAI_FUNC int luaD_precall | ( | lua_State * | L,
|  | StkId | func,
|  | int | nresults
| ) |  |

Definition at line 264 of file ldo.c.

References adjust_varargs(), CallInfo::base, lua_State::base, cast_int, lua_State::ci, clvalue, Proto::code, curr_func, CallInfo::func, lua_State::hookmask, inc_ci, Proto::is_vararg, LClosure::isC, lua_assert, lua_lock, lua_unlock, luaD_callhook(), luaD_checkstack, luaD_poscall(), Proto::maxstacksize, CallInfo::nresults, Proto::numparams, LClosure::p, PCRC, PCRLUA, PCRYIELD, restorestack, lua_State::savedpc, CallInfo::savedpc, savestack, setnilvalue, lua_State::stack_last, CallInfo::tailcalls, CallInfo::top, lua_State::top, tryfuncTM(), and ttisfunction.

Referenced by luaD_call(), luaV_execute(), and resume().

LUAI_FUNC int luaD_protectedparser | ( | lua_State * | L,
|  | ZIO * | z,
|  | const char * | name
| ) |  |

Definition at line 506 of file ldo.c.

References SParser::buff, lua_State::errfunc, f_parser(), luaD_pcall(), luaZ_freebuffer, luaZ_initbuffer, name, SParser::name, savestack, lua_State::top, and SParser::z.

Referenced by lua_load().

LUAI_FUNC int luaD_rawrunprotected | ( | lua_State * | L,
|  | Pfunc | f,
|  | void * | ud
| ) |  |

Definition at line 111 of file ldo.c.

References lua_State::errorJmp, lua_longjmp::previous, and lua_longjmp::status.

Referenced by lua_close(), lua_newstate(), lua_resume(), and luaD_pcall().

LUAI_FUNC void luaD_reallocCI | ( | lua_State * | L,
|  | int | newsize
| ) |  |

Definition at line 152 of file ldo.c.

References lua_State::base_ci, lua_State::ci, lua_State::end_ci, luaM_reallocvector, and lua_State::size_ci.

Referenced by checkstacksizes(), growCI(), and restore_stack_limit().

LUAI_FUNC void luaD_reallocstack | ( | lua_State * | L,
|  | int | newsize
| ) |  |

Definition at line 141 of file ldo.c.

References correctstack(), EXTRA_STACK, lua_assert, luaM_reallocvector, lua_State::stack, lua_State::stack_last, and lua_State::stacksize.

Referenced by checkstacksizes(), and luaD_growstack().

LUAI_FUNC void luaD_seterrorobj | ( | lua_State * | L,
|  | int | errcode,
|  | StkId | oldtop
| ) |  |

Definition at line 51 of file ldo.c.

References luaS_newliteral, MEMERRMSG, setobjs2s, setsvalue2s, and lua_State::top.

Referenced by lua_resume(), luaD_pcall(), and resetstack().

LUAI_FUNC void luaD_throw | ( | lua_State * | L,
|  | int | errcode
| ) |  |

Definition at line 94 of file ldo.c.

References cast_byte, lua_State::errorJmp, EXIT_FAILURE, G, lua_unlock, resetstack(), lua_State::status, and lua_longjmp::status.

Referenced by error(), growCI(), luaD_call(), luaG_errormsg(), luaM_realloc_(), and luaX_lexerror().