mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
comments.
This commit is contained in:
parent
5b08fcd5a1
commit
acdb0b741e
4
lapi.c
4
lapi.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 1.64 1999/12/14 18:31:20 roberto Exp roberto $
|
** $Id: lapi.c,v 1.65 1999/12/23 18:19:57 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -79,7 +79,7 @@ lua_Object luaA_putObjectOnTop (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
static void top2LC (lua_State *L, int n) {
|
static void top2LC (lua_State *L, int n) {
|
||||||
/* Put the 'n' elements on the top as the Lua2C contents */
|
/* Put the `n' elements on the top as the Lua2C contents */
|
||||||
L->Cstack.base = L->top; /* new base */
|
L->Cstack.base = L->top; /* new base */
|
||||||
L->Cstack.lua2C = L->Cstack.base-n; /* position of the new results */
|
L->Cstack.lua2C = L->Cstack.base-n; /* position of the new results */
|
||||||
L->Cstack.num = n; /* number of results */
|
L->Cstack.num = n; /* number of results */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.21 1999/11/22 13:12:07 roberto Exp roberto $
|
** $Id: lauxlib.c,v 1.22 1999/12/20 13:09:45 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* Please Notice: This file uses only the official API of Lua
|
/* This file uses only the official API of Lua.
|
||||||
** Any function declared here could be written as an application function.
|
** Any function declared here could be written as an application function.
|
||||||
** With care, these functions can be used by other libraries.
|
** With care, these functions can be used by other libraries.
|
||||||
*/
|
*/
|
||||||
@ -113,7 +113,7 @@ void luaL_verror (lua_State *L, const char *fmt, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define EXTRALEN 13 /* > strlen('string "..."\0') */
|
#define EXTRALEN sizeof("string \"...\"0")
|
||||||
|
|
||||||
void luaL_chunkid (char *out, const char *source, int len) {
|
void luaL_chunkid (char *out, const char *source, int len) {
|
||||||
if (*source == '(') {
|
if (*source == '(') {
|
||||||
@ -129,7 +129,7 @@ void luaL_chunkid (char *out, const char *source, int len) {
|
|||||||
const char *b = strchr(source , '\n'); /* stop at first new line */
|
const char *b = strchr(source , '\n'); /* stop at first new line */
|
||||||
int lim = (b && (b-source)<len) ? b-source : len;
|
int lim = (b && (b-source)<len) ? b-source : len;
|
||||||
sprintf(out, "string \"%.*s\"", lim, source);
|
sprintf(out, "string \"%.*s\"", lim, source);
|
||||||
strcpy(out+lim+(EXTRALEN-5), "...\""); /* 5 = strlen("...'\0") */
|
strcpy(out+lim+(EXTRALEN-sizeof("...\"0")), "...\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
lbuiltin.c
14
lbuiltin.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lbuiltin.c,v 1.87 1999/12/23 18:19:57 roberto Exp roberto $
|
** $Id: lbuiltin.c,v 1.88 1999/12/27 13:04:53 roberto Exp roberto $
|
||||||
** Built-in functions
|
** Built-in functions
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -94,16 +94,16 @@ static Hash *gettable (lua_State *L, int arg) {
|
|||||||
** If your system does not support "stderr", redefine this function, or
|
** If your system does not support "stderr", redefine this function, or
|
||||||
** redefine _ERRORMESSAGE so that it won't need _ALERT.
|
** redefine _ERRORMESSAGE so that it won't need _ALERT.
|
||||||
*/
|
*/
|
||||||
void luaB_alert (lua_State *L) {
|
void luaB__alert (lua_State *L) {
|
||||||
fputs(luaL_check_string(L, 1), stderr);
|
fputs(luaL_check_string(L, 1), stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Standard implementation of _ERRORMESSAGE.
|
** Standard implementation of _ERRORMESSAGE.
|
||||||
** The library "iolib" redefines _ERRORMESSAGE for better error information.
|
** The library `liolib' redefines _ERRORMESSAGE for better error information.
|
||||||
*/
|
*/
|
||||||
void luaB_ERRORMESSAGE (lua_State *L) {
|
void luaB__ERRORMESSAGE (lua_State *L) {
|
||||||
lua_Object al = lua_rawgetglobal(L, "_ALERT");
|
lua_Object al = lua_rawgetglobal(L, "_ALERT");
|
||||||
if (lua_isfunction(L, al)) { /* avoid error loop if _ALERT is not defined */
|
if (lua_isfunction(L, al)) { /* avoid error loop if _ALERT is not defined */
|
||||||
char buff[600];
|
char buff[600];
|
||||||
@ -529,7 +529,7 @@ static void swap (lua_State *L, Hash *a, int i, int j) {
|
|||||||
|
|
||||||
static int sort_comp (lua_State *L, lua_Object f, const TObject *a,
|
static int sort_comp (lua_State *L, lua_Object f, const TObject *a,
|
||||||
const TObject *b) {
|
const TObject *b) {
|
||||||
/* notice: the caller (auxsort) must check stack space */
|
/* WARNING: the caller (auxsort) must ensure stack space */
|
||||||
if (f != LUA_NOOBJECT) {
|
if (f != LUA_NOOBJECT) {
|
||||||
*(L->top) = *f;
|
*(L->top) = *f;
|
||||||
*(L->top+1) = *a;
|
*(L->top+1) = *a;
|
||||||
@ -609,8 +609,8 @@ void luaB_sort (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
static const struct luaL_reg builtin_funcs[] = {
|
static const struct luaL_reg builtin_funcs[] = {
|
||||||
{"_ALERT", luaB_alert},
|
{"_ALERT", luaB__alert},
|
||||||
{"_ERRORMESSAGE", luaB_ERRORMESSAGE},
|
{"_ERRORMESSAGE", luaB__ERRORMESSAGE},
|
||||||
{"call", luaB_call},
|
{"call", luaB_call},
|
||||||
{"collectgarbage", luaB_collectgarbage},
|
{"collectgarbage", luaB_collectgarbage},
|
||||||
{"copytagmethods", luaB_copytagmethods},
|
{"copytagmethods", luaB_copytagmethods},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lbuiltin.h,v 1.2 1999/11/22 13:12:07 roberto Exp roberto $
|
** $Id: lbuiltin.h,v 1.3 1999/12/14 18:33:29 roberto Exp roberto $
|
||||||
** Built-in functions
|
** Built-in functions
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
void luaB_alert (lua_State *L);
|
void luaB__alert (lua_State *L);
|
||||||
void luaB_ERRORMESSAGE (lua_State *L);
|
void luaB__ERRORMESSAGE (lua_State *L);
|
||||||
void luaB_print (lua_State *L);
|
void luaB_print (lua_State *L);
|
||||||
void luaB_tonumber (lua_State *L);
|
void luaB_tonumber (lua_State *L);
|
||||||
void luaB_error (lua_State *L);
|
void luaB_error (lua_State *L);
|
||||||
|
8
ldo.c
8
ldo.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.59 1999/12/21 18:04:41 roberto Exp roberto $
|
** $Id: ldo.c,v 1.60 1999/12/23 18:19:57 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -56,7 +56,7 @@ void luaD_checkstack (lua_State *L, int n) {
|
|||||||
else {
|
else {
|
||||||
L->stack_last += EXTRA_STACK; /* to be used by error message */
|
L->stack_last += EXTRA_STACK; /* to be used by error message */
|
||||||
if (lua_stackedfunction(L, L->stacksize/SLOTS_PER_F) == LUA_NOOBJECT) {
|
if (lua_stackedfunction(L, L->stacksize/SLOTS_PER_F) == LUA_NOOBJECT) {
|
||||||
/* too few funcs on stack: doesn't look like a rec. loop */
|
/* too few funcs on stack: doesn't look like a recursion loop */
|
||||||
lua_error(L, "Lua2C - C2Lua overflow");
|
lua_error(L, "Lua2C - C2Lua overflow");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -253,14 +253,14 @@ static void message (lua_State *L, const char *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Reports an error, and jumps up to the available recover label
|
** Reports an error, and jumps up to the available recovery label
|
||||||
*/
|
*/
|
||||||
void lua_error (lua_State *L, const char *s) {
|
void lua_error (lua_State *L, const char *s) {
|
||||||
if (s) message(L, s);
|
if (s) message(L, s);
|
||||||
if (L->errorJmp)
|
if (L->errorJmp)
|
||||||
longjmp(L->errorJmp->b, 1);
|
longjmp(L->errorJmp->b, 1);
|
||||||
else {
|
else {
|
||||||
message(L, "exit(1). Unable to recover.\n");
|
message(L, "unable to recover. exiting.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
lfunc.c
4
lfunc.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lfunc.c,v 1.14 1999/11/10 15:39:35 roberto Exp roberto $
|
** $Id: lfunc.c,v 1.15 1999/11/22 13:12:07 roberto Exp roberto $
|
||||||
** Auxiliary functions to manipulate prototypes and closures
|
** Auxiliary functions to manipulate prototypes and closures
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -61,7 +61,7 @@ void luaF_freeclosure (lua_State *L, Closure *c) {
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Look for n-th local variable at line "line" in function "func".
|
** Look for n-th local variable at line `line' in function `func'.
|
||||||
** Returns NULL if not found.
|
** Returns NULL if not found.
|
||||||
*/
|
*/
|
||||||
const char *luaF_getlocalname (const TProtoFunc *func,
|
const char *luaF_getlocalname (const TProtoFunc *func,
|
||||||
|
4
lfunc.h
4
lfunc.h
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lfunc.h,v 1.8 1999/10/14 19:46:57 roberto Exp roberto $
|
** $Id: lfunc.h,v 1.9 1999/11/22 13:12:07 roberto Exp roberto $
|
||||||
** Lua Function structures
|
** Auxiliary functions to manipulate prototypes and closures
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
6
lgc.c
6
lgc.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lgc.c,v 1.37 1999/12/21 18:04:41 roberto Exp roberto $
|
** $Id: lgc.c,v 1.38 1999/12/23 18:19:57 roberto Exp roberto $
|
||||||
** Garbage Collector
|
** Garbage Collector
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -181,7 +181,7 @@ static void clear_global_list (lua_State *L, int limit) {
|
|||||||
** with limit=MAX_INT, that means all elements.
|
** with limit=MAX_INT, that means all elements.
|
||||||
*/
|
*/
|
||||||
static void collectstring (lua_State *L, int limit) {
|
static void collectstring (lua_State *L, int limit) {
|
||||||
TObject o; /* to call userdata 'gc' tag method */
|
TObject o; /* to call userdata `gc' tag method */
|
||||||
int i;
|
int i;
|
||||||
ttype(&o) = LUA_T_USERDATA;
|
ttype(&o) = LUA_T_USERDATA;
|
||||||
clear_global_list(L, limit);
|
clear_global_list(L, limit);
|
||||||
@ -254,7 +254,7 @@ void luaC_collect (lua_State *L, int all) {
|
|||||||
|
|
||||||
|
|
||||||
long lua_collectgarbage (lua_State *L, long limit) {
|
long lua_collectgarbage (lua_State *L, long limit) {
|
||||||
unsigned long recovered = L->nblocks; /* to subtract nblocks after gc */
|
unsigned long recovered = L->nblocks; /* to subtract `nblocks' after gc */
|
||||||
markall(L);
|
markall(L);
|
||||||
luaR_invalidaterefs(L);
|
luaR_invalidaterefs(L);
|
||||||
luaC_collect(L, 0);
|
luaC_collect(L, 0);
|
||||||
|
8
llex.h
8
llex.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: llex.h,v 1.14 1999/08/16 20:52:00 roberto Exp roberto $
|
** $Id: llex.h,v 1.15 1999/11/22 13:12:07 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#define FIRST_RESERVED 260
|
#define FIRST_RESERVED 260
|
||||||
|
|
||||||
/* maximum length of a reserved word (+1 for terminal 0) */
|
/* maximum length of a reserved word (+1 for final 0) */
|
||||||
#define TOKEN_LEN 15
|
#define TOKEN_LEN 15
|
||||||
|
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ enum RESERVED {
|
|||||||
#define MAX_IFS 5 /* arbitrary limit */
|
#define MAX_IFS 5 /* arbitrary limit */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* "ifstate" keeps the state of each nested $if the lexical is dealing with. */
|
/* `ifState' keeps the state of each nested $if the lexical is dealing with. */
|
||||||
|
|
||||||
struct ifState {
|
struct ifState {
|
||||||
int elsepart; /* true if it's in the $else part */
|
int elsepart; /* true if it's in the $else part */
|
||||||
@ -46,7 +46,7 @@ struct ifState {
|
|||||||
typedef struct LexState {
|
typedef struct LexState {
|
||||||
int current; /* look ahead character */
|
int current; /* look ahead character */
|
||||||
int token; /* look ahead token */
|
int token; /* look ahead token */
|
||||||
struct FuncState *fs; /* 'FuncState' is private for the parser */
|
struct FuncState *fs; /* `FuncState' is private for the parser */
|
||||||
struct lua_State *L;
|
struct lua_State *L;
|
||||||
union {
|
union {
|
||||||
real r;
|
real r;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lmathlib.c,v 1.21 1999/11/22 17:39:51 roberto Exp roberto $
|
** $Id: lmathlib.c,v 1.22 1999/12/14 18:31:20 roberto Exp roberto $
|
||||||
** Lua standard mathematical library
|
** Standard mathematical library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ static void math_random (lua_State *L) {
|
|||||||
some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */
|
some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */
|
||||||
double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX;
|
double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX;
|
||||||
if (lua_getparam(L, 1) == LUA_NOOBJECT) /* no arguments? */
|
if (lua_getparam(L, 1) == LUA_NOOBJECT) /* no arguments? */
|
||||||
lua_pushnumber(L, r); /* real between 0 & 1 */
|
lua_pushnumber(L, r); /* real between 0 and 1 */
|
||||||
else {
|
else {
|
||||||
int l, u; /* lower & upper limits */
|
int l, u; /* lower & upper limits */
|
||||||
if (lua_getparam(L, 2) == LUA_NOOBJECT) { /* only one argument? */
|
if (lua_getparam(L, 2) == LUA_NOOBJECT) { /* only one argument? */
|
||||||
@ -159,7 +159,7 @@ static void math_random (lua_State *L) {
|
|||||||
u = luaL_check_int(L, 2);
|
u = luaL_check_int(L, 2);
|
||||||
}
|
}
|
||||||
luaL_arg_check(L, l<=u, 1, "interval is empty");
|
luaL_arg_check(L, l<=u, 1, "interval is empty");
|
||||||
lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between l & u */
|
lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between `l' and `u' */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
lmem.c
4
lmem.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lmem.c,v 1.21 1999/11/29 16:38:48 roberto Exp roberto $
|
** $Id: lmem.c,v 1.22 1999/12/14 18:31:20 roberto Exp roberto $
|
||||||
** Interface to Memory Manager
|
** Interface to Memory Manager
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -49,7 +49,7 @@ void *luaM_realloc (lua_State *L, void *block, unsigned long size) {
|
|||||||
if (s != size)
|
if (s != size)
|
||||||
lua_error(L, "memory allocation error: block too big");
|
lua_error(L, "memory allocation error: block too big");
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
free(block); /* block may be NULL, that is OK for free */
|
free(block); /* block may be NULL; that is OK for free */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
block = realloc(block, s);
|
block = realloc(block, s);
|
||||||
|
4
lmem.h
4
lmem.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lmem.h,v 1.9 1999/08/16 20:52:00 roberto Exp roberto $
|
** $Id: lmem.h,v 1.10 1999/11/22 13:12:07 roberto Exp roberto $
|
||||||
** Interface to Memory Manager
|
** Interface to Memory Manager
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -18,7 +18,7 @@
|
|||||||
#define refEM "reference table overflow"
|
#define refEM "reference table overflow"
|
||||||
#define tableEM "table overflow"
|
#define tableEM "table overflow"
|
||||||
#define memEM "not enough memory"
|
#define memEM "not enough memory"
|
||||||
#define arrEM "internal array bigger than `int' limit"
|
#define arrEM "internal array larger than `int' limit"
|
||||||
|
|
||||||
void *luaM_realloc (lua_State *L, void *oldblock, unsigned long size);
|
void *luaM_realloc (lua_State *L, void *oldblock, unsigned long size);
|
||||||
void *luaM_growaux (lua_State *L, void *block, unsigned long nelems, int inc, int size,
|
void *luaM_growaux (lua_State *L, void *block, unsigned long nelems, int inc, int size,
|
||||||
|
12
lobject.h
12
lobject.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 1.40 1999/12/14 18:33:29 roberto Exp roberto $
|
** $Id: lobject.h,v 1.41 1999/12/23 18:19:57 roberto Exp roberto $
|
||||||
** Type definitions for Lua objects
|
** Type definitions for Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -46,7 +46,7 @@ typedef unsigned char Byte; /* unsigned 8 bits */
|
|||||||
#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
|
#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
|
||||||
|
|
||||||
|
|
||||||
/* convertion of pointer to int (for hashing only) */
|
/* conversion of pointer to int (for hashing only) */
|
||||||
/* (the shift removes bits that are usually 0 because of alignment) */
|
/* (the shift removes bits that are usually 0 because of alignment) */
|
||||||
#define IntPoint(L, p) (((unsigned int)(p)) >> 3)
|
#define IntPoint(L, p) (((unsigned int)(p)) >> 3)
|
||||||
|
|
||||||
@ -65,10 +65,10 @@ typedef unsigned char Byte; /* unsigned 8 bits */
|
|||||||
** grep "ORDER LUA_T"
|
** grep "ORDER LUA_T"
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LUA_T_USERDATA = 0, /* tag default for userdata */
|
LUA_T_USERDATA = 0, /* default tag for userdata */
|
||||||
LUA_T_NUMBER = -1, /* fixed tag for numbers */
|
LUA_T_NUMBER = -1, /* fixed tag for numbers */
|
||||||
LUA_T_STRING = -2, /* fixed tag for strings */
|
LUA_T_STRING = -2, /* fixed tag for strings */
|
||||||
LUA_T_ARRAY = -3, /* tag default for tables (or arrays) */
|
LUA_T_ARRAY = -3, /* default tag for tables (or arrays) */
|
||||||
LUA_T_LPROTO = -4, /* fixed tag for Lua functions */
|
LUA_T_LPROTO = -4, /* fixed tag for Lua functions */
|
||||||
LUA_T_CPROTO = -5, /* fixed tag for C functions */
|
LUA_T_CPROTO = -5, /* fixed tag for C functions */
|
||||||
LUA_T_NIL = -6, /* last "pre-defined" tag */
|
LUA_T_NIL = -6, /* last "pre-defined" tag */
|
||||||
@ -84,7 +84,7 @@ typedef enum {
|
|||||||
#define NUM_TAGS 7
|
#define NUM_TAGS 7
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** chech whether t is a mark; ttypes are negative numbers, so the
|
** chech whether `t' is a mark; ttypes are negative numbers, so the
|
||||||
** comparisons look reversed. (ORDER LUA_T)
|
** comparisons look reversed. (ORDER LUA_T)
|
||||||
*/
|
*/
|
||||||
#define is_T_MARK(t) (LUA_T_CMARK <= (t) && (t) <= LUA_T_LCLMARK)
|
#define is_T_MARK(t) (LUA_T_CMARK <= (t) && (t) <= LUA_T_LCLMARK)
|
||||||
@ -181,7 +181,7 @@ typedef struct LocVar {
|
|||||||
typedef struct Closure {
|
typedef struct Closure {
|
||||||
struct Closure *next;
|
struct Closure *next;
|
||||||
int marked;
|
int marked;
|
||||||
int nelems; /* not included the first one (always the prototype) */
|
int nelems; /* not including the first one (always the prototype) */
|
||||||
TObject consts[1]; /* at least one for prototype */
|
TObject consts[1]; /* at least one for prototype */
|
||||||
} Closure;
|
} Closure;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lopcodes.h,v 1.33 1999/06/17 17:04:03 roberto Exp roberto $
|
** $Id: lopcodes.h,v 1.34 1999/11/25 18:59:43 roberto Exp roberto $
|
||||||
** Opcodes for Lua virtual machine
|
** Opcodes for Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -121,7 +121,7 @@ LONGARG /* b (add b*(1<<16) to arg of next instruction) */
|
|||||||
#define MAX_ARG ((1<<24)-1)
|
#define MAX_ARG ((1<<24)-1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* maximum value of a word of 2 bytes; cannot be bigger than MAX_ARG */
|
/* maximum value of a word of 2 bytes; cannot be larger than MAX_ARG */
|
||||||
#if MAX_ARG < (1<<16)
|
#if MAX_ARG < (1<<16)
|
||||||
#define MAX_WORD MAX_ARG
|
#define MAX_WORD MAX_ARG
|
||||||
#else
|
#else
|
||||||
|
4
lref.c
4
lref.c
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lref.c,v 1.4 1999/12/14 18:31:20 roberto Exp roberto $
|
** $Id: lref.c,v 1.5 1999/12/23 18:19:57 roberto Exp roberto $
|
||||||
** REF mechanism
|
** reference mechanism
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
4
lref.h
4
lref.h
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lref.h,v 1.3 1999/11/22 13:12:07 roberto Exp roberto $
|
** $Id: lref.h,v 1.4 1999/12/14 18:33:29 roberto Exp roberto $
|
||||||
** REF mechanism
|
** reference mechanism
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
6
lstate.h
6
lstate.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstate.h,v 1.25 1999/12/06 11:41:28 roberto Exp roberto $
|
** $Id: lstate.h,v 1.26 1999/12/21 18:04:41 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,7 @@ typedef TObject *StkId; /* index to stack elements */
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** "jmp_buf" may be an array, so it is better to make sure it has an
|
** `jmp_buf' may be an array, so it is better to make sure it has an
|
||||||
** address (and not that it *is* an address...)
|
** address (and not that it *is* an address...)
|
||||||
*/
|
*/
|
||||||
struct lua_longjmp {
|
struct lua_longjmp {
|
||||||
@ -74,7 +74,7 @@ struct lua_State {
|
|||||||
int refSize; /* size of refArray */
|
int refSize; /* size of refArray */
|
||||||
int refFree; /* list of free positions in refArray */
|
int refFree; /* list of free positions in refArray */
|
||||||
unsigned long GCthreshold;
|
unsigned long GCthreshold;
|
||||||
unsigned long nblocks; /* number of 'blocks' currently allocated */
|
unsigned long nblocks; /* number of `blocks' currently allocated */
|
||||||
int debug;
|
int debug;
|
||||||
lua_CHFunction callhook;
|
lua_CHFunction callhook;
|
||||||
lua_LHFunction linehook;
|
lua_LHFunction linehook;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.37 1999/11/22 13:12:07 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.38 1999/11/22 17:39:51 roberto Exp roberto $
|
||||||
** Standard library for strings and pattern-matching
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
4
ltests.c
4
ltests.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltests.c,v 1.1 1999/12/14 18:31:20 roberto Exp roberto $
|
** $Id: ltests.c,v 1.2 1999/12/23 18:19:57 roberto Exp roberto $
|
||||||
** Internal Module for Debugging of the Lua Implementation
|
** Internal Module for Debugging of the Lua Implementation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -163,7 +163,7 @@ static void testC (lua_State *L) {
|
|||||||
}
|
}
|
||||||
else if EQ("getparam") {
|
else if EQ("getparam") {
|
||||||
int n = getreg(L, &pc);
|
int n = getreg(L, &pc);
|
||||||
reg[n] = lua_getparam(L, getnum(&pc)+1); /* skips the commmand itself */
|
reg[n] = lua_getparam(L, getnum(&pc)+1); /* skips the command itself */
|
||||||
}
|
}
|
||||||
else if EQ("getresult") {
|
else if EQ("getresult") {
|
||||||
int n = getreg(L, &pc);
|
int n = getreg(L, &pc);
|
||||||
|
14
lvm.c
14
lvm.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 1.74 1999/12/21 18:04:41 roberto Exp roberto $
|
** $Id: lvm.c,v 1.75 1999/12/23 18:19:57 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -135,21 +135,21 @@ void luaV_gettable (lua_State *L) {
|
|||||||
*/
|
*/
|
||||||
void luaV_settable (lua_State *L, StkId t) {
|
void luaV_settable (lua_State *L, StkId t) {
|
||||||
const TObject *im;
|
const TObject *im;
|
||||||
if (ttype(t) != LUA_T_ARRAY) { /* not a table, get "settable" method */
|
if (ttype(t) != LUA_T_ARRAY) { /* not a table, get `settable' method */
|
||||||
im = luaT_getimbyObj(L, t, IM_SETTABLE);
|
im = luaT_getimbyObj(L, t, IM_SETTABLE);
|
||||||
if (ttype(im) == LUA_T_NIL)
|
if (ttype(im) == LUA_T_NIL)
|
||||||
lua_error(L, "indexed expression not a table");
|
lua_error(L, "indexed expression not a table");
|
||||||
}
|
}
|
||||||
else { /* object is a table... */
|
else { /* object is a table... */
|
||||||
im = luaT_getim(L, avalue(t)->htag, IM_SETTABLE);
|
im = luaT_getim(L, avalue(t)->htag, IM_SETTABLE);
|
||||||
if (ttype(im) == LUA_T_NIL) { /* and does not have a "settable" method */
|
if (ttype(im) == LUA_T_NIL) { /* and does not have a `settable' method */
|
||||||
luaH_set(L, avalue(t), t+1, L->top-1);
|
luaH_set(L, avalue(t), t+1, L->top-1);
|
||||||
L->top--; /* pop value */
|
L->top--; /* pop value */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* else it has a "settable" method, go through to next command */
|
/* else it has a `settable' method, go through to next command */
|
||||||
}
|
}
|
||||||
/* object is not a table, or it has a "settable" method */
|
/* object is not a table, or it has a `settable' method */
|
||||||
/* prepare arguments and call the tag method */
|
/* prepare arguments and call the tag method */
|
||||||
*(L->top+1) = *(L->top-1);
|
*(L->top+1) = *(L->top-1);
|
||||||
*(L->top) = *(t+1);
|
*(L->top) = *(t+1);
|
||||||
@ -210,7 +210,7 @@ static void call_binTM (lua_State *L, StkId top, IMS event, const char *msg) {
|
|||||||
if (ttype(im) == LUA_T_NIL) {
|
if (ttype(im) == LUA_T_NIL) {
|
||||||
im = luaT_getimbyObj(L, top-1, event); /* try second operand */
|
im = luaT_getimbyObj(L, top-1, event); /* try second operand */
|
||||||
if (ttype(im) == LUA_T_NIL) {
|
if (ttype(im) == LUA_T_NIL) {
|
||||||
im = luaT_getim(L, 0, event); /* try a 'global' i.m. */
|
im = luaT_getim(L, 0, event); /* try a `global' method */
|
||||||
if (ttype(im) == LUA_T_NIL)
|
if (ttype(im) == LUA_T_NIL)
|
||||||
lua_error(L, msg);
|
lua_error(L, msg);
|
||||||
}
|
}
|
||||||
@ -603,7 +603,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
|
|||||||
case LONGARGW: aux += highbyte(L, *pc++);
|
case LONGARGW: aux += highbyte(L, *pc++);
|
||||||
case LONGARG: aux += *pc++;
|
case LONGARG: aux += *pc++;
|
||||||
aux = highbyte(L, highbyte(L, aux));
|
aux = highbyte(L, highbyte(L, aux));
|
||||||
goto switchentry; /* do not reset "aux" */
|
goto switchentry; /* do not reset `aux' */
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user