Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
ldump.c File Reference
#include <stddef.h>
#include "lua.h"
#include "lobject.h"
#include "lstate.h"
#include "lundump.h"

Go to the source code of this file.

Data Structures

struct  DumpState
 

Macros

#define ldump_c
 
#define LUA_CORE
 
#define DumpMem(b, n, size, D)   DumpBlock(b,(n)*(size),D)
 
#define DumpVar(x, D)   DumpMem(&x,1,sizeof(x),D)
 
#define DumpCode(f, D)   DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
 

Functions

static void DumpBlock (const void *b, size_t size, DumpState *D)
 
static void DumpChar (int y, DumpState *D)
 
static void DumpInt (int x, DumpState *D)
 
static void DumpNumber (lua_Number x, DumpState *D)
 
static void DumpVector (const void *b, int n, size_t size, DumpState *D)
 
static void DumpString (const TString *s, DumpState *D)
 
static void DumpFunction (const Proto *f, DumpState *D)
 
static void DumpConstants (const Proto *f, DumpState *D)
 
static void DumpUpvalues (const Proto *f, DumpState *D)
 
static void DumpDebug (const Proto *f, DumpState *D)
 
static void DumpHeader (DumpState *D)
 
int luaU_dump (lua_State *L, const Proto *f, lua_Writer w, void *data, int strip)
 

Macro Definition Documentation

◆ DumpCode

#define DumpCode ( f,
D )   DumpVector(f->code,f->sizecode,sizeof(Instruction),D)

Definition at line 76 of file lua-5.2.4/src/ldump.c.

Referenced by DumpFunction().

◆ DumpMem

#define DumpMem ( b,
n,
size,
D )   DumpBlock(b,(n)*(size),D)

Definition at line 26 of file lua-5.2.4/src/ldump.c.

Referenced by DumpVector().

◆ DumpVar

#define DumpVar ( x,
D )   DumpMem(&x,1,sizeof(x),D)

Definition at line 27 of file lua-5.2.4/src/ldump.c.

Referenced by DumpChar(), DumpInt(), DumpNumber(), and DumpString().

◆ ldump_c

#define ldump_c

Definition at line 9 of file lua-5.2.4/src/ldump.c.

◆ LUA_CORE

#define LUA_CORE

Definition at line 10 of file lua-5.2.4/src/ldump.c.

Function Documentation

◆ DumpBlock()

static void DumpBlock ( const void * b,
size_t size,
DumpState * D )
static

Definition at line 29 of file lua-5.2.4/src/ldump.c.

30{
31 if (D->status==0)
32 {
33 lua_unlock(D->L);
34 D->status=(*D->writer)(D->L,b,size,D->data);
35 lua_lock(D->L);
36 }
37}
#define lua_unlock(L)
#define lua_lock(L)
lua_State * L
lua_Writer writer

References DumpState::data, DumpState::L, lua_lock, lua_unlock, DumpState::status, and DumpState::writer.

Referenced by DumpHeader(), and DumpString().

◆ DumpChar()

static void DumpChar ( int y,
DumpState * D )
static

Definition at line 39 of file lua-5.2.4/src/ldump.c.

40{
41 char x=(char)y;
42 DumpVar(x,D);
43}
#define DumpVar(x, D)

References DumpVar.

Referenced by DumpConstants(), DumpFunction(), and DumpUpvalues().

◆ DumpConstants()

static void DumpConstants ( const Proto * f,
DumpState * D )
static

Definition at line 80 of file lua-5.2.4/src/ldump.c.

81{
82 int i,n=f->sizek;
83 DumpInt(n,D);
84 for (i=0; i<n; i++)
85 {
86 const TValue* o=&f->k[i];
87 DumpChar(ttypenv(o),D);
88 switch (ttypenv(o))
89 {
90 case LUA_TNIL:
91 break;
92 case LUA_TBOOLEAN:
93 DumpChar(bvalue(o),D);
94 break;
95 case LUA_TNUMBER:
96 DumpNumber(nvalue(o),D);
97 break;
98 case LUA_TSTRING:
100 break;
101 default: lua_assert(0);
102 }
103 }
104 n=f->sizep;
105 DumpInt(n,D);
106 for (i=0; i<n; i++) DumpFunction(f->p[i],D);
107}
#define lua_assert(c)
#define nvalue(o)
#define rawtsvalue(o)
#define bvalue(o)
#define LUA_TSTRING
#define LUA_TBOOLEAN
#define LUA_TNUMBER
#define LUA_TNIL
static void DumpNumber(lua_Number x, DumpState *D)
static void DumpInt(int x, DumpState *D)
static void DumpChar(int y, DumpState *D)
static void DumpFunction(const Proto *f, DumpState *D)
static void DumpString(const TString *s, DumpState *D)
#define ttypenv(o)
struct Proto ** p

References bvalue, DumpChar(), DumpFunction(), DumpInt(), DumpNumber(), DumpString(), Proto::k, lua_assert, LUA_TBOOLEAN, LUA_TNIL, LUA_TNUMBER, LUA_TSTRING, nvalue, Proto::p, rawtsvalue, Proto::sizek, Proto::sizep, and ttypenv.

Referenced by DumpFunction().

◆ DumpDebug()

static void DumpDebug ( const Proto * f,
DumpState * D )
static

Definition at line 120 of file lua-5.2.4/src/ldump.c.

121{
122 int i,n;
123 DumpString((D->strip) ? NULL : f->source,D);
124 n= (D->strip) ? 0 : f->sizelineinfo;
125 DumpVector(f->lineinfo,n,sizeof(int),D);
126 n= (D->strip) ? 0 : f->sizelocvars;
127 DumpInt(n,D);
128 for (i=0; i<n; i++)
129 {
130 DumpString(f->locvars[i].varname,D);
131 DumpInt(f->locvars[i].startpc,D);
132 DumpInt(f->locvars[i].endpc,D);
133 }
134 n= (D->strip) ? 0 : f->sizeupvalues;
135 DumpInt(n,D);
136 for (i=0; i<n; i++) DumpString(f->upvalues[i].name,D);
137}
#define NULL
Definition gmacros.h:924
#define DumpVector(v, n, D)
TString * varname
struct LocVar * locvars
TString ** upvalues

References DumpInt(), DumpString(), DumpVector, LocVar::endpc, Proto::lineinfo, Proto::locvars, NULL, Proto::sizelineinfo, Proto::sizelocvars, Proto::sizeupvalues, Proto::source, LocVar::startpc, DumpState::strip, Proto::upvalues, and LocVar::varname.

Referenced by DumpFunction().

◆ DumpFunction()

static void DumpFunction ( const Proto * f,
DumpState * D )
static

Definition at line 139 of file lua-5.2.4/src/ldump.c.

140{
141 DumpInt(f->linedefined,D);
143 DumpChar(f->numparams,D);
144 DumpChar(f->is_vararg,D);
146 DumpCode(f,D);
147 DumpConstants(f,D);
148 DumpUpvalues(f,D);
149 DumpDebug(f,D);
150}
static void DumpConstants(const Proto *f, DumpState *D)
static void DumpDebug(const Proto *f, DumpState *D)
static void DumpUpvalues(const Proto *f, DumpState *D)
#define DumpCode(f, D)
lu_byte maxstacksize

References DumpChar(), DumpCode, DumpConstants(), DumpDebug(), DumpInt(), DumpUpvalues(), Proto::is_vararg, Proto::lastlinedefined, Proto::linedefined, Proto::maxstacksize, and Proto::numparams.

Referenced by DumpConstants(), and luaU_dump().

◆ DumpHeader()

static void DumpHeader ( DumpState * D)
static

Definition at line 152 of file lua-5.2.4/src/ldump.c.

153{
155 luaU_header(h);
157}
unsigned char lu_byte
void luaU_header(char *h)
#define LUAC_HEADERSIZE
static void DumpBlock(const void *b, size_t size, DumpState *D)

References DumpBlock(), LUAC_HEADERSIZE, and luaU_header().

Referenced by luaU_dump().

◆ DumpInt()

static void DumpInt ( int x,
DumpState * D )
static

Definition at line 45 of file lua-5.2.4/src/ldump.c.

46{
47 DumpVar(x,D);
48}

References DumpVar.

Referenced by DumpConstants(), DumpDebug(), DumpFunction(), DumpUpvalues(), and DumpVector().

◆ DumpNumber()

static void DumpNumber ( lua_Number x,
DumpState * D )
static

Definition at line 50 of file lua-5.2.4/src/ldump.c.

51{
52 DumpVar(x,D);
53}

References DumpVar.

Referenced by DumpConstants().

◆ DumpString()

static void DumpString ( const TString * s,
DumpState * D )
static

Definition at line 61 of file lua-5.2.4/src/ldump.c.

62{
63 if (s==NULL)
64 {
65 size_t size=0;
66 DumpVar(size,D);
67 }
68 else
69 {
70 size_t size=s->tsv.len+1; /* include trailing '\0' */
71 DumpVar(size,D);
72 DumpBlock(getstr(s),size*sizeof(char),D);
73 }
74}
#define getstr(ts)
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318

References DumpBlock(), DumpVar, getstr, NULL, and s.

Referenced by DumpConstants(), and DumpDebug().

◆ DumpUpvalues()

static void DumpUpvalues ( const Proto * f,
DumpState * D )
static

Definition at line 109 of file lua-5.2.4/src/ldump.c.

110{
111 int i,n=f->sizeupvalues;
112 DumpInt(n,D);
113 for (i=0; i<n; i++)
114 {
115 DumpChar(f->upvalues[i].instack,D);
116 DumpChar(f->upvalues[i].idx,D);
117 }
118}

References DumpChar(), DumpInt(), Proto::sizeupvalues, and Proto::upvalues.

Referenced by DumpFunction().

◆ DumpVector()

static void DumpVector ( const void * b,
int n,
size_t size,
DumpState * D )
static

Definition at line 55 of file lua-5.2.4/src/ldump.c.

56{
57 DumpInt(n,D);
58 DumpMem(b,n,size,D);
59}
#define DumpMem(b, n, size, D)

References DumpInt(), and DumpMem.

◆ luaU_dump()

int luaU_dump ( lua_State * L,
const Proto * f,
lua_Writer w,
void * data,
int strip )

Definition at line 162 of file lua-5.2.4/src/ldump.c.

163{
164 DumpState D;
165 D.L=L;
166 D.writer=w;
167 D.data=data;
168 D.strip=strip;
169 D.status=0;
170 DumpHeader(&D);
171 DumpFunction(f,&D);
172 return D.status;
173}
static void DumpHeader(DumpState *D)

References DumpState::data, DumpFunction(), DumpHeader(), DumpState::L, DumpState::status, DumpState::strip, and DumpState::writer.