small modifications (format, small optimizations, etc)
This commit is contained in:
4
lapi.c
4
lapi.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 1.5 1997/11/19 17:29:23 roberto Exp roberto $
|
** $Id: lapi.c,v 1.6 1997/11/19 18:16:33 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -270,7 +270,7 @@ int lua_isfunction (lua_Object o)
|
|||||||
real lua_getnumber (lua_Object object)
|
real lua_getnumber (lua_Object object)
|
||||||
{
|
{
|
||||||
if (object == LUA_NOOBJECT) return 0.0;
|
if (object == LUA_NOOBJECT) return 0.0;
|
||||||
if (tonumber (Address(object))) return 0.0;
|
if (tonumber(Address(object))) return 0.0;
|
||||||
else return (nvalue(Address(object)));
|
else return (nvalue(Address(object)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $
|
** $Id: lauxlib.c,v 1.3 1997/11/04 15:27:53 roberto Exp roberto $
|
||||||
** Auxiliar functions for building Lua libraries
|
** Auxiliar functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void luaL_arg_check(int cond, int numarg, char *extramsg)
|
void luaL_arg_check (int cond, int numarg, char *extramsg)
|
||||||
{
|
{
|
||||||
if (!cond) {
|
if (!cond) {
|
||||||
char *funcname;
|
char *funcname;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
|
** $Id: lauxlib.h,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $
|
||||||
** Auxiliar functions for building Lua libraries
|
** Auxiliar functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -18,7 +18,7 @@ struct luaL_reg {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void luaL_openlib (struct luaL_reg *l, int n);
|
void luaL_openlib (struct luaL_reg *l, int n);
|
||||||
void luaL_arg_check(int cond, int numarg, char *extramsg);
|
void luaL_arg_check (int cond, int numarg, char *extramsg);
|
||||||
char *luaL_check_string (int numArg);
|
char *luaL_check_string (int numArg);
|
||||||
char *luaL_opt_string (int numArg, char *def);
|
char *luaL_opt_string (int numArg, char *def);
|
||||||
double luaL_check_number (int numArg);
|
double luaL_check_number (int numArg);
|
||||||
|
|||||||
4
ldo.c
4
ldo.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.8 1997/11/07 15:09:49 roberto Exp roberto $
|
** $Id: ldo.c,v 1.9 1997/11/19 17:29:23 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
|
||||||
*/
|
*/
|
||||||
@@ -224,7 +224,7 @@ void luaD_travstack (int (*fn)(TObject *))
|
|||||||
{
|
{
|
||||||
StkId i;
|
StkId i;
|
||||||
for (i = (L->stack.top-1)-L->stack.stack; i>=0; i--)
|
for (i = (L->stack.top-1)-L->stack.stack; i>=0; i--)
|
||||||
fn (L->stack.stack+i);
|
fn(L->stack.stack+i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
318
llex.c
318
llex.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 1.6 1997/11/19 17:29:23 roberto Exp roberto $
|
** $Id: llex.c,v 1.7 1997/11/19 17:35:47 roberto Exp roberto $
|
||||||
** Lexical Analizer
|
** Lexical Analizer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
int lua_debug=0;
|
int lua_debug=0;
|
||||||
|
|
||||||
|
|
||||||
#define next(LL) (LL->current = zgetc(LL->lex_z))
|
#define next(LS) (LS->current = zgetc(LS->lex_z))
|
||||||
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@@ -46,29 +46,29 @@ void luaX_init (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void firstline (LexState *LL)
|
static void firstline (LexState *LS)
|
||||||
{
|
{
|
||||||
int c = zgetc(LL->lex_z);
|
int c = zgetc(LS->lex_z);
|
||||||
if (c == '#')
|
if (c == '#')
|
||||||
while((c=zgetc(LL->lex_z)) != '\n' && c != EOZ) /* skip first line */;
|
while ((c=zgetc(LS->lex_z)) != '\n' && c != EOZ) /* skip first line */;
|
||||||
zungetc(LL->lex_z);
|
zungetc(LS->lex_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void luaX_setinput (ZIO *z)
|
void luaX_setinput (ZIO *z)
|
||||||
{
|
{
|
||||||
LexState *LL = L->lexstate;
|
LexState *LS = L->lexstate;
|
||||||
LL->current = '\n';
|
LS->current = '\n';
|
||||||
LL->linelasttoken = 0;
|
LS->linelasttoken = 0;
|
||||||
LL->lastline = 0;
|
LS->lastline = 0;
|
||||||
LL->linenumber = 0;
|
LS->linenumber = 0;
|
||||||
LL->iflevel = 0;
|
LS->iflevel = 0;
|
||||||
LL->ifstate[0].skip = 0;
|
LS->ifstate[0].skip = 0;
|
||||||
LL->ifstate[0].elsepart = 1; /* to avoid a free $else */
|
LS->ifstate[0].elsepart = 1; /* to avoid a free $else */
|
||||||
LL->lex_z = z;
|
LS->lex_z = z;
|
||||||
firstline(LL);
|
firstline(LS);
|
||||||
LL->textbuff.buffsize = 20;
|
LS->textbuff.buffsize = 20;
|
||||||
LL->textbuff.text = luaM_buffer(LL->textbuff.buffsize);
|
LS->textbuff.text = luaM_buffer(LS->textbuff.buffsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -81,10 +81,10 @@ void luaX_setinput (ZIO *z)
|
|||||||
|
|
||||||
#define PRAGMASIZE 20
|
#define PRAGMASIZE 20
|
||||||
|
|
||||||
static void skipspace (LexState *LL)
|
static void skipspace (LexState *LS)
|
||||||
{
|
{
|
||||||
while (LL->current == ' ' || LL->current == '\t' || LL->current == '\r')
|
while (LS->current == ' ' || LS->current == '\t' || LS->current == '\r')
|
||||||
next(LL);
|
next(LS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,49 +102,49 @@ static int checkcond (char *buff)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void readname (LexState *LL, char *buff)
|
static void readname (LexState *LS, char *buff)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
skipspace(LL);
|
skipspace(LS);
|
||||||
while (isalnum(LL->current) || LL->current == '_') {
|
while (isalnum(LS->current) || LS->current == '_') {
|
||||||
if (i >= PRAGMASIZE) {
|
if (i >= PRAGMASIZE) {
|
||||||
buff[PRAGMASIZE] = 0;
|
buff[PRAGMASIZE] = 0;
|
||||||
luaY_syntaxerror("pragma too long", buff);
|
luaY_syntaxerror("pragma too long", buff);
|
||||||
}
|
}
|
||||||
buff[i++] = LL->current;
|
buff[i++] = LS->current;
|
||||||
next(LL);
|
next(LS);
|
||||||
}
|
}
|
||||||
buff[i] = 0;
|
buff[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void inclinenumber (LexState *LL);
|
static void inclinenumber (LexState *LS);
|
||||||
|
|
||||||
|
|
||||||
static void ifskip (LexState *LL)
|
static void ifskip (LexState *LS)
|
||||||
{
|
{
|
||||||
while (LL->ifstate[LL->iflevel].skip) {
|
while (LS->ifstate[LS->iflevel].skip) {
|
||||||
if (LL->current == '\n')
|
if (LS->current == '\n')
|
||||||
inclinenumber(LL);
|
inclinenumber(LS);
|
||||||
else if (LL->current == EOZ)
|
else if (LS->current == EOZ)
|
||||||
luaY_syntaxerror("input ends inside a $if", "");
|
luaY_syntaxerror("input ends inside a $if", "");
|
||||||
else next(LL);
|
else next(LS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void inclinenumber (LexState *LL)
|
static void inclinenumber (LexState *LS)
|
||||||
{
|
{
|
||||||
static char *pragmas [] =
|
static char *pragmas [] =
|
||||||
{"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL};
|
{"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL};
|
||||||
next(LL); /* skip '\n' */
|
next(LS); /* skip '\n' */
|
||||||
++LL->linenumber;
|
++LS->linenumber;
|
||||||
if (LL->current == '$') { /* is a pragma? */
|
if (LS->current == '$') { /* is a pragma? */
|
||||||
char buff[PRAGMASIZE+1];
|
char buff[PRAGMASIZE+1];
|
||||||
int ifnot = 0;
|
int ifnot = 0;
|
||||||
int skip = LL->ifstate[LL->iflevel].skip;
|
int skip = LS->ifstate[LS->iflevel].skip;
|
||||||
next(LL); /* skip $ */
|
next(LS); /* skip $ */
|
||||||
readname(LL, buff);
|
readname(LS, buff);
|
||||||
switch (luaO_findstring(buff, pragmas)) {
|
switch (luaO_findstring(buff, pragmas)) {
|
||||||
case 0: /* debug */
|
case 0: /* debug */
|
||||||
if (!skip) lua_debug = 1;
|
if (!skip) lua_debug = 1;
|
||||||
@@ -154,42 +154,42 @@ static void inclinenumber (LexState *LL)
|
|||||||
break;
|
break;
|
||||||
case 2: /* endinput */
|
case 2: /* endinput */
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
LL->current = EOZ;
|
LS->current = EOZ;
|
||||||
LL->iflevel = 0; /* to allow $endinput inside a $if */
|
LS->iflevel = 0; /* to allow $endinput inside a $if */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: /* end */
|
case 3: /* end */
|
||||||
if (LL->iflevel-- == 0)
|
if (LS->iflevel-- == 0)
|
||||||
luaY_syntaxerror("unmatched $end", "$end");
|
luaY_syntaxerror("unmatched $end", "$end");
|
||||||
break;
|
break;
|
||||||
case 4: /* ifnot */
|
case 4: /* ifnot */
|
||||||
ifnot = 1;
|
ifnot = 1;
|
||||||
/* go through */
|
/* go through */
|
||||||
case 5: /* if */
|
case 5: /* if */
|
||||||
if (LL->iflevel == MAX_IFS-1)
|
if (LS->iflevel == MAX_IFS-1)
|
||||||
luaY_syntaxerror("too many nested `$ifs'", "$if");
|
luaY_syntaxerror("too many nested `$ifs'", "$if");
|
||||||
readname(LL, buff);
|
readname(LS, buff);
|
||||||
LL->iflevel++;
|
LS->iflevel++;
|
||||||
LL->ifstate[LL->iflevel].elsepart = 0;
|
LS->ifstate[LS->iflevel].elsepart = 0;
|
||||||
LL->ifstate[LL->iflevel].condition = checkcond(buff) ? !ifnot : ifnot;
|
LS->ifstate[LS->iflevel].condition = checkcond(buff) ? !ifnot : ifnot;
|
||||||
LL->ifstate[LL->iflevel].skip = skip || !LL->ifstate[LL->iflevel].condition;
|
LS->ifstate[LS->iflevel].skip = skip || !LS->ifstate[LS->iflevel].condition;
|
||||||
break;
|
break;
|
||||||
case 6: /* else */
|
case 6: /* else */
|
||||||
if (LL->ifstate[LL->iflevel].elsepart)
|
if (LS->ifstate[LS->iflevel].elsepart)
|
||||||
luaY_syntaxerror("unmatched $else", "$else");
|
luaY_syntaxerror("unmatched $else", "$else");
|
||||||
LL->ifstate[LL->iflevel].elsepart = 1;
|
LS->ifstate[LS->iflevel].elsepart = 1;
|
||||||
LL->ifstate[LL->iflevel].skip = LL->ifstate[LL->iflevel-1].skip ||
|
LS->ifstate[LS->iflevel].skip = LS->ifstate[LS->iflevel-1].skip ||
|
||||||
LL->ifstate[LL->iflevel].condition;
|
LS->ifstate[LS->iflevel].condition;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
luaY_syntaxerror("invalid pragma", buff);
|
luaY_syntaxerror("invalid pragma", buff);
|
||||||
}
|
}
|
||||||
skipspace(LL);
|
skipspace(LS);
|
||||||
if (LL->current == '\n') /* pragma must end with a '\n' ... */
|
if (LS->current == '\n') /* pragma must end with a '\n' ... */
|
||||||
inclinenumber(LL);
|
inclinenumber(LS);
|
||||||
else if (LL->current != EOZ) /* or eof */
|
else if (LS->current != EOZ) /* or eof */
|
||||||
luaY_syntaxerror("invalid pragma format", buff);
|
luaY_syntaxerror("invalid pragma format", buff);
|
||||||
ifskip(LL);
|
ifskip(LS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,11 +202,11 @@ static void inclinenumber (LexState *LL)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void save (LexState *LL, int c)
|
static void save (LexState *LS, int c)
|
||||||
{
|
{
|
||||||
if (LL->textbuff.tokensize >= LL->textbuff.buffsize)
|
if (LS->textbuff.tokensize >= LS->textbuff.buffsize)
|
||||||
LL->textbuff.text = luaM_buffer(LL->textbuff.buffsize *= 2);
|
LS->textbuff.text = luaM_buffer(LS->textbuff.buffsize *= 2);
|
||||||
LL->textbuff.text[LL->textbuff.tokensize++] = c;
|
LS->textbuff.text[LS->textbuff.tokensize++] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,44 +217,44 @@ char *luaX_lasttoken (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define save_and_next(LL) (save(LL, LL->current), next(LL))
|
#define save_and_next(LS) (save(LS, LS->current), next(LS))
|
||||||
|
|
||||||
|
|
||||||
static int read_long_string (LexState *LL, YYSTYPE *l)
|
static int read_long_string (LexState *LS, YYSTYPE *l)
|
||||||
{
|
{
|
||||||
int cont = 0;
|
int cont = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (LL->current) {
|
switch (LS->current) {
|
||||||
case EOZ:
|
case EOZ:
|
||||||
save(LL, 0);
|
save(LS, 0);
|
||||||
return WRONGTOKEN;
|
return WRONGTOKEN;
|
||||||
case '[':
|
case '[':
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current == '[') {
|
if (LS->current == '[') {
|
||||||
cont++;
|
cont++;
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case ']':
|
case ']':
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current == ']') {
|
if (LS->current == ']') {
|
||||||
if (cont == 0) goto endloop;
|
if (cont == 0) goto endloop;
|
||||||
cont--;
|
cont--;
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case '\n':
|
case '\n':
|
||||||
save(LL, '\n');
|
save(LS, '\n');
|
||||||
inclinenumber(LL);
|
inclinenumber(LS);
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
}
|
}
|
||||||
} endloop:
|
} endloop:
|
||||||
save_and_next(LL); /* pass the second ']' */
|
save_and_next(LS); /* pass the second ']' */
|
||||||
LL->textbuff.text[LL->textbuff.tokensize-2] = 0; /* erases ']]' */
|
LS->textbuff.text[LS->textbuff.tokensize-2] = 0; /* erases ']]' */
|
||||||
l->pTStr = luaS_new(LL->textbuff.text+2);
|
l->pTStr = luaS_new(LS->textbuff.text+2);
|
||||||
LL->textbuff.text[LL->textbuff.tokensize-2] = ']'; /* restores ']]' */
|
LS->textbuff.text[LS->textbuff.tokensize-2] = ']'; /* restores ']]' */
|
||||||
return STRING;
|
return STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,103 +266,103 @@ static int read_long_string (LexState *LL, YYSTYPE *l)
|
|||||||
int luaY_lex (YYSTYPE *l);
|
int luaY_lex (YYSTYPE *l);
|
||||||
int luaY_lex (YYSTYPE *l)
|
int luaY_lex (YYSTYPE *l)
|
||||||
{
|
{
|
||||||
LexState *LL = L->lexstate;
|
LexState *LS = L->lexstate;
|
||||||
double a;
|
double a;
|
||||||
LL->textbuff.tokensize = 0;
|
LS->textbuff.tokensize = 0;
|
||||||
if (lua_debug)
|
if (lua_debug)
|
||||||
luaY_codedebugline(LL->linelasttoken);
|
luaY_codedebugline(LS->linelasttoken);
|
||||||
LL->linelasttoken = LL->linenumber;
|
LS->linelasttoken = LS->linenumber;
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (LL->current) {
|
switch (LS->current) {
|
||||||
case '\n':
|
case '\n':
|
||||||
inclinenumber(LL);
|
inclinenumber(LS);
|
||||||
LL->linelasttoken = LL->linenumber;
|
LS->linelasttoken = LS->linenumber;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case ' ': case '\t': case '\r': /* CR: to avoid problems with DOS */
|
case ' ': case '\t': case '\r': /* CR: to avoid problems with DOS */
|
||||||
next(LL);
|
next(LS);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current != '-') return '-';
|
if (LS->current != '-') return '-';
|
||||||
do { next(LL); } while (LL->current != '\n' && LL->current != EOZ);
|
do { next(LS); } while (LS->current != '\n' && LS->current != EOZ);
|
||||||
LL->textbuff.tokensize = 0;
|
LS->textbuff.tokensize = 0;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case '[':
|
case '[':
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current != '[') return '[';
|
if (LS->current != '[') return '[';
|
||||||
else {
|
else {
|
||||||
save_and_next(LL); /* pass the second '[' */
|
save_and_next(LS); /* pass the second '[' */
|
||||||
return read_long_string(LL, l);
|
return read_long_string(LS, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
case '=':
|
case '=':
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current != '=') return '=';
|
if (LS->current != '=') return '=';
|
||||||
else { save_and_next(LL); return EQ; }
|
else { save_and_next(LS); return EQ; }
|
||||||
|
|
||||||
case '<':
|
case '<':
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current != '=') return '<';
|
if (LS->current != '=') return '<';
|
||||||
else { save_and_next(LL); return LE; }
|
else { save_and_next(LS); return LE; }
|
||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current != '=') return '>';
|
if (LS->current != '=') return '>';
|
||||||
else { save_and_next(LL); return GE; }
|
else { save_and_next(LS); return GE; }
|
||||||
|
|
||||||
case '~':
|
case '~':
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current != '=') return '~';
|
if (LS->current != '=') return '~';
|
||||||
else { save_and_next(LL); return NE; }
|
else { save_and_next(LS); return NE; }
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
case '\'': {
|
case '\'': {
|
||||||
int del = LL->current;
|
int del = LS->current;
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
while (LL->current != del) {
|
while (LS->current != del) {
|
||||||
switch (LL->current) {
|
switch (LS->current) {
|
||||||
case EOZ:
|
case EOZ:
|
||||||
case '\n':
|
case '\n':
|
||||||
save(LL, 0);
|
save(LS, 0);
|
||||||
return WRONGTOKEN;
|
return WRONGTOKEN;
|
||||||
case '\\':
|
case '\\':
|
||||||
next(LL); /* do not save the '\' */
|
next(LS); /* do not save the '\' */
|
||||||
switch (LL->current) {
|
switch (LS->current) {
|
||||||
case 'n': save(LL, '\n'); next(LL); break;
|
case 'n': save(LS, '\n'); next(LS); break;
|
||||||
case 't': save(LL, '\t'); next(LL); break;
|
case 't': save(LS, '\t'); next(LS); break;
|
||||||
case 'r': save(LL, '\r'); next(LL); break;
|
case 'r': save(LS, '\r'); next(LS); break;
|
||||||
case '\n': save(LL, '\n'); inclinenumber(LL); break;
|
case '\n': save(LS, '\n'); inclinenumber(LS); break;
|
||||||
default : save_and_next(LL); break;
|
default : save_and_next(LS); break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next(LL); /* skip delimiter */
|
next(LS); /* skip delimiter */
|
||||||
save(LL, 0);
|
save(LS, 0);
|
||||||
l->pTStr = luaS_new(LL->textbuff.text+1);
|
l->pTStr = luaS_new(LS->textbuff.text+1);
|
||||||
LL->textbuff.text[LL->textbuff.tokensize-1] = del; /* restore delimiter */
|
LS->textbuff.text[LS->textbuff.tokensize-1] = del; /* restore delimiter */
|
||||||
return STRING;
|
return STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '.':
|
case '.':
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current == '.')
|
if (LS->current == '.')
|
||||||
{
|
{
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current == '.')
|
if (LS->current == '.')
|
||||||
{
|
{
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
return DOTS; /* ... */
|
return DOTS; /* ... */
|
||||||
}
|
}
|
||||||
else return CONC; /* .. */
|
else return CONC; /* .. */
|
||||||
}
|
}
|
||||||
else if (!isdigit(LL->current)) return '.';
|
else if (!isdigit(LS->current)) return '.';
|
||||||
/* LL->current is a digit: goes through to number */
|
/* LS->current is a digit: goes through to number */
|
||||||
a=0.0;
|
a=0.0;
|
||||||
goto fraction;
|
goto fraction;
|
||||||
|
|
||||||
@@ -370,38 +370,38 @@ int luaY_lex (YYSTYPE *l)
|
|||||||
case '5': case '6': case '7': case '8': case '9':
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
a=0.0;
|
a=0.0;
|
||||||
do {
|
do {
|
||||||
a=10.0*a+(LL->current-'0');
|
a=10.0*a+(LS->current-'0');
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
} while (isdigit(LL->current));
|
} while (isdigit(LS->current));
|
||||||
if (LL->current == '.') {
|
if (LS->current == '.') {
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
if (LL->current == '.') {
|
if (LS->current == '.') {
|
||||||
save(LL, 0);
|
save(LS, 0);
|
||||||
luaY_error(
|
luaY_error(
|
||||||
"ambiguous syntax (decimal point x string concatenation)");
|
"ambiguous syntax (decimal point x string concatenation)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fraction:
|
fraction:
|
||||||
{ double da=0.1;
|
{ double da=0.1;
|
||||||
while (isdigit(LL->current))
|
while (isdigit(LS->current))
|
||||||
{
|
{
|
||||||
a+=(LL->current-'0')*da;
|
a+=(LS->current-'0')*da;
|
||||||
da/=10.0;
|
da/=10.0;
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
}
|
}
|
||||||
if (toupper(LL->current) == 'E') {
|
if (toupper(LS->current) == 'E') {
|
||||||
int e=0;
|
int e=0;
|
||||||
int neg;
|
int neg;
|
||||||
double ea;
|
double ea;
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
neg=(LL->current=='-');
|
neg=(LS->current=='-');
|
||||||
if (LL->current == '+' || LL->current == '-') save_and_next(LL);
|
if (LS->current == '+' || LS->current == '-') save_and_next(LS);
|
||||||
if (!isdigit(LL->current)) {
|
if (!isdigit(LS->current)) {
|
||||||
save(LL, 0); return WRONGTOKEN; }
|
save(LS, 0); return WRONGTOKEN; }
|
||||||
do {
|
do {
|
||||||
e=10.0*e+(LL->current-'0');
|
e=10.0*e+(LS->current-'0');
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
} while (isdigit(LL->current));
|
} while (isdigit(LS->current));
|
||||||
for (ea=neg?0.1:10.0; e>0; e>>=1)
|
for (ea=neg?0.1:10.0; e>0; e>>=1)
|
||||||
{
|
{
|
||||||
if (e & 1) a*=ea;
|
if (e & 1) a*=ea;
|
||||||
@@ -413,23 +413,23 @@ int luaY_lex (YYSTYPE *l)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case EOZ:
|
case EOZ:
|
||||||
save(LL, 0);
|
save(LS, 0);
|
||||||
if (LL->iflevel > 0)
|
if (LS->iflevel > 0)
|
||||||
luaY_error("missing $endif");
|
luaY_error("missing $endif");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (LL->current != '_' && !isalpha(LL->current)) {
|
if (LS->current != '_' && !isalpha(LS->current)) {
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
return LL->textbuff.text[0];
|
return LS->textbuff.text[0];
|
||||||
}
|
}
|
||||||
else { /* identifier or reserved word */
|
else { /* identifier or reserved word */
|
||||||
TaggedString *ts;
|
TaggedString *ts;
|
||||||
do {
|
do {
|
||||||
save_and_next(LL);
|
save_and_next(LS);
|
||||||
} while (isalnum(LL->current) || LL->current == '_');
|
} while (isalnum(LS->current) || LS->current == '_');
|
||||||
save(LL, 0);
|
save(LS, 0);
|
||||||
ts = luaS_new(LL->textbuff.text);
|
ts = luaS_new(LS->textbuff.text);
|
||||||
if (ts->head.marked > 255)
|
if (ts->head.marked > 255)
|
||||||
return ts->head.marked; /* reserved word */
|
return ts->head.marked; /* reserved word */
|
||||||
l->pTStr = ts;
|
l->pTStr = ts;
|
||||||
|
|||||||
12
lstate.h
12
lstate.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: $
|
** $Id: lstate.h,v 1.1 1997/11/19 17:30:36 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -18,9 +18,9 @@
|
|||||||
typedef int StkId; /* index to stack elements */
|
typedef int StkId; /* index to stack elements */
|
||||||
|
|
||||||
struct Stack {
|
struct Stack {
|
||||||
TObject *last;
|
|
||||||
TObject *stack;
|
|
||||||
TObject *top;
|
TObject *top;
|
||||||
|
TObject *stack;
|
||||||
|
TObject *last;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct C_Lua_Stack {
|
struct C_Lua_Stack {
|
||||||
@@ -45,14 +45,14 @@ struct ref {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct LState {
|
typedef struct LState {
|
||||||
struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
|
|
||||||
int numCblocks; /* number of nested Cblocks */
|
|
||||||
TObject *functofind; /* auxiliar */
|
|
||||||
struct Stack stack; /* Lua stack */
|
struct Stack stack; /* Lua stack */
|
||||||
struct C_Lua_Stack Cstack; /* C2lua struct */
|
struct C_Lua_Stack Cstack; /* C2lua struct */
|
||||||
int stacklimit; /* limit for stack overflow */
|
int stacklimit; /* limit for stack overflow */
|
||||||
void *errorJmp; /* current error recover point */
|
void *errorJmp; /* current error recover point */
|
||||||
TObject errorim; /* error tag method */
|
TObject errorim; /* error tag method */
|
||||||
|
struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
|
||||||
|
int numCblocks; /* number of nested Cblocks */
|
||||||
|
TObject *functofind; /* auxiliar */
|
||||||
GCnode rootproto; /* list of all prototypes */
|
GCnode rootproto; /* list of all prototypes */
|
||||||
GCnode rootcl; /* list of all closures */
|
GCnode rootcl; /* list of all closures */
|
||||||
GCnode roottable; /* list of all tables */
|
GCnode roottable; /* list of all tables */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstring.c,v 1.4 1997/11/04 15:27:53 roberto Exp roberto $
|
** $Id: lstring.c,v 1.5 1997/11/19 17:29:23 roberto Exp roberto $
|
||||||
** String table (keep all strings handled by Lua)
|
** String table (keep all strings handled by Lua)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -74,7 +74,7 @@ static void grow (stringtable *tb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TaggedString *newone(char *buff, int tag, unsigned long h)
|
static TaggedString *newone (char *buff, int tag, unsigned long h)
|
||||||
{
|
{
|
||||||
TaggedString *ts;
|
TaggedString *ts;
|
||||||
if (tag == LUA_T_STRING) {
|
if (tag == LUA_T_STRING) {
|
||||||
|
|||||||
4
ltable.c
4
ltable.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltable.c,v 1.5 1997/10/24 17:17:24 roberto Exp roberto $
|
** $Id: ltable.c,v 1.6 1997/11/19 17:29:23 roberto Exp roberto $
|
||||||
** Lua tables (hash)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -84,7 +84,7 @@ static Node *hashnodecreate (int nhash)
|
|||||||
*/
|
*/
|
||||||
static void hashdelete (Hash *t)
|
static void hashdelete (Hash *t)
|
||||||
{
|
{
|
||||||
luaM_free (nodevector(t));
|
luaM_free(nodevector(t));
|
||||||
luaM_free(t);
|
luaM_free(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
lua.c
4
lua.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lua.c,v 1.3 1997/10/16 18:35:59 roberto Exp roberto $
|
** $Id: lua.c,v 1.4 1997/11/19 17:29:23 roberto Exp roberto $
|
||||||
** Lua stand-alone interpreter
|
** Lua stand-alone interpreter
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -72,7 +72,7 @@ int main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int result = lua_dofile (argv[i]);
|
int result = lua_dofile(argv[i]);
|
||||||
if (result) {
|
if (result) {
|
||||||
if (result == 2) {
|
if (result == 2) {
|
||||||
fprintf(stderr, "lua: cannot execute file ");
|
fprintf(stderr, "lua: cannot execute file ");
|
||||||
|
|||||||
4
lua.stx
4
lua.stx
@@ -1,6 +1,6 @@
|
|||||||
%{
|
%{
|
||||||
/*
|
/*
|
||||||
** $Id: lua.stx,v 1.17 1997/11/07 15:09:49 roberto Exp roberto $
|
** $Id: lua.stx,v 1.18 1997/11/19 17:29:23 roberto Exp roberto $
|
||||||
** Syntax analizer and code generator
|
** Syntax analizer and code generator
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -613,7 +613,7 @@ TProtoFunc *luaY_parser (ZIO *z, char *chunkname)
|
|||||||
L->lexstate = &lexstate;
|
L->lexstate = &lexstate;
|
||||||
luaX_setinput(z);
|
luaX_setinput(z);
|
||||||
init_state(luaS_new(chunkname));
|
init_state(luaS_new(chunkname));
|
||||||
if (luaY_parse ()) lua_error("parse error");
|
if (luaY_parse()) lua_error("parse error");
|
||||||
return close_func();
|
return close_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
210
lvm.c
210
lvm.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 1.13 1997/10/27 16:14:37 roberto Exp roberto $
|
** $Id: lvm.c,v 1.14 1997/11/19 17:29:23 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -79,12 +79,13 @@ int luaV_tostring (TObject *obj)
|
|||||||
|
|
||||||
void luaV_closure (int nelems)
|
void luaV_closure (int nelems)
|
||||||
{
|
{
|
||||||
|
struct Stack *S = &L->stack;
|
||||||
Closure *c = luaF_newclosure(nelems);
|
Closure *c = luaF_newclosure(nelems);
|
||||||
c->consts[0] = *(L->stack.top-1);
|
c->consts[0] = *(S->top-1);
|
||||||
memcpy(&c->consts[1], L->stack.top-(nelems+1), nelems*sizeof(TObject));
|
memcpy(&c->consts[1], S->top-(nelems+1), nelems*sizeof(TObject));
|
||||||
L->stack.top -= nelems;
|
S->top -= nelems;
|
||||||
ttype(L->stack.top-1) = LUA_T_FUNCTION;
|
ttype(S->top-1) = LUA_T_FUNCTION;
|
||||||
(L->stack.top-1)->value.cl = c;
|
(S->top-1)->value.cl = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -94,23 +95,24 @@ void luaV_closure (int nelems)
|
|||||||
*/
|
*/
|
||||||
void luaV_gettable (void)
|
void luaV_gettable (void)
|
||||||
{
|
{
|
||||||
|
struct Stack *S = &L->stack;
|
||||||
TObject *im;
|
TObject *im;
|
||||||
if (ttype(L->stack.top-2) != LUA_T_ARRAY) /* not a table, get "gettable" method */
|
if (ttype(S->top-2) != LUA_T_ARRAY) /* not a table, get "gettable" method */
|
||||||
im = luaT_getimbyObj(L->stack.top-2, IM_GETTABLE);
|
im = luaT_getimbyObj(S->top-2, IM_GETTABLE);
|
||||||
else { /* object is a table... */
|
else { /* object is a table... */
|
||||||
int tg = (L->stack.top-2)->value.a->htag;
|
int tg = (S->top-2)->value.a->htag;
|
||||||
im = luaT_getim(tg, IM_GETTABLE);
|
im = luaT_getim(tg, IM_GETTABLE);
|
||||||
if (ttype(im) == LUA_T_NIL) { /* and does not have a "gettable" method */
|
if (ttype(im) == LUA_T_NIL) { /* and does not have a "gettable" method */
|
||||||
TObject *h = luaH_get(avalue(L->stack.top-2), L->stack.top-1);
|
TObject *h = luaH_get(avalue(S->top-2), S->top-1);
|
||||||
if (h != NULL && ttype(h) != LUA_T_NIL) {
|
if (h != NULL && ttype(h) != LUA_T_NIL) {
|
||||||
--L->stack.top;
|
--S->top;
|
||||||
*(L->stack.top-1) = *h;
|
*(S->top-1) = *h;
|
||||||
}
|
}
|
||||||
else if (ttype(im=luaT_getim(tg, IM_INDEX)) != LUA_T_NIL)
|
else if (ttype(im=luaT_getim(tg, IM_INDEX)) != LUA_T_NIL)
|
||||||
luaD_callTM(im, 2, 1);
|
luaD_callTM(im, 2, 1);
|
||||||
else {
|
else {
|
||||||
--L->stack.top;
|
--S->top;
|
||||||
ttype(L->stack.top-1) = LUA_T_NIL;
|
ttype(S->top-1) = LUA_T_NIL;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -125,26 +127,27 @@ void luaV_gettable (void)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Function to store indexed based on values at the L->stack.top
|
** Function to store indexed based on values at the stack.top
|
||||||
** mode = 0: raw store (without internal methods)
|
** mode = 0: raw store (without internal methods)
|
||||||
** mode = 1: normal store (with internal methods)
|
** mode = 1: normal store (with internal methods)
|
||||||
** mode = 2: "deep L->stack.stack" store (with internal methods)
|
** mode = 2: "deep L->stack.stack" store (with internal methods)
|
||||||
*/
|
*/
|
||||||
void luaV_settable (TObject *t, int mode)
|
void luaV_settable (TObject *t, int mode)
|
||||||
{
|
{
|
||||||
|
struct Stack *S = &L->stack;
|
||||||
TObject *im = (mode == 0) ? NULL : luaT_getimbyObj(t, IM_SETTABLE);
|
TObject *im = (mode == 0) ? NULL : luaT_getimbyObj(t, IM_SETTABLE);
|
||||||
if (ttype(t) == LUA_T_ARRAY && (im == NULL || ttype(im) == LUA_T_NIL)) {
|
if (ttype(t) == LUA_T_ARRAY && (im == NULL || ttype(im) == LUA_T_NIL)) {
|
||||||
TObject *h = luaH_set(avalue(t), t+1);
|
TObject *h = luaH_set(avalue(t), t+1);
|
||||||
*h = *(L->stack.top-1);
|
*h = *(S->top-1);
|
||||||
L->stack.top -= (mode == 2) ? 1 : 3;
|
S->top -= (mode == 2) ? 1 : 3;
|
||||||
}
|
}
|
||||||
else { /* object is not a table, and/or has a specific "settable" method */
|
else { /* object is not a table, and/or has a specific "settable" method */
|
||||||
if (im && ttype(im) != LUA_T_NIL) {
|
if (im && ttype(im) != LUA_T_NIL) {
|
||||||
if (mode == 2) {
|
if (mode == 2) {
|
||||||
*(L->stack.top+1) = *(L->stack.top-1);
|
*(S->top+1) = *(L->stack.top-1);
|
||||||
*(L->stack.top) = *(t+1);
|
*(S->top) = *(t+1);
|
||||||
*(L->stack.top-1) = *t;
|
*(S->top-1) = *t;
|
||||||
L->stack.top += 2; /* WARNING: caller must assure stack space */
|
S->top += 2; /* WARNING: caller must assure stack space */
|
||||||
}
|
}
|
||||||
luaD_callTM(im, 3, 0);
|
luaD_callTM(im, 3, 0);
|
||||||
}
|
}
|
||||||
@@ -163,10 +166,11 @@ void luaV_getglobal (TaggedString *ts)
|
|||||||
*L->stack.top++ = *value;
|
*L->stack.top++ = *value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ttype(L->stack.top) = LUA_T_STRING;
|
struct Stack *S = &L->stack;
|
||||||
tsvalue(L->stack.top) = ts;
|
ttype(S->top) = LUA_T_STRING;
|
||||||
L->stack.top++;
|
tsvalue(S->top) = ts;
|
||||||
*L->stack.top++ = *value;
|
S->top++;
|
||||||
|
*S->top++ = *value;
|
||||||
luaD_callTM(im, 2, 1);
|
luaD_callTM(im, 2, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,11 +184,12 @@ void luaV_setglobal (TaggedString *ts)
|
|||||||
luaS_rawsetglobal(ts, --L->stack.top);
|
luaS_rawsetglobal(ts, --L->stack.top);
|
||||||
else {
|
else {
|
||||||
/* WARNING: caller must assure stack space */
|
/* WARNING: caller must assure stack space */
|
||||||
TObject newvalue = *(L->stack.top-1);
|
struct Stack *S = &L->stack;
|
||||||
ttype(L->stack.top-1) = LUA_T_STRING;
|
TObject newvalue = *(S->top-1);
|
||||||
tsvalue(L->stack.top-1) = ts;
|
ttype(S->top-1) = LUA_T_STRING;
|
||||||
*L->stack.top++ = *oldvalue;
|
tsvalue(S->top-1) = ts;
|
||||||
*L->stack.top++ = newvalue;
|
*S->top++ = *oldvalue;
|
||||||
|
*S->top++ = newvalue;
|
||||||
luaD_callTM(im, 3, 0);
|
luaD_callTM(im, 3, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,8 +220,9 @@ static void call_arith (IMS event)
|
|||||||
static void comparison (lua_Type ttype_less, lua_Type ttype_equal,
|
static void comparison (lua_Type ttype_less, lua_Type ttype_equal,
|
||||||
lua_Type ttype_great, IMS op)
|
lua_Type ttype_great, IMS op)
|
||||||
{
|
{
|
||||||
TObject *l = L->stack.top-2;
|
struct Stack *S = &L->stack;
|
||||||
TObject *r = L->stack.top-1;
|
TObject *l = S->top-2;
|
||||||
|
TObject *r = S->top-1;
|
||||||
int result;
|
int result;
|
||||||
if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER)
|
if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER)
|
||||||
result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1;
|
result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1;
|
||||||
@@ -226,9 +232,9 @@ static void comparison (lua_Type ttype_less, lua_Type ttype_equal,
|
|||||||
call_binTM(op, "unexpected type at comparison");
|
call_binTM(op, "unexpected type at comparison");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
L->stack.top--;
|
S->top--;
|
||||||
nvalue(L->stack.top-1) = 1;
|
nvalue(S->top-1) = 1;
|
||||||
ttype(L->stack.top-1) = (result < 0) ? ttype_less :
|
ttype(S->top-1) = (result < 0) ? ttype_less :
|
||||||
(result == 0) ? ttype_equal : ttype_great;
|
(result == 0) ? ttype_equal : ttype_great;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +281,7 @@ static void adjust_varargs (StkId first_extra_arg)
|
|||||||
*/
|
*/
|
||||||
StkId luaV_execute (Closure *cl, StkId base)
|
StkId luaV_execute (Closure *cl, StkId base)
|
||||||
{
|
{
|
||||||
LState *LL = L; /* to optimize */
|
struct Stack *S = &L->stack; /* to optimize */
|
||||||
Byte *pc = cl->consts[0].value.tf->code;
|
Byte *pc = cl->consts[0].value.tf->code;
|
||||||
TObject *consts = cl->consts[0].value.tf->consts;
|
TObject *consts = cl->consts[0].value.tf->consts;
|
||||||
if (lua_callhook)
|
if (lua_callhook)
|
||||||
@@ -286,13 +292,13 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
switch ((OpCode)(aux = *pc++)) {
|
switch ((OpCode)(aux = *pc++)) {
|
||||||
|
|
||||||
case PUSHNIL0:
|
case PUSHNIL0:
|
||||||
ttype(LL->stack.top++) = LUA_T_NIL;
|
ttype(S->top++) = LUA_T_NIL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUSHNIL:
|
case PUSHNIL:
|
||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
do {
|
do {
|
||||||
ttype(LL->stack.top++) = LUA_T_NIL;
|
ttype(S->top++) = LUA_T_NIL;
|
||||||
} while (aux--);
|
} while (aux--);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -305,9 +311,9 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case PUSHNUMBER0: case PUSHNUMBER1: case PUSHNUMBER2:
|
case PUSHNUMBER0: case PUSHNUMBER1: case PUSHNUMBER2:
|
||||||
aux -= PUSHNUMBER0;
|
aux -= PUSHNUMBER0;
|
||||||
pushnumber:
|
pushnumber:
|
||||||
ttype(LL->stack.top) = LUA_T_NUMBER;
|
ttype(S->top) = LUA_T_NUMBER;
|
||||||
nvalue(LL->stack.top) = aux;
|
nvalue(S->top) = aux;
|
||||||
LL->stack.top++;
|
S->top++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUSHLOCAL:
|
case PUSHLOCAL:
|
||||||
@@ -317,7 +323,7 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case PUSHLOCAL4: case PUSHLOCAL5: case PUSHLOCAL6: case PUSHLOCAL7:
|
case PUSHLOCAL4: case PUSHLOCAL5: case PUSHLOCAL6: case PUSHLOCAL7:
|
||||||
aux -= PUSHLOCAL0;
|
aux -= PUSHLOCAL0;
|
||||||
pushlocal:
|
pushlocal:
|
||||||
*LL->stack.top++ = *((LL->stack.stack+base) + aux);
|
*S->top++ = *((S->stack+base) + aux);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GETGLOBALW:
|
case GETGLOBALW:
|
||||||
@@ -347,7 +353,7 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case GETDOTTED4: case GETDOTTED5: case GETDOTTED6: case GETDOTTED7:
|
case GETDOTTED4: case GETDOTTED5: case GETDOTTED6: case GETDOTTED7:
|
||||||
aux -= GETDOTTED0;
|
aux -= GETDOTTED0;
|
||||||
getdotted:
|
getdotted:
|
||||||
*LL->stack.top++ = consts[aux];
|
*S->top++ = consts[aux];
|
||||||
luaV_gettable();
|
luaV_gettable();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -357,10 +363,10 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case PUSHSELF:
|
case PUSHSELF:
|
||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
pushself: {
|
pushself: {
|
||||||
TObject receiver = *(LL->stack.top-1);
|
TObject receiver = *(S->top-1);
|
||||||
*LL->stack.top++ = consts[aux];
|
*S->top++ = consts[aux];
|
||||||
luaV_gettable();
|
luaV_gettable();
|
||||||
*LL->stack.top++ = receiver;
|
*S->top++ = receiver;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +381,7 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case PUSHCONSTANT6: case PUSHCONSTANT7:
|
case PUSHCONSTANT6: case PUSHCONSTANT7:
|
||||||
aux -= PUSHCONSTANT0;
|
aux -= PUSHCONSTANT0;
|
||||||
pushconstant:
|
pushconstant:
|
||||||
*LL->stack.top++ = consts[aux];
|
*S->top++ = consts[aux];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUSHUPVALUE:
|
case PUSHUPVALUE:
|
||||||
@@ -384,7 +390,7 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case PUSHUPVALUE0: case PUSHUPVALUE1:
|
case PUSHUPVALUE0: case PUSHUPVALUE1:
|
||||||
aux -= PUSHUPVALUE0;
|
aux -= PUSHUPVALUE0;
|
||||||
pushupvalue:
|
pushupvalue:
|
||||||
*LL->stack.top++ = cl->consts[aux+1];
|
*S->top++ = cl->consts[aux+1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SETLOCAL:
|
case SETLOCAL:
|
||||||
@@ -394,7 +400,7 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case SETLOCAL4: case SETLOCAL5: case SETLOCAL6: case SETLOCAL7:
|
case SETLOCAL4: case SETLOCAL5: case SETLOCAL6: case SETLOCAL7:
|
||||||
aux -= SETLOCAL0;
|
aux -= SETLOCAL0;
|
||||||
setlocal:
|
setlocal:
|
||||||
*((LL->stack.stack+base) + aux) = *(--LL->stack.top);
|
*((S->stack+base) + aux) = *(--S->top);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SETGLOBALW:
|
case SETGLOBALW:
|
||||||
@@ -411,11 +417,11 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SETTABLE0:
|
case SETTABLE0:
|
||||||
luaV_settable(LL->stack.top-3, 1);
|
luaV_settable(S->top-3, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SETTABLE:
|
case SETTABLE:
|
||||||
luaV_settable(LL->stack.top-3-(*pc++), 2);
|
luaV_settable(S->top-3-(*pc++), 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SETLISTW:
|
case SETLISTW:
|
||||||
@@ -428,12 +434,12 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
aux = 0;
|
aux = 0;
|
||||||
setlist: {
|
setlist: {
|
||||||
int n = *(pc++);
|
int n = *(pc++);
|
||||||
TObject *arr = LL->stack.top-n-1;
|
TObject *arr = S->top-n-1;
|
||||||
for (; n; n--) {
|
for (; n; n--) {
|
||||||
ttype(LL->stack.top) = LUA_T_NUMBER;
|
ttype(S->top) = LUA_T_NUMBER;
|
||||||
nvalue(LL->stack.top) = n+aux;
|
nvalue(S->top) = n+aux;
|
||||||
*(luaH_set (avalue(arr), LL->stack.top)) = *(LL->stack.top-1);
|
*(luaH_set(avalue(arr), S->top)) = *(S->top-1);
|
||||||
LL->stack.top--;
|
S->top--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -444,10 +450,10 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case SETMAP:
|
case SETMAP:
|
||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
setmap: {
|
setmap: {
|
||||||
TObject *arr = LL->stack.top-(2*aux)-3;
|
TObject *arr = S->top-(2*aux)-3;
|
||||||
do {
|
do {
|
||||||
*(luaH_set (avalue(arr), LL->stack.top-2)) = *(LL->stack.top-1);
|
*(luaH_set(avalue(arr), S->top-2)) = *(S->top-1);
|
||||||
LL->stack.top-=2;
|
S->top-=2;
|
||||||
} while (aux--);
|
} while (aux--);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -458,7 +464,7 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case POP0: case POP1:
|
case POP0: case POP1:
|
||||||
aux -= POP0;
|
aux -= POP0;
|
||||||
pop:
|
pop:
|
||||||
LL->stack.top -= (aux+1);
|
S->top -= (aux+1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARGS:
|
case ARGS:
|
||||||
@@ -480,17 +486,17 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
createarray:
|
createarray:
|
||||||
luaC_checkGC();
|
luaC_checkGC();
|
||||||
avalue(LL->stack.top) = luaH_new(aux);
|
avalue(S->top) = luaH_new(aux);
|
||||||
ttype(LL->stack.top) = LUA_T_ARRAY;
|
ttype(S->top) = LUA_T_ARRAY;
|
||||||
LL->stack.top++;
|
S->top++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EQOP: case NEQOP: {
|
case EQOP: case NEQOP: {
|
||||||
int res = luaO_equalObj(LL->stack.top-2, LL->stack.top-1);
|
int res = luaO_equalObj(S->top-2, S->top-1);
|
||||||
LL->stack.top--;
|
S->top--;
|
||||||
if (aux == NEQOP) res = !res;
|
if (aux == NEQOP) res = !res;
|
||||||
ttype(LL->stack.top-1) = res ? LUA_T_NUMBER : LUA_T_NIL;
|
ttype(S->top-1) = res ? LUA_T_NUMBER : LUA_T_NIL;
|
||||||
nvalue(LL->stack.top-1) = 1;
|
nvalue(S->top-1) = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,49 +517,49 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ADDOP: {
|
case ADDOP: {
|
||||||
TObject *l = LL->stack.top-2;
|
TObject *l = S->top-2;
|
||||||
TObject *r = LL->stack.top-1;
|
TObject *r = S->top-1;
|
||||||
if (tonumber(r) || tonumber(l))
|
if (tonumber(r) || tonumber(l))
|
||||||
call_arith(IM_ADD);
|
call_arith(IM_ADD);
|
||||||
else {
|
else {
|
||||||
nvalue(l) += nvalue(r);
|
nvalue(l) += nvalue(r);
|
||||||
--LL->stack.top;
|
--S->top;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SUBOP: {
|
case SUBOP: {
|
||||||
TObject *l = LL->stack.top-2;
|
TObject *l = S->top-2;
|
||||||
TObject *r = LL->stack.top-1;
|
TObject *r = S->top-1;
|
||||||
if (tonumber(r) || tonumber(l))
|
if (tonumber(r) || tonumber(l))
|
||||||
call_arith(IM_SUB);
|
call_arith(IM_SUB);
|
||||||
else {
|
else {
|
||||||
nvalue(l) -= nvalue(r);
|
nvalue(l) -= nvalue(r);
|
||||||
--LL->stack.top;
|
--S->top;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MULTOP: {
|
case MULTOP: {
|
||||||
TObject *l = LL->stack.top-2;
|
TObject *l = S->top-2;
|
||||||
TObject *r = LL->stack.top-1;
|
TObject *r = S->top-1;
|
||||||
if (tonumber(r) || tonumber(l))
|
if (tonumber(r) || tonumber(l))
|
||||||
call_arith(IM_MUL);
|
call_arith(IM_MUL);
|
||||||
else {
|
else {
|
||||||
nvalue(l) *= nvalue(r);
|
nvalue(l) *= nvalue(r);
|
||||||
--LL->stack.top;
|
--S->top;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DIVOP: {
|
case DIVOP: {
|
||||||
TObject *l = LL->stack.top-2;
|
TObject *l = S->top-2;
|
||||||
TObject *r = LL->stack.top-1;
|
TObject *r = S->top-1;
|
||||||
if (tonumber(r) || tonumber(l))
|
if (tonumber(r) || tonumber(l))
|
||||||
call_arith(IM_DIV);
|
call_arith(IM_DIV);
|
||||||
else {
|
else {
|
||||||
nvalue(l) /= nvalue(r);
|
nvalue(l) /= nvalue(r);
|
||||||
--LL->stack.top;
|
--S->top;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -563,32 +569,32 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CONCOP: {
|
case CONCOP: {
|
||||||
TObject *l = LL->stack.top-2;
|
TObject *l = S->top-2;
|
||||||
TObject *r = LL->stack.top-1;
|
TObject *r = S->top-1;
|
||||||
if (tostring(l) || tostring(r))
|
if (tostring(l) || tostring(r))
|
||||||
call_binTM(IM_CONCAT, "unexpected type for concatenation");
|
call_binTM(IM_CONCAT, "unexpected type for concatenation");
|
||||||
else {
|
else {
|
||||||
tsvalue(l) = strconc(svalue(l), svalue(r));
|
tsvalue(l) = strconc(svalue(l), svalue(r));
|
||||||
--LL->stack.top;
|
--S->top;
|
||||||
}
|
}
|
||||||
luaC_checkGC();
|
luaC_checkGC();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MINUSOP:
|
case MINUSOP:
|
||||||
if (tonumber(LL->stack.top-1)) {
|
if (tonumber(S->top-1)) {
|
||||||
ttype(LL->stack.top) = LUA_T_NIL;
|
ttype(S->top) = LUA_T_NIL;
|
||||||
LL->stack.top++;
|
S->top++;
|
||||||
call_arith(IM_UNM);
|
call_arith(IM_UNM);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nvalue(LL->stack.top-1) = - nvalue(LL->stack.top-1);
|
nvalue(S->top-1) = - nvalue(S->top-1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NOTOP:
|
case NOTOP:
|
||||||
ttype(LL->stack.top-1) =
|
ttype(S->top-1) =
|
||||||
(ttype(LL->stack.top-1) == LUA_T_NIL) ? LUA_T_NUMBER : LUA_T_NIL;
|
(ttype(S->top-1) == LUA_T_NIL) ? LUA_T_NUMBER : LUA_T_NIL;
|
||||||
nvalue(LL->stack.top-1) = 1;
|
nvalue(S->top-1) = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ONTJMPW:
|
case ONTJMPW:
|
||||||
@@ -597,8 +603,8 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case ONTJMP:
|
case ONTJMP:
|
||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
ontjmp:
|
ontjmp:
|
||||||
if (ttype(LL->stack.top-1) != LUA_T_NIL) pc += aux;
|
if (ttype(S->top-1) != LUA_T_NIL) pc += aux;
|
||||||
else LL->stack.top--;
|
else S->top--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ONFJMPW:
|
case ONFJMPW:
|
||||||
@@ -607,8 +613,8 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case ONFJMP:
|
case ONFJMP:
|
||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
onfjmp:
|
onfjmp:
|
||||||
if (ttype(LL->stack.top-1) == LUA_T_NIL) pc += aux;
|
if (ttype(S->top-1) == LUA_T_NIL) pc += aux;
|
||||||
else LL->stack.top--;
|
else S->top--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JMPW:
|
case JMPW:
|
||||||
@@ -626,7 +632,7 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case IFFJMP:
|
case IFFJMP:
|
||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
iffjmp:
|
iffjmp:
|
||||||
if (ttype(--LL->stack.top) == LUA_T_NIL) pc += aux;
|
if (ttype(--S->top) == LUA_T_NIL) pc += aux;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IFTUPJMPW:
|
case IFTUPJMPW:
|
||||||
@@ -635,7 +641,7 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case IFTUPJMP:
|
case IFTUPJMP:
|
||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
iftupjmp:
|
iftupjmp:
|
||||||
if (ttype(--LL->stack.top) != LUA_T_NIL) pc -= aux;
|
if (ttype(--S->top) != LUA_T_NIL) pc -= aux;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IFFUPJMPW:
|
case IFFUPJMPW:
|
||||||
@@ -644,7 +650,7 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case IFFUPJMP:
|
case IFFUPJMP:
|
||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
iffupjmp:
|
iffupjmp:
|
||||||
if (ttype(--LL->stack.top) == LUA_T_NIL) pc -= aux;
|
if (ttype(--S->top) == LUA_T_NIL) pc -= aux;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLOSURE:
|
case CLOSURE:
|
||||||
@@ -663,13 +669,13 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case CALLFUNC0: case CALLFUNC1:
|
case CALLFUNC0: case CALLFUNC1:
|
||||||
aux -= CALLFUNC0;
|
aux -= CALLFUNC0;
|
||||||
callfunc: {
|
callfunc: {
|
||||||
StkId newBase = (LL->stack.top-LL->stack.stack)-(*pc++);
|
StkId newBase = (S->top-S->stack)-(*pc++);
|
||||||
luaD_call(newBase, aux);
|
luaD_call(newBase, aux);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ENDCODE:
|
case ENDCODE:
|
||||||
LL->stack.top = LL->stack.stack + base;
|
S->top = S->stack + base;
|
||||||
/* goes through */
|
/* goes through */
|
||||||
case RETCODE:
|
case RETCODE:
|
||||||
if (lua_callhook)
|
if (lua_callhook)
|
||||||
@@ -682,13 +688,13 @@ StkId luaV_execute (Closure *cl, StkId base)
|
|||||||
case SETLINE:
|
case SETLINE:
|
||||||
aux = *pc++;
|
aux = *pc++;
|
||||||
setline:
|
setline:
|
||||||
if ((LL->stack.stack+base-1)->ttype != LUA_T_LINE) {
|
if ((S->stack+base-1)->ttype != LUA_T_LINE) {
|
||||||
/* open space for LINE value */
|
/* open space for LINE value */
|
||||||
luaD_openstack((LL->stack.top-LL->stack.stack)-base);
|
luaD_openstack((S->top-S->stack)-base);
|
||||||
base++;
|
base++;
|
||||||
(LL->stack.stack+base-1)->ttype = LUA_T_LINE;
|
(S->stack+base-1)->ttype = LUA_T_LINE;
|
||||||
}
|
}
|
||||||
(LL->stack.stack+base-1)->value.i = aux;
|
(S->stack+base-1)->value.i = aux;
|
||||||
if (lua_linehook)
|
if (lua_linehook)
|
||||||
luaD_lineHook(aux);
|
luaD_lineHook(aux);
|
||||||
break;
|
break;
|
||||||
|
|||||||
14
lzio.c
14
lzio.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: zio.c,v 1.2 1997/06/20 19:25:54 roberto Exp $
|
** $Id: lzio.c,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
|
||||||
** a generic input stream interface
|
** a generic input stream interface
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -15,12 +15,12 @@
|
|||||||
|
|
||||||
/* ----------------------------------------------------- memory buffers --- */
|
/* ----------------------------------------------------- memory buffers --- */
|
||||||
|
|
||||||
static int zmfilbuf(ZIO* z)
|
static int zmfilbuf (ZIO* z)
|
||||||
{
|
{
|
||||||
return EOZ;
|
return EOZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZIO* zmopen(ZIO* z, char* b, int size)
|
ZIO* zmopen (ZIO* z, char* b, int size)
|
||||||
{
|
{
|
||||||
if (b==NULL) return NULL;
|
if (b==NULL) return NULL;
|
||||||
z->n=size;
|
z->n=size;
|
||||||
@@ -32,7 +32,7 @@ ZIO* zmopen(ZIO* z, char* b, int size)
|
|||||||
|
|
||||||
/* ------------------------------------------------------------ strings --- */
|
/* ------------------------------------------------------------ strings --- */
|
||||||
|
|
||||||
ZIO* zsopen(ZIO* z, char* s)
|
ZIO* zsopen (ZIO* z, char* s)
|
||||||
{
|
{
|
||||||
if (s==NULL) return NULL;
|
if (s==NULL) return NULL;
|
||||||
return zmopen(z,s,strlen(s));
|
return zmopen(z,s,strlen(s));
|
||||||
@@ -40,7 +40,7 @@ ZIO* zsopen(ZIO* z, char* s)
|
|||||||
|
|
||||||
/* -------------------------------------------------------------- FILEs --- */
|
/* -------------------------------------------------------------- FILEs --- */
|
||||||
|
|
||||||
static int zffilbuf(ZIO* z)
|
static int zffilbuf (ZIO* z)
|
||||||
{
|
{
|
||||||
int n=fread(z->buffer,1,ZBSIZE,z->u);
|
int n=fread(z->buffer,1,ZBSIZE,z->u);
|
||||||
if (n==0) return EOZ;
|
if (n==0) return EOZ;
|
||||||
@@ -50,7 +50,7 @@ static int zffilbuf(ZIO* z)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZIO* zFopen(ZIO* z, FILE* f)
|
ZIO* zFopen (ZIO* z, FILE* f)
|
||||||
{
|
{
|
||||||
if (f==NULL) return NULL;
|
if (f==NULL) return NULL;
|
||||||
z->n=0;
|
z->n=0;
|
||||||
@@ -62,7 +62,7 @@ ZIO* zFopen(ZIO* z, FILE* f)
|
|||||||
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------- read --- */
|
/* --------------------------------------------------------------- read --- */
|
||||||
int zread(ZIO *z, void *b, int n)
|
int zread (ZIO *z, void *b, int n)
|
||||||
{
|
{
|
||||||
while (n) {
|
while (n) {
|
||||||
int m;
|
int m;
|
||||||
|
|||||||
10
lzio.h
10
lzio.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: $
|
** $Id: lzio.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
|
||||||
** Buffered streams
|
** Buffered streams
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -22,11 +22,11 @@
|
|||||||
|
|
||||||
typedef struct zio ZIO;
|
typedef struct zio ZIO;
|
||||||
|
|
||||||
ZIO* zFopen(ZIO* z, FILE* f); /* open FILEs */
|
ZIO* zFopen (ZIO* z, FILE* f); /* open FILEs */
|
||||||
ZIO* zsopen(ZIO* z, char* s); /* string */
|
ZIO* zsopen (ZIO* z, char* s); /* string */
|
||||||
ZIO* zmopen(ZIO* z, char* b, int size); /* memory */
|
ZIO* zmopen (ZIO* z, char* b, int size); /* memory */
|
||||||
|
|
||||||
int zread(ZIO* z, void* b, int n); /* read next n bytes */
|
int zread (ZIO* z, void* b, int n); /* read next n bytes */
|
||||||
|
|
||||||
#define zgetc(z) (--(z)->n>=0 ? ((int)*(z)->p++): (z)->filbuf(z))
|
#define zgetc(z) (--(z)->n>=0 ? ((int)*(z)->p++): (z)->filbuf(z))
|
||||||
#define zungetc(z) (++(z)->n,--(z)->p)
|
#define zungetc(z) (++(z)->n,--(z)->p)
|
||||||
|
|||||||
Reference in New Issue
Block a user