mirror of
https://github.com/lua/lua
synced 2024-11-25 22:29:39 +03:00
`luaconf.h´ exports all its definitions always (so all of them
must have a lua/LUA prefix).
This commit is contained in:
parent
d3902cfa81
commit
f8df21bd20
4
lapi.c
4
lapi.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.c,v 2.28 2005/02/23 17:30:22 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.29 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -95,7 +95,7 @@ void luaA_pushobject (lua_State *L, const TValue *o) {
|
||||
LUA_API int lua_checkstack (lua_State *L, int size) {
|
||||
int res;
|
||||
lua_lock(L);
|
||||
if ((L->top - L->base + size) > MAXCSTACK)
|
||||
if ((L->top - L->base + size) > LUAC_MAXCSTACK)
|
||||
res = 0; /* stack overflow */
|
||||
else {
|
||||
luaD_checkstack(L, size);
|
||||
|
4
lcode.c
4
lcode.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lcode.c,v 2.8 2004/12/03 20:35:33 roberto Exp roberto $
|
||||
** $Id: lcode.c,v 2.9 2005/01/10 18:17:39 roberto Exp roberto $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -606,7 +606,7 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
||||
if (op == OPR_MINUS) {
|
||||
luaK_exp2val(fs, e);
|
||||
if (e->k == VK && ttisnumber(&fs->f->k[e->info]))
|
||||
e->info = luaK_numberK(fs, num_unm(nvalue(&fs->f->k[e->info])));
|
||||
e->info = luaK_numberK(fs, luac_numunm(nvalue(&fs->f->k[e->info])));
|
||||
else {
|
||||
luaK_exp2anyreg(fs, e);
|
||||
freeexp(fs, e);
|
||||
|
54
ldblib.c
54
ldblib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldblib.c,v 1.92 2005/01/18 17:23:25 roberto Exp roberto $
|
||||
** $Id: ldblib.c,v 1.93 2005/02/18 12:40:02 roberto Exp roberto $
|
||||
** Interface from Lua to its debug API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
|
||||
static int getmetatable (lua_State *L) {
|
||||
static int db_getmetatable (lua_State *L) {
|
||||
luaL_checkany(L, 1);
|
||||
if (!lua_getmetatable(L, 1)) {
|
||||
lua_pushnil(L); /* no metatable */
|
||||
@ -28,7 +28,7 @@ static int getmetatable (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int setmetatable (lua_State *L) {
|
||||
static int db_setmetatable (lua_State *L) {
|
||||
int t = lua_type(L, 2);
|
||||
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
|
||||
"nil or table expected");
|
||||
@ -38,13 +38,13 @@ static int setmetatable (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int getfenv (lua_State *L) {
|
||||
static int db_getfenv (lua_State *L) {
|
||||
lua_getfenv(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int setfenv (lua_State *L) {
|
||||
static int db_setfenv (lua_State *L) {
|
||||
luaL_checktype(L, 2, LUA_TTABLE);
|
||||
lua_settop(L, 2);
|
||||
if (lua_setfenv(L, 1) == 0)
|
||||
@ -77,7 +77,7 @@ static lua_State *getthread (lua_State *L, int *arg) {
|
||||
}
|
||||
|
||||
|
||||
static int getinfo (lua_State *L) {
|
||||
static int db_getinfo (lua_State *L) {
|
||||
lua_Debug ar;
|
||||
int arg;
|
||||
lua_State *L1 = getthread(L, &arg);
|
||||
@ -130,7 +130,7 @@ static int getinfo (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int getlocal (lua_State *L) {
|
||||
static int db_getlocal (lua_State *L) {
|
||||
int arg;
|
||||
lua_State *L1 = getthread(L, &arg);
|
||||
lua_Debug ar;
|
||||
@ -151,7 +151,7 @@ static int getlocal (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int setlocal (lua_State *L) {
|
||||
static int db_setlocal (lua_State *L) {
|
||||
int arg;
|
||||
lua_State *L1 = getthread(L, &arg);
|
||||
lua_Debug ar;
|
||||
@ -178,12 +178,12 @@ static int auxupvalue (lua_State *L, int get) {
|
||||
}
|
||||
|
||||
|
||||
static int getupvalue (lua_State *L) {
|
||||
static int db_getupvalue (lua_State *L) {
|
||||
return auxupvalue(L, 1);
|
||||
}
|
||||
|
||||
|
||||
static int setupvalue (lua_State *L) {
|
||||
static int db_setupvalue (lua_State *L) {
|
||||
luaL_checkany(L, 3);
|
||||
return auxupvalue(L, 0);
|
||||
}
|
||||
@ -244,7 +244,7 @@ static void gethooktable (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int sethook (lua_State *L) {
|
||||
static int db_sethook (lua_State *L) {
|
||||
int arg;
|
||||
lua_State *L1 = getthread(L, &arg);
|
||||
if (lua_isnoneornil(L, arg+1)) {
|
||||
@ -267,7 +267,7 @@ static int sethook (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int gethook (lua_State *L) {
|
||||
static int db_gethook (lua_State *L) {
|
||||
int arg;
|
||||
lua_State *L1 = getthread(L, &arg);
|
||||
char buff[5];
|
||||
@ -288,7 +288,7 @@ static int gethook (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int debug (lua_State *L) {
|
||||
static int db_debug (lua_State *L) {
|
||||
for (;;) {
|
||||
char buffer[250];
|
||||
fputs("lua_debug> ", stderr);
|
||||
@ -308,7 +308,7 @@ static int debug (lua_State *L) {
|
||||
#define LEVELS1 12 /* size of the first part of the stack */
|
||||
#define LEVELS2 10 /* size of the second part of the stack */
|
||||
|
||||
static int errorfb (lua_State *L) {
|
||||
static int db_errorfb (lua_State *L) {
|
||||
int level;
|
||||
int firstpart = 1; /* still before eventual `...' */
|
||||
int arg;
|
||||
@ -362,19 +362,19 @@ static int errorfb (lua_State *L) {
|
||||
|
||||
|
||||
static const luaL_reg dblib[] = {
|
||||
{"getmetatable", getmetatable},
|
||||
{"setmetatable", setmetatable},
|
||||
{"getfenv", getfenv},
|
||||
{"setfenv", setfenv},
|
||||
{"getlocal", getlocal},
|
||||
{"getinfo", getinfo},
|
||||
{"gethook", gethook},
|
||||
{"getupvalue", getupvalue},
|
||||
{"sethook", sethook},
|
||||
{"setlocal", setlocal},
|
||||
{"setupvalue", setupvalue},
|
||||
{"debug", debug},
|
||||
{"traceback", errorfb},
|
||||
{"getmetatable", db_getmetatable},
|
||||
{"setmetatable", db_setmetatable},
|
||||
{"getfenv", db_getfenv},
|
||||
{"setfenv", db_setfenv},
|
||||
{"getlocal", db_getlocal},
|
||||
{"getinfo", db_getinfo},
|
||||
{"gethook", db_gethook},
|
||||
{"getupvalue", db_getupvalue},
|
||||
{"sethook", db_sethook},
|
||||
{"setlocal", db_setlocal},
|
||||
{"setupvalue", db_setupvalue},
|
||||
{"debug", db_debug},
|
||||
{"traceback", db_errorfb},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
24
ldo.c
24
ldo.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldo.c,v 2.14 2005/02/18 12:40:02 roberto Exp roberto $
|
||||
** $Id: ldo.c,v 2.15 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** Stack and Call structure of Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -43,7 +43,7 @@
|
||||
/* chain list of long jump buffers */
|
||||
struct lua_longjmp {
|
||||
struct lua_longjmp *previous;
|
||||
l_jmpbuf b;
|
||||
luac_jmpbuf b;
|
||||
volatile int status; /* error code */
|
||||
};
|
||||
|
||||
@ -71,7 +71,7 @@ static void seterrorobj (lua_State *L, int errcode, StkId oldtop) {
|
||||
void luaD_throw (lua_State *L, int errcode) {
|
||||
if (L->errorJmp) {
|
||||
L->errorJmp->status = errcode;
|
||||
L_THROW(L, L->errorJmp);
|
||||
LUAC_THROW(L, L->errorJmp);
|
||||
}
|
||||
else {
|
||||
if (G(L)->panic) G(L)->panic(L);
|
||||
@ -85,7 +85,7 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
|
||||
lj.status = 0;
|
||||
lj.previous = L->errorJmp; /* chain new error handler */
|
||||
L->errorJmp = &lj;
|
||||
L_TRY(L, &lj,
|
||||
LUAC_TRY(L, &lj,
|
||||
(*f)(L, ud);
|
||||
);
|
||||
L->errorJmp = lj.previous; /* restore old error handler */
|
||||
@ -95,10 +95,10 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
|
||||
|
||||
static void restore_stack_limit (lua_State *L) {
|
||||
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
|
||||
if (L->size_ci > LUA_MAXCALLS) { /* there was an overflow? */
|
||||
if (L->size_ci > LUAC_MAXCALLS) { /* there was an overflow? */
|
||||
int inuse = (L->ci - L->base_ci);
|
||||
if (inuse + 1 < LUA_MAXCALLS) /* can `undo' overflow? */
|
||||
luaD_reallocCI(L, LUA_MAXCALLS);
|
||||
if (inuse + 1 < LUAC_MAXCALLS) /* can `undo' overflow? */
|
||||
luaD_reallocCI(L, LUAC_MAXCALLS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,11 +149,11 @@ void luaD_growstack (lua_State *L, int n) {
|
||||
|
||||
|
||||
static CallInfo *growCI (lua_State *L) {
|
||||
if (L->size_ci > LUA_MAXCALLS) /* overflow while handling overflow? */
|
||||
if (L->size_ci > LUAC_MAXCALLS) /* overflow while handling overflow? */
|
||||
luaD_throw(L, LUA_ERRERR);
|
||||
else {
|
||||
luaD_reallocCI(L, 2*L->size_ci);
|
||||
if (L->size_ci > LUA_MAXCALLS)
|
||||
if (L->size_ci > LUAC_MAXCALLS)
|
||||
luaG_runerror(L, "stack overflow");
|
||||
}
|
||||
return ++L->ci;
|
||||
@ -340,10 +340,10 @@ void luaD_poscall (lua_State *L, int wanted, StkId firstResult) {
|
||||
** function position.
|
||||
*/
|
||||
void luaD_call (lua_State *L, StkId func, int nResults) {
|
||||
if (++L->nCcalls >= LUA_MAXCCALLS) {
|
||||
if (L->nCcalls == LUA_MAXCCALLS)
|
||||
if (++L->nCcalls >= LUAC_MAXCCALLS) {
|
||||
if (L->nCcalls == LUAC_MAXCCALLS)
|
||||
luaG_runerror(L, "C stack overflow");
|
||||
else if (L->nCcalls >= (LUA_MAXCCALLS + (LUA_MAXCCALLS>>3)))
|
||||
else if (L->nCcalls >= (LUAC_MAXCCALLS + (LUAC_MAXCCALLS>>3)))
|
||||
luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
|
||||
}
|
||||
if (luaD_precall(L, func, nResults) == PCRLUA) { /* is a Lua function? */
|
||||
|
4
lgc.c
4
lgc.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lgc.c,v 2.26 2005/02/18 12:40:02 roberto Exp roberto $
|
||||
** $Id: lgc.c,v 2.27 2005/02/23 17:30:22 roberto Exp roberto $
|
||||
** Garbage Collector
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -242,7 +242,7 @@ static void traverseclosure (global_State *g, Closure *cl) {
|
||||
static void checkstacksizes (lua_State *L, StkId max) {
|
||||
int ci_used = L->ci - L->base_ci; /* number of `ci' in use */
|
||||
int s_used = max - L->stack; /* part of stack in use */
|
||||
if (L->size_ci > LUA_MAXCALLS) /* handling overflow? */
|
||||
if (L->size_ci > LUAC_MAXCALLS) /* handling overflow? */
|
||||
return; /* do not touch the stacks */
|
||||
if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
|
||||
luaD_reallocCI(L, L->size_ci/2); /* still big enough... */
|
||||
|
14
llimits.h
14
llimits.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: llimits.h,v 1.62 2004/12/13 12:15:11 roberto Exp roberto $
|
||||
** $Id: llimits.h,v 1.63 2005/01/14 14:19:42 roberto Exp roberto $
|
||||
** Limits, basic types, and some other `installation-dependent' definitions
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -15,12 +15,14 @@
|
||||
#include "lua.h"
|
||||
|
||||
|
||||
#define api_check luac_apicheck
|
||||
|
||||
typedef LUA_UINT32 lu_int32;
|
||||
|
||||
typedef LU_MEM lu_mem;
|
||||
typedef LUAC_UINT32 lu_int32;
|
||||
|
||||
typedef L_MEM l_mem;
|
||||
typedef LUAC_UMEM lu_mem;
|
||||
|
||||
typedef LUAC_MEM l_mem;
|
||||
|
||||
|
||||
|
||||
@ -45,11 +47,11 @@ typedef unsigned char lu_byte;
|
||||
|
||||
|
||||
/* type to ensure maximum alignment */
|
||||
typedef LUSER_ALIGNMENT_T L_Umaxalign;
|
||||
typedef LUAC_USER_ALIGNMENT_T L_Umaxalign;
|
||||
|
||||
|
||||
/* result of a `usual argument conversion' over lua_Number */
|
||||
typedef LUA_UACNUMBER l_uacNumber;
|
||||
typedef LUAC_UACNUMBER l_uacNumber;
|
||||
|
||||
|
||||
#define check_exp(c,e) (lua_assert(c), (e))
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: loadlib.c,v 1.18 2005/02/28 15:58:48 roberto Exp roberto $
|
||||
** $Id: loadlib.c,v 1.19 2005/03/07 18:07:34 roberto Exp roberto $
|
||||
** Dynamic library loader for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*
|
||||
@ -33,7 +33,7 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym);
|
||||
|
||||
|
||||
|
||||
#if defined(USE_DLOPEN)
|
||||
#if defined(LUA_USEDLOPEN)
|
||||
/*
|
||||
** {========================================================================
|
||||
** This is an implementation of loadlib based on the dlfcn interface.
|
||||
@ -67,7 +67,7 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
|
||||
|
||||
|
||||
|
||||
#elif defined(USE_DLL)
|
||||
#elif defined(LUA_USEDLL)
|
||||
/*
|
||||
** {======================================================================
|
||||
** This is an implementation of loadlib for Windows using native functions.
|
||||
@ -109,7 +109,7 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
|
||||
|
||||
|
||||
|
||||
#elif defined(USE_DYLD)
|
||||
#elif defined(LUA_USEDYLD)
|
||||
/*
|
||||
** {======================================================================
|
||||
** Native Mac OS X / Darwin Implementation
|
||||
@ -119,6 +119,7 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
|
||||
/* Mac appends a `_' before C function names */
|
||||
#undef POF
|
||||
#define POF "_" LUA_POF
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lobject.c,v 2.8 2005/01/10 18:17:39 roberto Exp roberto $
|
||||
** $Id: lobject.c,v 2.9 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** Some generic functions over Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -74,7 +74,7 @@ int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
|
||||
case LUA_TNIL:
|
||||
return 1;
|
||||
case LUA_TNUMBER:
|
||||
return num_eq(nvalue(t1), nvalue(t2));
|
||||
return luac_numeq(nvalue(t1), nvalue(t2));
|
||||
case LUA_TBOOLEAN:
|
||||
return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lopcodes.h,v 1.114 2004/12/02 12:59:10 roberto Exp roberto $
|
||||
** $Id: lopcodes.h,v 1.115 2005/03/08 18:00:16 roberto Exp roberto $
|
||||
** Opcodes for Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -51,9 +51,9 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
|
||||
/*
|
||||
** limits for opcode arguments.
|
||||
** we use (signed) int to manipulate most arguments,
|
||||
** so they must fit in LUA_BITSINT-1 bits (-1 for sign)
|
||||
** so they must fit in LUAC_BITSINT-1 bits (-1 for sign)
|
||||
*/
|
||||
#if SIZE_Bx < LUA_BITSINT-1
|
||||
#if SIZE_Bx < LUAC_BITSINT-1
|
||||
#define MAXARG_Bx ((1<<SIZE_Bx)-1)
|
||||
#define MAXARG_sBx (MAXARG_Bx>>1) /* `sBx' is signed */
|
||||
#else
|
||||
|
4
loslib.c
4
loslib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: loslib.c,v 1.3 2004/10/08 18:57:16 roberto Exp roberto $
|
||||
** $Id: loslib.c,v 1.4 2005/01/10 19:16:29 roberto Exp roberto $
|
||||
** Standard Operating System library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -57,7 +57,7 @@ static int io_rename (lua_State *L) {
|
||||
|
||||
|
||||
static int io_tmpname (lua_State *L) {
|
||||
#if !USE_TMPNAME
|
||||
#if !LUA_USETMPNAME
|
||||
luaL_error(L, "`tmpname' not supported");
|
||||
return 0;
|
||||
#else
|
||||
|
12
lparser.c
12
lparser.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lparser.c,v 2.15 2005/03/08 18:00:16 roberto Exp roberto $
|
||||
** $Id: lparser.c,v 2.16 2005/03/08 18:16:45 roberto Exp roberto $
|
||||
** Lua Parser
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
|
||||
|
||||
#define enterlevel(ls) if (++(ls)->nestlevel > LUA_MAXPARSERLEVEL) \
|
||||
#define enterlevel(ls) if (++(ls)->nestlevel > LUAC_MAXPARSERLEVEL) \
|
||||
luaX_lexerror(ls, "chunk has too many syntax levels", 0)
|
||||
#define leavelevel(ls) ((ls)->nestlevel--)
|
||||
|
||||
@ -181,7 +181,7 @@ static int registerlocalvar (LexState *ls, TString *varname) {
|
||||
|
||||
static void new_localvar (LexState *ls, TString *name, int n) {
|
||||
FuncState *fs = ls->fs;
|
||||
luaY_checklimit(fs, fs->nactvar+n+1, MAXVARS, "local variables");
|
||||
luaY_checklimit(fs, fs->nactvar+n+1, LUAC_MAXVARS, "local variables");
|
||||
fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name));
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
|
||||
}
|
||||
}
|
||||
/* new one */
|
||||
luaY_checklimit(fs, f->nups + 1, MAXUPVALUES, "upvalues");
|
||||
luaY_checklimit(fs, f->nups + 1, LUAC_MAXUPVALUES, "upvalues");
|
||||
luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues,
|
||||
TString *, MAX_INT, "");
|
||||
while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL;
|
||||
@ -993,7 +993,7 @@ static int cond (LexState *ls) {
|
||||
|
||||
static void whilestat (LexState *ls, int line) {
|
||||
/* whilestat -> WHILE cond DO block END */
|
||||
Instruction codeexp[MAXEXPWHILE + EXTRAEXP];
|
||||
Instruction codeexp[LUAC_MAXEXPWHILE + EXTRAEXP];
|
||||
int lineexp;
|
||||
int i;
|
||||
int sizeexp;
|
||||
@ -1011,7 +1011,7 @@ static void whilestat (LexState *ls, int line) {
|
||||
luaK_concat(fs, &v.f, fs->jpc);
|
||||
fs->jpc = NO_JUMP;
|
||||
sizeexp = fs->pc - expinit; /* size of expression code */
|
||||
if (sizeexp > MAXEXPWHILE)
|
||||
if (sizeexp > LUAC_MAXEXPWHILE)
|
||||
luaX_syntaxerror(ls, "`while' condition too complex");
|
||||
for (i = 0; i < sizeexp; i++) /* save `exp' code */
|
||||
codeexp[i] = fs->f->code[expinit + i];
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lparser.h,v 1.51 2004/05/31 18:51:50 roberto Exp roberto $
|
||||
** $Id: lparser.h,v 1.52 2005/03/07 16:58:27 roberto Exp roberto $
|
||||
** Lua Parser
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -67,8 +67,8 @@ typedef struct FuncState {
|
||||
int np; /* number of elements in `p' */
|
||||
short nlocvars; /* number of elements in `locvars' */
|
||||
lu_byte nactvar; /* number of active local variables */
|
||||
upvaldesc upvalues[MAXUPVALUES]; /* upvalues */
|
||||
unsigned short actvar[MAXVARS]; /* declared-variable stack */
|
||||
upvaldesc upvalues[LUAC_MAXUPVALUES]; /* upvalues */
|
||||
unsigned short actvar[LUAC_MAXVARS]; /* declared-variable stack */
|
||||
} FuncState;
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstrlib.c,v 1.108 2004/11/19 16:58:43 roberto Exp roberto $
|
||||
** $Id: lstrlib.c,v 1.109 2004/12/01 15:46:06 roberto Exp roberto $
|
||||
** Standard library for string operations and pattern-matching
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -172,7 +172,7 @@ typedef struct MatchState {
|
||||
struct {
|
||||
const char *init;
|
||||
ptrdiff_t len;
|
||||
} capture[MAX_CAPTURES];
|
||||
} capture[LUA_MAXCAPTURES];
|
||||
} MatchState;
|
||||
|
||||
|
||||
@ -327,7 +327,7 @@ static const char *start_capture (MatchState *ms, const char *s,
|
||||
const char *p, int what) {
|
||||
const char *res;
|
||||
int level = ms->level;
|
||||
if (level >= MAX_CAPTURES) luaL_error(ms->L, "too many captures");
|
||||
if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
|
||||
ms->capture[level].init = s;
|
||||
ms->capture[level].len = what;
|
||||
ms->level = level+1;
|
||||
|
14
ltable.c
14
ltable.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltable.c,v 2.15 2005/01/10 18:17:39 roberto Exp roberto $
|
||||
** $Id: ltable.c,v 2.16 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** Lua tables (hash)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -38,10 +38,10 @@
|
||||
/*
|
||||
** max size of array part is 2^MAXBITS
|
||||
*/
|
||||
#if LUA_BITSINT > 26
|
||||
#if LUAC_BITSINT > 26
|
||||
#define MAXBITS 26
|
||||
#else
|
||||
#define MAXBITS (LUA_BITSINT-2)
|
||||
#define MAXBITS (LUAC_BITSINT-2)
|
||||
#endif
|
||||
|
||||
#define MAXASIZE (1 << MAXBITS)
|
||||
@ -120,7 +120,7 @@ static int arrayindex (const TValue *key) {
|
||||
lua_Number n = nvalue(key);
|
||||
int k;
|
||||
lua_number2int(k, n);
|
||||
if (num_eq(cast(lua_Number, k), nvalue(key)))
|
||||
if (luac_numeq(cast(lua_Number, k), nvalue(key)))
|
||||
return k;
|
||||
}
|
||||
return -1; /* `key' did not match some condition */
|
||||
@ -437,7 +437,7 @@ const TValue *luaH_getnum (Table *t, int key) {
|
||||
lua_Number nk = cast(lua_Number, key);
|
||||
Node *n = hashnum(t, nk);
|
||||
do { /* check whether `key' is somewhere in the chain */
|
||||
if (ttisnumber(gkey(n)) && num_eq(nvalue(gkey(n)), nk))
|
||||
if (ttisnumber(gkey(n)) && luac_numeq(nvalue(gkey(n)), nk))
|
||||
return gval(n); /* that's it */
|
||||
else n = gnext(n);
|
||||
} while (n);
|
||||
@ -470,7 +470,7 @@ const TValue *luaH_get (Table *t, const TValue *key) {
|
||||
case LUA_TNUMBER: {
|
||||
int k;
|
||||
lua_number2int(k, (nvalue(key)));
|
||||
if (num_eq(cast(lua_Number, k), nvalue(key))) /* is an integer index? */
|
||||
if (luac_numeq(cast(lua_Number, k), nvalue(key))) /* index is integer? */
|
||||
return luaH_getnum(t, k); /* use specialized version */
|
||||
/* else go through */
|
||||
}
|
||||
@ -494,7 +494,7 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
|
||||
return cast(TValue *, p);
|
||||
else {
|
||||
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
|
||||
else if (ttisnumber(key) && !num_eq(nvalue(key), nvalue(key)))
|
||||
else if (ttisnumber(key) && !luac_numeq(nvalue(key), nvalue(key)))
|
||||
luaG_runerror(L, "table index is NaN");
|
||||
return newkey(L, t, key);
|
||||
}
|
||||
|
283
luaconf.h
283
luaconf.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: luaconf.h,v 1.32 2005/03/08 18:00:16 roberto Exp roberto $
|
||||
** $Id: luaconf.h,v 1.33 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** Configuration file for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -30,7 +30,7 @@
|
||||
** =======================================================
|
||||
*/
|
||||
|
||||
/* default path */
|
||||
/* CONFIG: default path */
|
||||
#if defined(_WIN32)
|
||||
#define LUA_ROOT "C:\\Program Files\\Lua51"
|
||||
#define LUA_LDIR LUA_ROOT "\\lua"
|
||||
@ -51,33 +51,58 @@
|
||||
#endif
|
||||
|
||||
|
||||
/* CONFIG: directory separator (for submodules) */
|
||||
#if defined(_WIN32)
|
||||
#define LUA_DIRSEP "\\"
|
||||
#else
|
||||
#define LUA_DIRSEP "/"
|
||||
#endif
|
||||
|
||||
/* type of numbers in Lua */
|
||||
|
||||
/* CONFIG: environment variables that hold the search path for packages */
|
||||
#define LUA_PATH "LUA_PATH"
|
||||
#define LUA_CPATH "LUA_CPATH"
|
||||
|
||||
/* CONFIG: prefix for open functions in C libraries */
|
||||
#define LUA_POF "luaopen_"
|
||||
|
||||
/* CONFIG: separator for open functions in C libraries */
|
||||
#define LUA_OFSEP "_"
|
||||
|
||||
/* CONFIG: separator of templates in a path */
|
||||
#define LUA_PATHSEP ';'
|
||||
|
||||
/* CONFIG: wild char in each template */
|
||||
#define LUA_PATH_MARK "?"
|
||||
|
||||
|
||||
|
||||
/* CONFIG: type of numbers in Lua */
|
||||
#define LUA_NUMBER double
|
||||
|
||||
/* formats for Lua numbers */
|
||||
/* CONFIG: formats for Lua numbers */
|
||||
#define LUA_NUMBER_SCAN "%lf"
|
||||
#define LUA_NUMBER_FMT "%.14g"
|
||||
|
||||
|
||||
/*
|
||||
** type for integer functions
|
||||
** CONFIG: type for integer functions
|
||||
** on most machines, `ptrdiff_t' gives a reasonable size for integers
|
||||
*/
|
||||
#define LUA_INTEGER ptrdiff_t
|
||||
|
||||
|
||||
/* mark for all API functions */
|
||||
/* CONFIG: mark for all API functions */
|
||||
#define LUA_API extern
|
||||
|
||||
/* mark for auxlib functions */
|
||||
/* CONFIG: mark for auxlib functions */
|
||||
#define LUALIB_API extern
|
||||
|
||||
/* buffer size used by lauxlib buffer system */
|
||||
/* CONFIG: buffer size used by lauxlib buffer system */
|
||||
#define LUAL_BUFFERSIZE BUFSIZ
|
||||
|
||||
|
||||
/* assertions in Lua (mainly for internal debugging) */
|
||||
/* CONFIG: assertions in Lua (mainly for internal debugging) */
|
||||
#define lua_assert(c) ((void)0)
|
||||
|
||||
/* }====================================================== */
|
||||
@ -92,7 +117,7 @@
|
||||
|
||||
#ifdef lua_c
|
||||
|
||||
/* definition of `isatty' */
|
||||
/* CONFIG: definition of `isatty' */
|
||||
#ifdef _POSIX_C_SOURCE
|
||||
#include <unistd.h>
|
||||
#define stdin_is_tty() isatty(0)
|
||||
@ -113,7 +138,7 @@
|
||||
|
||||
|
||||
/*
|
||||
** this macro can be used by some `history' system to save lines
|
||||
** CONFIG: this macro can be used by some `history' system to save lines
|
||||
** read in manual input
|
||||
*/
|
||||
#define lua_saveline(L,line) /* empty */
|
||||
@ -126,86 +151,80 @@
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** {======================================================
|
||||
** Core configuration
|
||||
** =======================================================
|
||||
*/
|
||||
|
||||
#ifdef LUA_CORE
|
||||
|
||||
/* LUA-C API assertions */
|
||||
#define api_check(L,o) lua_assert(o)
|
||||
/* CONFIG: LUA-C API assertions */
|
||||
#define luac_apicheck(L,o) lua_assert(o)
|
||||
|
||||
|
||||
/* number of bits in an `int' */
|
||||
/* avoid overflows in comparison */
|
||||
#if INT_MAX-20 < 32760
|
||||
#define LUA_BITSINT 16
|
||||
#define LUAC_BITSINT 16
|
||||
#elif INT_MAX > 2147483640L
|
||||
/* `int' has at least 32 bits */
|
||||
#define LUA_BITSINT 32
|
||||
#define LUAC_BITSINT 32
|
||||
#else
|
||||
#error "you must define LUA_BITSINT with number of bits in an integer"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** L_UINT32: unsigned integer with at least 32 bits
|
||||
** L_INT32: signed integer with at least 32 bits
|
||||
** LU_MEM: an unsigned integer big enough to count the total memory used by Lua
|
||||
** L_MEM: a signed integer big enough to count the total memory used by Lua
|
||||
** CONFIG:
|
||||
** LUAC_UINT32: unsigned integer with at least 32 bits
|
||||
** LUAC_INT32: signed integer with at least 32 bits
|
||||
** LUAC_UMEM: an unsigned integer big enough to count the total memory
|
||||
** used by Lua
|
||||
** LUAC_MEM: a signed integer big enough to count the total memory used by Lua
|
||||
*/
|
||||
#if LUA_BITSINT >= 32
|
||||
#define LUA_UINT32 unsigned int
|
||||
#define LUA_INT32 int
|
||||
#define LUA_MAXINT32 INT_MAX
|
||||
#define LU_MEM size_t
|
||||
#define L_MEM ptrdiff_t
|
||||
#if LUAC_BITSINT >= 32
|
||||
#define LUAC_UINT32 unsigned int
|
||||
#define LUAC_INT32 int
|
||||
#define LUAC_MAXINT32 INT_MAX
|
||||
#define LUAC_UMEM size_t
|
||||
#define LUAC_MEM ptrdiff_t
|
||||
#else
|
||||
/* 16-bit ints */
|
||||
#define LUA_UINT32 unsigned long
|
||||
#define LUA_INT32 long
|
||||
#define LUA_MAXINT32 LONG_MAX
|
||||
#define LU_MEM LUA_UINT32
|
||||
#define L_MEM ptrdiff_t
|
||||
#define LUAC_UINT32 unsigned long
|
||||
#define LUAC_INT32 long
|
||||
#define LUAC_MAXINT32 LONG_MAX
|
||||
#define LUAC_UMEM LUAC_UINT32
|
||||
#define LUAC_MEM ptrdiff_t
|
||||
#endif
|
||||
|
||||
|
||||
/* maximum depth for calls (unsigned short) */
|
||||
#define LUA_MAXCALLS 10000
|
||||
/* CONFIG: maximum depth for calls (unsigned short) */
|
||||
#define LUAC_MAXCALLS 10000
|
||||
|
||||
/*
|
||||
** maximum depth for C calls (unsigned short): Not too big, or may
|
||||
** CONFIG: maximum depth for C calls (unsigned short): Not too big, or may
|
||||
** overflow the C stack...
|
||||
*/
|
||||
#define LUA_MAXCCALLS 200
|
||||
#define LUAC_MAXCCALLS 200
|
||||
|
||||
|
||||
/* maximum size for the virtual stack of a C function */
|
||||
#define MAXCSTACK 2048
|
||||
/* CONFIG: maximum size for the virtual stack of a C function */
|
||||
#define LUAC_MAXCSTACK 2048
|
||||
|
||||
|
||||
/*
|
||||
** maximum number of syntactical nested non-terminals: Not too big,
|
||||
** CONFIG: maximum number of syntactical nested non-terminals: Not too big,
|
||||
** or may overflow the C stack...
|
||||
*/
|
||||
#define LUA_MAXPARSERLEVEL 200
|
||||
#define LUAC_MAXPARSERLEVEL 200
|
||||
|
||||
|
||||
/* maximum number of variables declared in a function */
|
||||
#define MAXVARS 200 /* <MAXSTACK */
|
||||
/* CONFIG: maximum number of variables declared in a function */
|
||||
#define LUAC_MAXVARS 200 /* <MAXSTACK */
|
||||
|
||||
|
||||
/* maximum number of upvalues per function */
|
||||
#define MAXUPVALUES 60 /* <MAXSTACK */
|
||||
/* CONFIG: maximum number of upvalues per function */
|
||||
#define LUAC_MAXUPVALUES 60 /* <MAXSTACK */
|
||||
|
||||
|
||||
/* maximum size of expressions for optimizing `while' code */
|
||||
#define MAXEXPWHILE 100
|
||||
/* CONFIG: maximum size of expressions for optimizing `while' code */
|
||||
#define LUAC_MAXEXPWHILE 100
|
||||
|
||||
|
||||
/* function to convert a lua_Number to int (with any rounding method) */
|
||||
/* CONFIG: function to convert a lua_Number to int (with any rounding method) */
|
||||
#if defined(__GNUC__) && defined(__i386)
|
||||
#define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st")
|
||||
|
||||
@ -231,171 +250,133 @@ __inline int l_lrint (double flt)
|
||||
#endif
|
||||
|
||||
|
||||
/* function to convert a lua_Number to lua_Integer (with any rounding method) */
|
||||
/* CONFIG: function to convert a lua_Number to lua_Integer (with any rounding method) */
|
||||
#define lua_number2integer(i,n) lua_number2int((i), (n))
|
||||
|
||||
|
||||
/* function to convert a lua_Number to a string */
|
||||
/* CONFIG: function to convert a lua_Number to a string */
|
||||
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
|
||||
/* maximum size of previous conversion */
|
||||
#define MAX_NUMBER2STR 32 /* 16 digits, sign, point and \0 (+ some extra) */
|
||||
#define LUAC_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
|
||||
|
||||
/* function to convert a string to a lua_Number */
|
||||
/* CONFIG: function to convert a string to a lua_Number */
|
||||
#define lua_str2number(s,p) strtod((s), (p))
|
||||
|
||||
|
||||
|
||||
/* result of a `usual argument conversion' over lua_Number */
|
||||
#define LUA_UACNUMBER double
|
||||
/* CONFIG: result of a `usual argument conversion' over lua_Number */
|
||||
#define LUAC_UACNUMBER double
|
||||
|
||||
|
||||
/* primitive operators for numbers */
|
||||
#define num_add(a,b) ((a)+(b))
|
||||
#define num_sub(a,b) ((a)-(b))
|
||||
#define num_mul(a,b) ((a)*(b))
|
||||
#define num_div(a,b) ((a)/(b))
|
||||
#define num_unm(a) (-(a))
|
||||
#define num_eq(a,b) ((a)==(b))
|
||||
#define num_lt(a,b) ((a)<(b))
|
||||
#define num_le(a,b) ((a)<=(b))
|
||||
#define num_mod(a,b) ((a) - floor((a)/(b))*(b))
|
||||
#define num_pow(a,b) pow(a,b)
|
||||
/* CONFIG: primitive operators for numbers */
|
||||
#define luac_numadd(a,b) ((a)+(b))
|
||||
#define luac_numsub(a,b) ((a)-(b))
|
||||
#define luac_nummul(a,b) ((a)*(b))
|
||||
#define luac_numdiv(a,b) ((a)/(b))
|
||||
#define luac_numunm(a) (-(a))
|
||||
#define luac_numeq(a,b) ((a)==(b))
|
||||
#define luac_numlt(a,b) ((a)<(b))
|
||||
#define luac_numle(a,b) ((a)<=(b))
|
||||
#define luac_nummod(a,b) ((a) - floor((a)/(b))*(b))
|
||||
#define luac_numpow(a,b) pow(a,b)
|
||||
|
||||
|
||||
|
||||
/* type to ensure maximum alignment */
|
||||
#define LUSER_ALIGNMENT_T union { double u; void *s; long l; }
|
||||
/* CONFIG: type to ensure maximum alignment */
|
||||
#define LUAC_USER_ALIGNMENT_T union { double u; void *s; long l; }
|
||||
|
||||
|
||||
/*
|
||||
** exception handling: by default, Lua handles errors with longjmp/setjmp
|
||||
** when compiling as C code and with exceptions when compiling as C++ code.
|
||||
** Change that if you prefer to use longjmp/setjmp even with C++.
|
||||
** CONFIG: exception handling: by default, Lua handles errors with
|
||||
** longjmp/setjmp when compiling as C code and with exceptions
|
||||
** when compiling as C++ code. Change that if you prefer to use
|
||||
** longjmp/setjmp even with C++.
|
||||
*/
|
||||
#ifndef __cplusplus
|
||||
/* default handling with long jumps */
|
||||
#define L_THROW(L,c) longjmp((c)->b, 1)
|
||||
#define L_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
|
||||
#define l_jmpbuf jmp_buf
|
||||
#define LUAC_THROW(L,c) longjmp((c)->b, 1)
|
||||
#define LUAC_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
|
||||
#define luac_jmpbuf jmp_buf
|
||||
|
||||
#else
|
||||
/* C++ exceptions */
|
||||
#define L_THROW(L,c) throw(c)
|
||||
#define L_TRY(L,c,a) try { a } catch(...) \
|
||||
#define LUAC_THROW(L,c) throw(c)
|
||||
#define LUAC_TRY(L,c,a) try { a } catch(...) \
|
||||
{ if ((c)->status == 0) (c)->status = -1; }
|
||||
#define l_jmpbuf int /* dummy variable */
|
||||
#define luac_jmpbuf int /* dummy variable */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** macros for thread synchronization inside Lua core machine: This is
|
||||
** an attempt to simplify the implementation of a multithreaded version
|
||||
** of Lua. Do not change that unless you know what you are doing. all
|
||||
** accesses to the global state and to global objects are synchronized.
|
||||
** Because threads can read the stack of other threads (when running
|
||||
** garbage collection), a thread must also synchronize any write-access
|
||||
** to its own stack. Unsynchronized accesses are allowed only when
|
||||
** reading its own stack, or when reading immutable fields from global
|
||||
** objects (such as string values and udata values).
|
||||
** CONFIG: macros for thread synchronization inside Lua core
|
||||
** machine: This is an attempt to simplify the implementation of a
|
||||
** multithreaded version of Lua. Do not change that unless you know
|
||||
** what you are doing. all accesses to the global state and to global
|
||||
** objects are synchronized. Because threads can read the stack of
|
||||
** other threads (when running garbage collection), a thread must also
|
||||
** synchronize any write-access to its own stack. Unsynchronized
|
||||
** accesses are allowed only when reading its own stack, or when reading
|
||||
** immutable fields from global objects (such as string values and udata
|
||||
** values).
|
||||
*/
|
||||
#define lua_lock(L) ((void) 0)
|
||||
#define lua_unlock(L) ((void) 0)
|
||||
|
||||
|
||||
/*
|
||||
** this macro allows a thread switch in appropriate places in the Lua
|
||||
** core
|
||||
** CONFIG: this macro allows a thread switch in appropriate places in
|
||||
** the Lua core
|
||||
*/
|
||||
#define lua_threadyield(L) {lua_unlock(L); lua_lock(L);}
|
||||
|
||||
|
||||
|
||||
/* allows user-specific initialization on new threads */
|
||||
/* CONFIG: allows user-specific initialization on new threads */
|
||||
#define lua_userstateopen(L) ((void)0)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** {======================================================
|
||||
** Library configuration
|
||||
** =======================================================
|
||||
*/
|
||||
|
||||
#ifdef LUA_LIB
|
||||
|
||||
|
||||
/* environment variables that hold the search path for packages */
|
||||
#define LUA_PATH "LUA_PATH"
|
||||
#define LUA_CPATH "LUA_CPATH"
|
||||
|
||||
/* prefix for open functions in C libraries */
|
||||
#define LUA_POF "luaopen_"
|
||||
|
||||
/* separator for open functions in C libraries */
|
||||
#define LUA_OFSEP "_"
|
||||
|
||||
/* directory separator (for submodules) */
|
||||
#if defined(_WIN32)
|
||||
#define LUA_DIRSEP "\\"
|
||||
#else
|
||||
#define LUA_DIRSEP "/"
|
||||
#endif
|
||||
|
||||
/* separator of templates in a path */
|
||||
#define LUA_PATHSEP ';'
|
||||
|
||||
/* wild char in each template */
|
||||
#define LUA_PATH_MARK "?"
|
||||
|
||||
|
||||
/* maximum number of captures in pattern-matching (arbitrary limit) */
|
||||
#define MAX_CAPTURES 32
|
||||
/* CONFIG: maximum number of captures in pattern-matching (arbitrary limit) */
|
||||
#define LUA_MAXCAPTURES 32
|
||||
|
||||
|
||||
/*
|
||||
** by default, gcc does not get `os.tmpname', because it generates a warning
|
||||
** when using `tmpname'. Change that if you really want (or do not want)
|
||||
** `os.tmpname' available.
|
||||
** CONFIG: by default, gcc does not get `os.tmpname', because it
|
||||
** generates a warning when using `tmpname'. Change that if you really
|
||||
** want (or do not want) `os.tmpname' available.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define USE_TMPNAME 0
|
||||
#define LUA_USETMPNAME 0
|
||||
#else
|
||||
#define USE_TMPNAME 1
|
||||
#define LUA_USETMPNAME 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** Configuration for loadlib: Lua tries to guess the dynamic-library
|
||||
** system that your platform uses (either Windows' DLL, Mac's dyld, or
|
||||
** dlopen). If your system is some kind of Unix, there is a good chance
|
||||
** that USE_DLOPEN will work for it. You may need to adapt also the
|
||||
** makefile.
|
||||
** CONFIG: Configuration for loadlib: Lua tries to guess the
|
||||
** dynamic-library system that your platform uses (either Windows' DLL,
|
||||
** Mac's dyld, or dlopen). If your system is some kind of Unix, there is
|
||||
** a good chance that LUA_USEDLOPEN will work for it. You may need to adapt
|
||||
** also the makefile.
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
#define USE_DLL
|
||||
#define LUA_USEDLL
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#define USE_DYLD
|
||||
#define LUA_USEDYLD
|
||||
#elif defined(__linux) || defined(sun) || defined(sgi) || defined(BSD)
|
||||
#define USE_DLOPEN
|
||||
#define LUA_USEDLOPEN
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
|
||||
|
||||
/* ======================================================= */
|
||||
|
||||
/* Local configuration */
|
||||
|
||||
#undef USE_TMPNAME
|
||||
#define USE_TMPNAME 1
|
||||
#undef LUA_USETMPNAME
|
||||
#define LUA_USETMPNAME 1
|
||||
|
||||
#endif
|
||||
|
42
lvm.c
42
lvm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lvm.c,v 2.29 2005/03/08 18:00:16 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 2.30 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -49,7 +49,7 @@ int luaV_tostring (lua_State *L, StkId obj) {
|
||||
if (!ttisnumber(obj))
|
||||
return 0;
|
||||
else {
|
||||
char s[MAX_NUMBER2STR];
|
||||
char s[LUAC_MAXNUMBER2STR];
|
||||
lua_number2str(s, nvalue(obj));
|
||||
setsvalue2s(L, obj, luaS_new(L, s));
|
||||
return 1;
|
||||
@ -243,7 +243,7 @@ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
|
||||
if (ttype(l) != ttype(r))
|
||||
return luaG_ordererror(L, l, r);
|
||||
else if (ttisnumber(l))
|
||||
return num_lt(nvalue(l), nvalue(r));
|
||||
return luac_numlt(nvalue(l), nvalue(r));
|
||||
else if (ttisstring(l))
|
||||
return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
|
||||
else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
|
||||
@ -257,7 +257,7 @@ static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
|
||||
if (ttype(l) != ttype(r))
|
||||
return luaG_ordererror(L, l, r);
|
||||
else if (ttisnumber(l))
|
||||
return num_le(nvalue(l), nvalue(r));
|
||||
return luac_numle(nvalue(l), nvalue(r));
|
||||
else if (ttisstring(l))
|
||||
return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
|
||||
else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
|
||||
@ -273,7 +273,7 @@ int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
|
||||
lua_assert(ttype(t1) == ttype(t2));
|
||||
switch (ttype(t1)) {
|
||||
case LUA_TNIL: return 1;
|
||||
case LUA_TNUMBER: return num_eq(nvalue(t1), nvalue(t2));
|
||||
case LUA_TNUMBER: return luac_numeq(nvalue(t1), nvalue(t2));
|
||||
case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
|
||||
case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
|
||||
case LUA_TUSERDATA: {
|
||||
@ -338,12 +338,12 @@ static StkId Arith (lua_State *L, StkId ra, const TValue *rb,
|
||||
(c = luaV_tonumber(rc, &tempc)) != NULL) {
|
||||
lua_Number nb = nvalue(b), nc = nvalue(c);
|
||||
switch (op) {
|
||||
case TM_ADD: setnvalue(ra, num_add(nb, nc)); break;
|
||||
case TM_SUB: setnvalue(ra, num_sub(nb, nc)); break;
|
||||
case TM_MUL: setnvalue(ra, num_mul(nb, nc)); break;
|
||||
case TM_DIV: setnvalue(ra, num_div(nb, nc)); break;
|
||||
case TM_MOD: setnvalue(ra, num_mod(nb, nc)); break;
|
||||
case TM_POW: setnvalue(ra, num_pow(nb, nc)); break;
|
||||
case TM_ADD: setnvalue(ra, luac_numadd(nb, nc)); break;
|
||||
case TM_SUB: setnvalue(ra, luac_numsub(nb, nc)); break;
|
||||
case TM_MUL: setnvalue(ra, luac_nummul(nb, nc)); break;
|
||||
case TM_DIV: setnvalue(ra, luac_numdiv(nb, nc)); break;
|
||||
case TM_MOD: setnvalue(ra, luac_nummod(nb, nc)); break;
|
||||
case TM_POW: setnvalue(ra, luac_numpow(nb, nc)); break;
|
||||
default: lua_assert(0); break;
|
||||
}
|
||||
}
|
||||
@ -480,7 +480,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, num_add(nb, nc));
|
||||
setnvalue(ra, luac_numadd(nb, nc));
|
||||
}
|
||||
else
|
||||
base = Arith(L, ra, rb, rc, TM_ADD, pc); /***/
|
||||
@ -491,7 +491,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, num_sub(nb, nc));
|
||||
setnvalue(ra, luac_numsub(nb, nc));
|
||||
}
|
||||
else
|
||||
base = Arith(L, ra, rb, rc, TM_SUB, pc); /***/
|
||||
@ -502,7 +502,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, num_mul(nb, nc));
|
||||
setnvalue(ra, luac_nummul(nb, nc));
|
||||
}
|
||||
else
|
||||
base = Arith(L, ra, rb, rc, TM_MUL, pc); /***/
|
||||
@ -513,7 +513,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, num_div(nb, nc));
|
||||
setnvalue(ra, luac_numdiv(nb, nc));
|
||||
}
|
||||
else
|
||||
base = Arith(L, ra, rb, rc, TM_DIV, pc); /***/
|
||||
@ -524,7 +524,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, num_mod(nb, nc));
|
||||
setnvalue(ra, luac_nummod(nb, nc));
|
||||
}
|
||||
else
|
||||
base = Arith(L, ra, rb, rc, TM_MOD, pc); /***/
|
||||
@ -535,7 +535,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, num_pow(nb, nc));
|
||||
setnvalue(ra, luac_numpow(nb, nc));
|
||||
}
|
||||
else
|
||||
base = Arith(L, ra, rb, rc, TM_POW, pc); /***/
|
||||
@ -546,7 +546,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue temp;
|
||||
if (tonumber(rb, &temp)) {
|
||||
lua_Number nb = nvalue(rb);
|
||||
setnvalue(ra, num_unm(nb));
|
||||
setnvalue(ra, luac_numunm(nb));
|
||||
}
|
||||
else {
|
||||
setnilvalue(&temp);
|
||||
@ -682,9 +682,9 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
}
|
||||
case OP_FORLOOP: {
|
||||
lua_Number step = nvalue(ra+2);
|
||||
lua_Number idx = num_add(nvalue(ra), step); /* increment index */
|
||||
lua_Number idx = luac_numadd(nvalue(ra), step); /* increment index */
|
||||
lua_Number limit = nvalue(ra+1);
|
||||
if (step > 0 ? num_le(idx, limit) : num_le(limit, idx)) {
|
||||
if (step > 0 ? luac_numle(idx, limit) : luac_numle(limit, idx)) {
|
||||
dojump(L, pc, GETARG_sBx(i)); /* jump back */
|
||||
setnvalue(ra, idx); /* update internal index... */
|
||||
setnvalue(ra+3, idx); /* ...and external index */
|
||||
@ -702,7 +702,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
luaG_runerror(L, "`for' limit must be a number");
|
||||
else if (!tonumber(pstep, ra+2))
|
||||
luaG_runerror(L, "`for' step must be a number");
|
||||
setnvalue(ra, num_sub(nvalue(ra), nvalue(pstep)));
|
||||
setnvalue(ra, luac_numsub(nvalue(ra), nvalue(pstep)));
|
||||
dojump(L, pc, GETARG_sBx(i));
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user