# lua/lundump.c File Reference

`#include <string.h>`
`#include "lua.h"`
`#include "ldebug.h"`
`#include "ldo.h"`
`#include "lfunc.h"`
`#include "lmem.h"`
`#include "lobject.h"`
`#include "lstring.h"`
`#include "lundump.h"`
`#include "lzio.h"`

Include dependency graph for lundump.c:

Go to the source code of this file.

## Data Structures
struct | LoadState
## Defines
#define | lundump_c
#define | LUA_CORE
#define | IF(c, s) if (c) error(S,s)
#define | LoadMem(S, b, n, size) LoadBlock(S,b,(n)*(size))
#define | LoadByte(S) (lu_byte)LoadChar(S)
#define | LoadVar(S, x) LoadMem(S,&x,1,sizeof(x))
#define | LoadVector(S, b, n, size) LoadMem(S,b,n,size)
## Functions
static void | error (LoadState *S, const char *why)
static void | LoadBlock (LoadState *S, void *b, size_t size)
static int | LoadChar (LoadState *S)
static int | LoadInt (LoadState *S)
static lua_Number | LoadNumber (LoadState *S)
static TString * | LoadString (LoadState *S)
static void | LoadCode (LoadState *S, Proto *f)
static Proto * | LoadFunction (LoadState *S, TString *p)
static void | LoadConstants (LoadState *S, Proto *f)
static void | LoadDebug (LoadState *S, Proto *f)
static void | LoadHeader (LoadState *S)
Proto * | luaU_undump (lua_State *L, ZIO *Z, Mbuffer *buff, const char *name)
void | luaU_header (char *h)

## Define Documentation

#define IF | ( | c,
|  | s |  | ) | if (c) error(S,s)

Definition at line 33 of file lundump.c.

Referenced by LoadBlock(), LoadConstants(), LoadFunction(), LoadHeader(), and LoadInt().

#define LoadByte | ( | S |  | ) | (lu_byte)LoadChar(S)

Definition at line 43 of file lundump.c.

Referenced by LoadFunction().

#define LoadMem | ( | S,
|  | b,
|  | n,
|  | size |  | ) | LoadBlock(S,b,(n)*(size))

Definition at line 42 of file lundump.c.

#define LoadVar | ( | S,
|  | x |  | ) | LoadMem(S,&x,1,sizeof(x))

Definition at line 44 of file lundump.c.

Referenced by LoadChar(), LoadInt(), LoadNumber(), and LoadString().

#define LoadVector | ( | S,
|  | b,
|  | n,
|  | size |  | ) | LoadMem(S,b,n,size)

Definition at line 45 of file lundump.c.

Referenced by LoadCode(), and LoadDebug().

#define LUA_CORE

Definition at line 10 of file lundump.c.

#define lundump_c

Definition at line 9 of file lundump.c.

## Function Documentation

static void error | ( | LoadState * | S,
|  | const char * | why |
| ) |  |  | `[static]`

Definition at line 35 of file lundump.c.

References LoadState::L, luaD_throw(), luaO_pushfstring(), and LoadState::name.

Referenced by lzdReadOpen(), and vfs_parse_ls_lga().

static void LoadBlock | ( | LoadState * | S,
|  | void * | b,
|  | size_t | size |
| ) |  |  | `[static]`

Definition at line 47 of file lundump.c.

References IF, luaZ_read(), and LoadState::Z.

Referenced by LoadHeader(), and LoadString().

static int LoadChar | ( | LoadState * | S | ) | `[static]`

Definition at line 53 of file lundump.c.

References LoadVar.

Referenced by LoadConstants().

static void LoadCode | ( | LoadState * | S,
|  | Proto * | f |
| ) |  |  | `[static]`

Definition at line 89 of file lundump.c.

References Proto::code, LoadState::L, LoadInt(), LoadVector, luaM_newvector, and Proto::sizecode.

Referenced by LoadFunction().

static void LoadConstants | ( | LoadState * | S,
|  | Proto * | f |
| ) |  |  | `[static]`

Definition at line 99 of file lundump.c.

References IF, Proto::k, LoadState::L, LoadChar(), LoadFunction(), LoadInt(), LoadNumber(), LoadString(), luaM_newvector, Proto::p, setbvalue, setnilvalue, setnvalue, setsvalue2n, Proto::sizek, Proto::sizep, and Proto::source.

Referenced by LoadFunction().

static void LoadDebug | ( | LoadState * | S,
|  | Proto * | f |
| ) |  |  | `[static]`

Definition at line 136 of file lundump.c.

References LocVar::endpc, LoadState::L, Proto::lineinfo, LoadInt(), LoadString(), LoadVector, Proto::locvars, luaM_newvector, Proto::sizelineinfo, Proto::sizelocvars, Proto::sizeupvalues, LocVar::startpc, Proto::upvalues, and LocVar::varname.

Referenced by LoadFunction().

static Proto * LoadFunction | ( | LoadState * | S,
|  | TString * | p |
| ) |  |  | `[static]`

Definition at line 160 of file lundump.c.

References IF, incr_top, Proto::is_vararg, LoadState::L, Proto::lastlinedefined, Proto::linedefined, LoadByte, LoadCode(), LoadConstants(), LoadDebug(), LoadInt(), LoadString(), luaF_newproto(), luaG_checkcode(), Proto::maxstacksize, Proto::numparams, Proto::nups, setptvalue2s, Proto::source, and lua_State::top.

Referenced by LoadConstants(), and luaU_undump().

static void LoadHeader | ( | LoadState * | S | ) | `[static]`

Definition at line 179 of file lundump.c.

References IF, LoadBlock(), LUAC_HEADERSIZE, and luaU_header().

Referenced by luaU_undump().

static int LoadInt | ( | LoadState * | S | ) | `[static]`

Definition at line 60 of file lundump.c.

References IF, and LoadVar.

Referenced by LoadCode(), LoadConstants(), LoadDebug(), and LoadFunction().

static lua_Number LoadNumber | ( | LoadState * | S | ) | `[static]`

Definition at line 68 of file lundump.c.

References LoadVar.

Referenced by LoadConstants().

static TString* LoadString | ( | LoadState * | S | ) | `[static]`

Definition at line 75 of file lundump.c.

References LoadState::b, LoadState::L, LoadBlock(), LoadVar, luaS_newlstr(), and luaZ_openspace().

Referenced by LoadConstants(), LoadDebug(), and LoadFunction().

void luaU_header | ( | char * | h | ) |

Definition at line 210 of file lundump.c.

References LUAC_FORMAT, and LUAC_VERSION.

Referenced by DumpHeader(), and LoadHeader().

Proto* luaU_undump | ( | lua_State * | L,
|  | ZIO * | Z,
|  | Mbuffer * | buff,
|  | const char * | name |
| ) |  |  |

Definition at line 191 of file lundump.c.

References LoadState::b, LoadState::L, LoadFunction(), LoadHeader(), luaS_newliteral, LoadState::name, and LoadState::Z.

Referenced by f_parser().