mirror of https://github.com/rusefi/lua.git
`luac´ -> `luai' (to avoid confusion with other luac stuff)
This commit is contained in:
parent
f8df21bd20
commit
370d31a559
4
lapi.c
4
lapi.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lapi.c,v 2.29 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.30 2005/03/08 20:10:05 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) > LUAC_MAXCSTACK)
|
||||
if ((L->top - L->base + size) > LUAI_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.9 2005/01/10 18:17:39 roberto Exp roberto $
|
||||
** $Id: lcode.c,v 2.10 2005/03/08 20:10:05 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, luac_numunm(nvalue(&fs->f->k[e->info])));
|
||||
e->info = luaK_numberK(fs, luai_numunm(nvalue(&fs->f->k[e->info])));
|
||||
else {
|
||||
luaK_exp2anyreg(fs, e);
|
||||
freeexp(fs, e);
|
||||
|
|
24
ldo.c
24
ldo.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ldo.c,v 2.15 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** $Id: ldo.c,v 2.16 2005/03/08 20:10:05 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;
|
||||
luac_jmpbuf b;
|
||||
luai_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;
|
||||
LUAC_THROW(L, L->errorJmp);
|
||||
LUAI_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;
|
||||
LUAC_TRY(L, &lj,
|
||||
LUAI_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 > LUAC_MAXCALLS) { /* there was an overflow? */
|
||||
if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
|
||||
int inuse = (L->ci - L->base_ci);
|
||||
if (inuse + 1 < LUAC_MAXCALLS) /* can `undo' overflow? */
|
||||
luaD_reallocCI(L, LUAC_MAXCALLS);
|
||||
if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */
|
||||
luaD_reallocCI(L, LUAI_MAXCALLS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,11 +149,11 @@ void luaD_growstack (lua_State *L, int n) {
|
|||
|
||||
|
||||
static CallInfo *growCI (lua_State *L) {
|
||||
if (L->size_ci > LUAC_MAXCALLS) /* overflow while handling overflow? */
|
||||
if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
|
||||
luaD_throw(L, LUA_ERRERR);
|
||||
else {
|
||||
luaD_reallocCI(L, 2*L->size_ci);
|
||||
if (L->size_ci > LUAC_MAXCALLS)
|
||||
if (L->size_ci > LUAI_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 >= LUAC_MAXCCALLS) {
|
||||
if (L->nCcalls == LUAC_MAXCCALLS)
|
||||
if (++L->nCcalls >= LUAI_MAXCCALLS) {
|
||||
if (L->nCcalls == LUAI_MAXCCALLS)
|
||||
luaG_runerror(L, "C stack overflow");
|
||||
else if (L->nCcalls >= (LUAC_MAXCCALLS + (LUAC_MAXCCALLS>>3)))
|
||||
else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_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.27 2005/02/23 17:30:22 roberto Exp roberto $
|
||||
** $Id: lgc.c,v 2.28 2005/03/08 20:10:05 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 > LUAC_MAXCALLS) /* handling overflow? */
|
||||
if (L->size_ci > LUAI_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.63 2005/01/14 14:19:42 roberto Exp roberto $
|
||||
** $Id: llimits.h,v 1.64 2005/03/08 20:10:05 roberto Exp roberto $
|
||||
** Limits, basic types, and some other `installation-dependent' definitions
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -15,14 +15,14 @@
|
|||
#include "lua.h"
|
||||
|
||||
|
||||
#define api_check luac_apicheck
|
||||
#define api_check luai_apicheck
|
||||
|
||||
|
||||
typedef LUAC_UINT32 lu_int32;
|
||||
typedef LUAI_UINT32 lu_int32;
|
||||
|
||||
typedef LUAC_UMEM lu_mem;
|
||||
typedef LUAI_UMEM lu_mem;
|
||||
|
||||
typedef LUAC_MEM l_mem;
|
||||
typedef LUAI_MEM l_mem;
|
||||
|
||||
|
||||
|
||||
|
@ -47,11 +47,11 @@ typedef unsigned char lu_byte;
|
|||
|
||||
|
||||
/* type to ensure maximum alignment */
|
||||
typedef LUAC_USER_ALIGNMENT_T L_Umaxalign;
|
||||
typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
|
||||
|
||||
|
||||
/* result of a `usual argument conversion' over lua_Number */
|
||||
typedef LUAC_UACNUMBER l_uacNumber;
|
||||
typedef LUAI_UACNUMBER l_uacNumber;
|
||||
|
||||
|
||||
#define check_exp(c,e) (lua_assert(c), (e))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: loadlib.c,v 1.19 2005/03/07 18:07:34 roberto Exp roberto $
|
||||
** $Id: loadlib.c,v 1.20 2005/03/08 20:10:05 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(LUA_USEDLOPEN)
|
||||
#if defined(LUA_USE_DLOPEN)
|
||||
/*
|
||||
** {========================================================================
|
||||
** 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(LUA_USEDLL)
|
||||
#elif defined(LUA_USE_DLL)
|
||||
/*
|
||||
** {======================================================================
|
||||
** 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(LUA_USEDYLD)
|
||||
#elif defined(LUA_USE_DYLD)
|
||||
/*
|
||||
** {======================================================================
|
||||
** Native Mac OS X / Darwin Implementation
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lobject.c,v 2.9 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** $Id: lobject.c,v 2.10 2005/03/08 20:10:05 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 luac_numeq(nvalue(t1), nvalue(t2));
|
||||
return luai_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.115 2005/03/08 18:00:16 roberto Exp roberto $
|
||||
** $Id: lopcodes.h,v 1.116 2005/03/08 20:10:05 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 LUAC_BITSINT-1 bits (-1 for sign)
|
||||
** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
|
||||
*/
|
||||
#if SIZE_Bx < LUAC_BITSINT-1
|
||||
#if SIZE_Bx < LUAI_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.4 2005/01/10 19:16:29 roberto Exp roberto $
|
||||
** $Id: loslib.c,v 1.5 2005/03/08 20:10:05 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 !LUA_USETMPNAME
|
||||
#if !LUA_USE_TMPNAME
|
||||
luaL_error(L, "`tmpname' not supported");
|
||||
return 0;
|
||||
#else
|
||||
|
|
12
lparser.c
12
lparser.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lparser.c,v 2.16 2005/03/08 18:16:45 roberto Exp roberto $
|
||||
** $Id: lparser.c,v 2.17 2005/03/08 20:10:05 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 > LUAC_MAXPARSERLEVEL) \
|
||||
#define enterlevel(ls) if (++(ls)->nestlevel > LUAI_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, LUAC_MAXVARS, "local variables");
|
||||
luaY_checklimit(fs, fs->nactvar+n+1, LUAI_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, LUAC_MAXUPVALUES, "upvalues");
|
||||
luaY_checklimit(fs, f->nups + 1, LUAI_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[LUAC_MAXEXPWHILE + EXTRAEXP];
|
||||
Instruction codeexp[LUAI_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 > LUAC_MAXEXPWHILE)
|
||||
if (sizeexp > LUAI_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.52 2005/03/07 16:58:27 roberto Exp roberto $
|
||||
** $Id: lparser.h,v 1.53 2005/03/08 20:10:05 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[LUAC_MAXUPVALUES]; /* upvalues */
|
||||
unsigned short actvar[LUAC_MAXVARS]; /* declared-variable stack */
|
||||
upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */
|
||||
unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */
|
||||
} FuncState;
|
||||
|
||||
|
||||
|
|
14
ltable.c
14
ltable.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ltable.c,v 2.16 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** $Id: ltable.c,v 2.17 2005/03/08 20:10:05 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 LUAC_BITSINT > 26
|
||||
#if LUAI_BITSINT > 26
|
||||
#define MAXBITS 26
|
||||
#else
|
||||
#define MAXBITS (LUAC_BITSINT-2)
|
||||
#define MAXBITS (LUAI_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 (luac_numeq(cast(lua_Number, k), nvalue(key)))
|
||||
if (luai_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)) && luac_numeq(nvalue(gkey(n)), nk))
|
||||
if (ttisnumber(gkey(n)) && luai_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 (luac_numeq(cast(lua_Number, k), nvalue(key))) /* index is integer? */
|
||||
if (luai_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) && !luac_numeq(nvalue(key), nvalue(key)))
|
||||
else if (ttisnumber(key) && !luai_numeq(nvalue(key), nvalue(key)))
|
||||
luaG_runerror(L, "table index is NaN");
|
||||
return newkey(L, t, key);
|
||||
}
|
||||
|
|
106
luaconf.h
106
luaconf.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: luaconf.h,v 1.33 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** $Id: luaconf.h,v 1.34 2005/03/08 20:10:05 roberto Exp roberto $
|
||||
** Configuration file for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -152,16 +152,16 @@
|
|||
|
||||
|
||||
/* CONFIG: LUA-C API assertions */
|
||||
#define luac_apicheck(L,o) lua_assert(o)
|
||||
#define luai_apicheck(L,o) lua_assert(o)
|
||||
|
||||
|
||||
/* number of bits in an `int' */
|
||||
/* avoid overflows in comparison */
|
||||
#if INT_MAX-20 < 32760
|
||||
#define LUAC_BITSINT 16
|
||||
#define LUAI_BITSINT 16
|
||||
#elif INT_MAX > 2147483640L
|
||||
/* `int' has at least 32 bits */
|
||||
#define LUAC_BITSINT 32
|
||||
#define LUAI_BITSINT 32
|
||||
#else
|
||||
#error "you must define LUA_BITSINT with number of bits in an integer"
|
||||
#endif
|
||||
|
@ -169,59 +169,59 @@
|
|||
|
||||
/*
|
||||
** 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
|
||||
** LUAI_UINT32: unsigned integer with at least 32 bits
|
||||
** LUAI_INT32: signed integer with at least 32 bits
|
||||
** LUAI_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
|
||||
** LUAI_MEM: a signed integer big enough to count the total memory used by Lua
|
||||
*/
|
||||
#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
|
||||
#if LUAI_BITSINT >= 32
|
||||
#define LUAI_UINT32 unsigned int
|
||||
#define LUAI_INT32 int
|
||||
#define LUAI_MAXINT32 INT_MAX
|
||||
#define LUAI_UMEM size_t
|
||||
#define LUAI_MEM ptrdiff_t
|
||||
#else
|
||||
/* 16-bit ints */
|
||||
#define LUAC_UINT32 unsigned long
|
||||
#define LUAC_INT32 long
|
||||
#define LUAC_MAXINT32 LONG_MAX
|
||||
#define LUAC_UMEM LUAC_UINT32
|
||||
#define LUAC_MEM ptrdiff_t
|
||||
#define LUAI_UINT32 unsigned long
|
||||
#define LUAI_INT32 long
|
||||
#define LUAI_MAXINT32 LONG_MAX
|
||||
#define LUAI_UMEM LUAI_UINT32
|
||||
#define LUAI_MEM ptrdiff_t
|
||||
#endif
|
||||
|
||||
|
||||
/* CONFIG: maximum depth for calls (unsigned short) */
|
||||
#define LUAC_MAXCALLS 10000
|
||||
#define LUAI_MAXCALLS 10000
|
||||
|
||||
/*
|
||||
** CONFIG: maximum depth for C calls (unsigned short): Not too big, or may
|
||||
** overflow the C stack...
|
||||
*/
|
||||
#define LUAC_MAXCCALLS 200
|
||||
#define LUAI_MAXCCALLS 200
|
||||
|
||||
|
||||
/* CONFIG: maximum size for the virtual stack of a C function */
|
||||
#define LUAC_MAXCSTACK 2048
|
||||
#define LUAI_MAXCSTACK 2048
|
||||
|
||||
|
||||
/*
|
||||
** CONFIG: maximum number of syntactical nested non-terminals: Not too big,
|
||||
** or may overflow the C stack...
|
||||
*/
|
||||
#define LUAC_MAXPARSERLEVEL 200
|
||||
#define LUAI_MAXPARSERLEVEL 200
|
||||
|
||||
|
||||
/* CONFIG: maximum number of variables declared in a function */
|
||||
#define LUAC_MAXVARS 200 /* <MAXSTACK */
|
||||
#define LUAI_MAXVARS 200 /* <MAXSTACK */
|
||||
|
||||
|
||||
/* CONFIG: maximum number of upvalues per function */
|
||||
#define LUAC_MAXUPVALUES 60 /* <MAXSTACK */
|
||||
#define LUAI_MAXUPVALUES 60 /* <MAXSTACK */
|
||||
|
||||
|
||||
/* CONFIG: maximum size of expressions for optimizing `while' code */
|
||||
#define LUAC_MAXEXPWHILE 100
|
||||
#define LUAI_MAXEXPWHILE 100
|
||||
|
||||
|
||||
/* CONFIG: function to convert a lua_Number to int (with any rounding method) */
|
||||
|
@ -257,7 +257,7 @@ __inline int l_lrint (double flt)
|
|||
/* 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 LUAC_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
|
||||
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
|
||||
|
||||
/* CONFIG: function to convert a string to a lua_Number */
|
||||
#define lua_str2number(s,p) strtod((s), (p))
|
||||
|
@ -265,25 +265,25 @@ __inline int l_lrint (double flt)
|
|||
|
||||
|
||||
/* CONFIG: result of a `usual argument conversion' over lua_Number */
|
||||
#define LUAC_UACNUMBER double
|
||||
#define LUAI_UACNUMBER double
|
||||
|
||||
|
||||
/* 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)
|
||||
#define luai_numadd(a,b) ((a)+(b))
|
||||
#define luai_numsub(a,b) ((a)-(b))
|
||||
#define luai_nummul(a,b) ((a)*(b))
|
||||
#define luai_numdiv(a,b) ((a)/(b))
|
||||
#define luai_numunm(a) (-(a))
|
||||
#define luai_numeq(a,b) ((a)==(b))
|
||||
#define luai_numlt(a,b) ((a)<(b))
|
||||
#define luai_numle(a,b) ((a)<=(b))
|
||||
#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
|
||||
#define luai_numpow(a,b) pow(a,b)
|
||||
|
||||
|
||||
|
||||
/* CONFIG: type to ensure maximum alignment */
|
||||
#define LUAC_USER_ALIGNMENT_T union { double u; void *s; long l; }
|
||||
#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
|
||||
|
||||
|
||||
/*
|
||||
|
@ -294,16 +294,16 @@ __inline int l_lrint (double flt)
|
|||
*/
|
||||
#ifndef __cplusplus
|
||||
/* default handling with long jumps */
|
||||
#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
|
||||
#define LUAI_THROW(L,c) longjmp((c)->b, 1)
|
||||
#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
|
||||
#define luai_jmpbuf jmp_buf
|
||||
|
||||
#else
|
||||
/* C++ exceptions */
|
||||
#define LUAC_THROW(L,c) throw(c)
|
||||
#define LUAC_TRY(L,c,a) try { a } catch(...) \
|
||||
#define LUAI_THROW(L,c) throw(c)
|
||||
#define LUAI_TRY(L,c,a) try { a } catch(...) \
|
||||
{ if ((c)->status == 0) (c)->status = -1; }
|
||||
#define luac_jmpbuf int /* dummy variable */
|
||||
#define luai_jmpbuf int /* dummy variable */
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -349,9 +349,9 @@ __inline int l_lrint (double flt)
|
|||
** want (or do not want) `os.tmpname' available.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define LUA_USETMPNAME 0
|
||||
#define LUA_USE_TMPNAME 0
|
||||
#else
|
||||
#define LUA_USETMPNAME 1
|
||||
#define LUA_USE_TMPNAME 1
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -359,15 +359,15 @@ __inline int l_lrint (double flt)
|
|||
** 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
|
||||
** a good chance that LUA_USE_DLOPEN will work for it. You may need to adapt
|
||||
** also the makefile.
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
#define LUA_USEDLL
|
||||
#define LUA_USE_DLL
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#define LUA_USEDYLD
|
||||
#define LUA_USE_DYLD
|
||||
#elif defined(__linux) || defined(sun) || defined(sgi) || defined(BSD)
|
||||
#define LUA_USEDLOPEN
|
||||
#define LUA_USE_DLOPEN
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -376,7 +376,7 @@ __inline int l_lrint (double flt)
|
|||
|
||||
/* Local configuration */
|
||||
|
||||
#undef LUA_USETMPNAME
|
||||
#define LUA_USETMPNAME 1
|
||||
#undef LUA_USE_TMPNAME
|
||||
#define LUA_USE_TMPNAME 1
|
||||
|
||||
#endif
|
||||
|
|
42
lvm.c
42
lvm.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lvm.c,v 2.30 2005/03/08 18:09:16 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 2.31 2005/03/08 20:10:05 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[LUAC_MAXNUMBER2STR];
|
||||
char s[LUAI_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 luac_numlt(nvalue(l), nvalue(r));
|
||||
return luai_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 luac_numle(nvalue(l), nvalue(r));
|
||||
return luai_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 luac_numeq(nvalue(t1), nvalue(t2));
|
||||
case LUA_TNUMBER: return luai_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, 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;
|
||||
case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
|
||||
case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
|
||||
case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
|
||||
case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
|
||||
case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
|
||||
case TM_POW: setnvalue(ra, luai_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, luac_numadd(nb, nc));
|
||||
setnvalue(ra, luai_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, luac_numsub(nb, nc));
|
||||
setnvalue(ra, luai_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, luac_nummul(nb, nc));
|
||||
setnvalue(ra, luai_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, luac_numdiv(nb, nc));
|
||||
setnvalue(ra, luai_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, luac_nummod(nb, nc));
|
||||
setnvalue(ra, luai_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, luac_numpow(nb, nc));
|
||||
setnvalue(ra, luai_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, luac_numunm(nb));
|
||||
setnvalue(ra, luai_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 = luac_numadd(nvalue(ra), step); /* increment index */
|
||||
lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
|
||||
lua_Number limit = nvalue(ra+1);
|
||||
if (step > 0 ? luac_numle(idx, limit) : luac_numle(limit, idx)) {
|
||||
if (step > 0 ? luai_numle(idx, limit) : luai_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, luac_numsub(nvalue(ra), nvalue(pstep)));
|
||||
setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
|
||||
dojump(L, pc, GETARG_sBx(i));
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue