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, const TString *p, DumpState *D)
 
static void DumpConstants (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.1.5/src/ldump.c.

Referenced by DumpFunction(), and DumpFunction().

◆ DumpMem

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

Definition at line 26 of file lua-5.1.5/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.1.5/src/ldump.c.

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

◆ ldump_c

#define ldump_c

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

◆ LUA_CORE

#define LUA_CORE

Definition at line 10 of file lua-5.1.5/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.1.5/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.1.5/src/ldump.c.

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

References DumpVar.

Referenced by DumpConstants(), and DumpFunction().

◆ DumpConstants()

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

Definition at line 80 of file lua-5.1.5/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(ttype(o),D);
88 switch (ttype(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:
102 lua_assert(0); /* cannot happen */
103 break;
104 }
105 }
106 n=f->sizep;
107 DumpInt(n,D);
108 for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
109}
static void DumpNumber(lua_Number x, DumpState *D)
static void DumpInt(int x, DumpState *D)
static void DumpChar(int y, DumpState *D)
static void DumpString(const TString *s, DumpState *D)
static void DumpFunction(const Proto *f, const TString *p, DumpState *D)
#define lua_assert(c)
#define nvalue(o)
#define rawtsvalue(o)
#define bvalue(o)
#define ttype(o)
#define LUA_TSTRING
#define LUA_TBOOLEAN
#define LUA_TNUMBER
#define LUA_TNIL
struct Proto ** p
TString * source

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, Proto::source, and ttype.

Referenced by DumpFunction().

◆ DumpDebug()

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

Definition at line 111 of file lua-5.1.5/src/ldump.c.

112{
113 int i,n;
114 n= (D->strip) ? 0 : f->sizelineinfo;
115 DumpVector(f->lineinfo,n,sizeof(int),D);
116 n= (D->strip) ? 0 : f->sizelocvars;
117 DumpInt(n,D);
118 for (i=0; i<n; i++)
119 {
120 DumpString(f->locvars[i].varname,D);
121 DumpInt(f->locvars[i].startpc,D);
122 DumpInt(f->locvars[i].endpc,D);
123 }
124 n= (D->strip) ? 0 : f->sizeupvalues;
125 DumpInt(n,D);
126 for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
127}
#define DumpVector(v, n, D)
TString * varname
struct LocVar * locvars
TString ** upvalues

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

Referenced by DumpFunction().

◆ DumpFunction()

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

Definition at line 129 of file lua-5.1.5/src/ldump.c.

130{
131 DumpString((f->source==p || D->strip) ? NULL : f->source,D);
132 DumpInt(f->linedefined,D);
134 DumpChar(f->nups,D);
135 DumpChar(f->numparams,D);
136 DumpChar(f->is_vararg,D);
138 DumpCode(f,D);
139 DumpConstants(f,D);
140 DumpDebug(f,D);
141}
#define NULL
Definition gmacros.h:924
static void DumpConstants(const Proto *f, DumpState *D)
static void DumpDebug(const Proto *f, DumpState *D)
#define DumpCode(f, D)
lu_byte maxstacksize

References DumpChar(), DumpCode, DumpConstants(), DumpDebug(), DumpInt(), DumpString(), Proto::is_vararg, Proto::lastlinedefined, Proto::linedefined, Proto::maxstacksize, NULL, Proto::numparams, Proto::nups, Proto::source, and DumpState::strip.

Referenced by DumpConstants(), and luaU_dump().

◆ DumpHeader()

static void DumpHeader ( DumpState * D)
static

Definition at line 143 of file lua-5.1.5/src/ldump.c.

144{
145 char h[LUAC_HEADERSIZE];
146 luaU_header(h);
148}
static void DumpBlock(const void *b, size_t size, DumpState *D)
void luaU_header(char *h)
#define LUAC_HEADERSIZE

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.1.5/src/ldump.c.

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

References DumpVar.

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

◆ DumpNumber()

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

Definition at line 50 of file lua-5.1.5/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.1.5/src/ldump.c.

62{
63 if (s==NULL || getstr(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,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(), DumpDebug(), and DumpFunction().

◆ DumpVector()

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

Definition at line 55 of file lua-5.1.5/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 153 of file lua-5.1.5/src/ldump.c.

154{
155 DumpState D;
156 D.L=L;
157 D.writer=w;
158 D.data=data;
159 D.strip=strip;
160 D.status=0;
161 DumpHeader(&D);
162 DumpFunction(f,NULL,&D);
163 return D.status;
164}
static void DumpHeader(DumpState *D)

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

Referenced by lua_dump(), lua_dump(), pmain(), pmain(), pmain(), and pmain().