details (from lhf)

This commit is contained in:
Roberto Ierusalimschy
1999-02-25 18:07:26 -03:00
parent 31bea2190b
commit 6a853fcb8b
13 changed files with 106 additions and 103 deletions

6
lapi.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 1.37 1999/02/22 19:13:12 roberto Exp roberto $ ** $Id: lapi.c,v 1.38 1999/02/23 14:57:28 roberto Exp roberto $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -477,7 +477,7 @@ int luaA_next (Hash *t, int i) {
int lua_next (lua_Object o, int i) { int lua_next (lua_Object o, int i) {
TObject *t = Address(o); TObject *t = Address(o);
if (ttype(t) != LUA_T_ARRAY) if (ttype(t) != LUA_T_ARRAY)
lua_error("API error: object is not a table in `lua_next'"); lua_error("API error - object is not a table in `lua_next'");
i = luaA_next(avalue(t), i); i = luaA_next(avalue(t), i);
top2LC((i==0) ? 0 : 2); top2LC((i==0) ? 0 : 2);
return i; return i;
@@ -620,7 +620,7 @@ static int checkfunc (TObject *o)
char *lua_getobjname (lua_Object o, char **name) char *lua_getobjname (lua_Object o, char **name)
{ /* try to find a name for given function */ { /* try to find a name for given function */
set_normalized(L->stack.top, Address(o)); /* to be accessed by "checkfunc */ set_normalized(L->stack.top, Address(o)); /* to be accessed by "checkfunc" */
if ((*name = luaT_travtagmethods(checkfunc)) != NULL) if ((*name = luaT_travtagmethods(checkfunc)) != NULL)
return "tag-method"; return "tag-method";
else if ((*name = luaS_travsymbol(checkfunc)) != NULL) else if ((*name = luaS_travsymbol(checkfunc)) != NULL)

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.c,v 1.12 1998/06/19 16:14:09 roberto Exp roberto $ ** $Id: lauxlib.c,v 1.13 1998/09/07 18:59:59 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
*/ */
@@ -10,9 +10,10 @@
#include <string.h> #include <string.h>
/* Please Notice: This file uses only the official API of Lua /* Please Notice: This file uses only the official API of Lua
** Any function declared here could be written as an application ** Any function declared here could be written as an application function.
** function. With care, these functions can be used by other libraries. ** With care, these functions can be used by other libraries.
*/ */
#include "lauxlib.h" #include "lauxlib.h"
#include "lua.h" #include "lua.h"
#include "luadebug.h" #include "luadebug.h"
@@ -33,7 +34,7 @@ void luaL_argerror (int numarg, char *extramsg) {
lua_getobjname(f, &funcname); lua_getobjname(f, &funcname);
numarg -= lua_nups(f); numarg -= lua_nups(f);
if (funcname == NULL) if (funcname == NULL)
funcname = "???"; funcname = "(unknown)";
if (extramsg == NULL) if (extramsg == NULL)
luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname); luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname);
else else

4
llex.c
View File

@@ -1,6 +1,6 @@
/* /*
** $Id: llex.c,v 1.28 1999/02/04 17:47:59 roberto Exp roberto $ ** $Id: llex.c,v 1.29 1999/02/25 15:17:01 roberto Exp roberto $
** Lexical Analizer ** Lexical Analyzer
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */

6
llex.h
View File

@@ -1,6 +1,6 @@
/* /*
** $Id: llex.h,v 1.9 1998/06/19 16:14:09 roberto Exp roberto $ ** $Id: llex.h,v 1.10 1998/07/24 18:02:38 roberto Exp roberto $
** Lexical Analizer ** Lexical Analyzer
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -30,7 +30,7 @@ enum RESERVED {
/* "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 its in the $else part */ int elsepart; /* true if it's in the $else part */
int condition; /* true if $if condition is true */ int condition; /* true if $if condition is true */
int skip; /* true if part must be skipped */ int skip; /* true if part must be skipped */
}; };

6
lmem.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lmem.c,v 1.10 1999/02/24 17:55:51 roberto Exp roberto $ ** $Id: lmem.c,v 1.11 1999/02/25 15:16:26 roberto Exp roberto $
** Interface to Memory Manager ** Interface to Memory Manager
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -59,7 +59,7 @@ void *luaM_growaux (void *block, unsigned long nelems, int inc, int size,
void *luaM_realloc (void *block, unsigned long size) { void *luaM_realloc (void *block, unsigned long size) {
size_t s = (size_t)size; size_t s = (size_t)size;
if (s != size) if (s != size)
lua_error("Allocation Error: Block too big"); lua_error("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;
@@ -100,7 +100,7 @@ static void *checkblock (void *block) {
void *luaM_realloc (void *block, unsigned long size) { void *luaM_realloc (void *block, unsigned long size) {
unsigned long realsize = HEADER+size+1; unsigned long realsize = HEADER+size+1;
if (realsize != (size_t)realsize) if (realsize != (size_t)realsize)
lua_error("Allocation Error: Block too big"); lua_error("memory allocation error: block too big");
if (size == 0) { if (size == 0) {
if (block) { if (block) {
unsigned long *b = (unsigned long *)((char *)block - HEADER); unsigned long *b = (unsigned long *)((char *)block - HEADER);

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lopcodes.h,v 1.26 1999/02/23 13:38:38 roberto Exp roberto $ ** $Id: lopcodes.h,v 1.27 1999/02/24 17:55:51 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
*/ */
@@ -17,97 +17,97 @@
typedef enum { typedef enum {
/* name parm before after side effect /* name parm before after side effect
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
ENDCODE,/* - - - */ ENDCODE,/* - - - */
RETCODE,/* b - - */ RETCODE,/* b - - */
PUSHNIL,/* b - nil_0...nil_b */ PUSHNIL,/* b - nil_0...nil_b */
POP,/* b - - TOP-=b */ POP,/* b - - TOP-=b */
POPDUP,/* b v v TOP-=b */ POPDUP,/* b v v TOP-=b */
PUSHNUMBERW,/* w - (float)w */ PUSHNUMBERW,/* w - (float)w */
PUSHNUMBER,/* b - (float)b */ PUSHNUMBER,/* b - (float)b */
PUSHNUMBERNEGW,/* w - (float)-w */ PUSHNUMBERNEGW,/* w - (float)-w */
PUSHNUMBERNEG,/* b - (float)-b */ PUSHNUMBERNEG,/* b - (float)-b */
PUSHCONSTANTW,/*w - CNST[w] */ PUSHCONSTANTW,/*w - CNST[w] */
PUSHCONSTANT,/* b - CNST[b] */ PUSHCONSTANT,/* b - CNST[b] */
PUSHUPVALUE,/* b - Closure[b] */ PUSHUPVALUE,/* b - Closure[b] */
PUSHLOCAL,/* b - LOC[b] */ PUSHLOCAL,/* b - LOC[b] */
GETGLOBALW,/* w - VAR[CNST[w]] */ GETGLOBALW,/* w - VAR[CNST[w]] */
GETGLOBAL,/* b - VAR[CNST[b]] */ GETGLOBAL,/* b - VAR[CNST[b]] */
GETTABLE,/* - i t t[i] */ GETTABLE,/* - i t t[i] */
GETDOTTEDW,/* w t t[CNST[w]] */ GETDOTTEDW,/* w t t[CNST[w]] */
GETDOTTED,/* b t t[CNST[b]] */ GETDOTTED,/* b t t[CNST[b]] */
PUSHSELFW,/* w t t t[CNST[w]] */ PUSHSELFW,/* w t t t[CNST[w]] */
PUSHSELF,/* b t t t[CNST[b]] */ PUSHSELF,/* b t t t[CNST[b]] */
CREATEARRAYW,/* w - newarray(size = w) */ CREATEARRAYW,/* w - newarray(size = w) */
CREATEARRAY,/* b - newarray(size = b) */ CREATEARRAY,/* b - newarray(size = b) */
SETLOCAL,/* b x - LOC[b]=x */ SETLOCAL,/* b x - LOC[b]=x */
SETLOCALDUP,/* b x x LOC[b]=x */ SETLOCALDUP,/* b x x LOC[b]=x */
SETGLOBALW,/* w x - VAR[CNST[w]]=x */ SETGLOBALW,/* w x - VAR[CNST[w]]=x */
SETGLOBAL,/* b x - VAR[CNST[b]]=x */ SETGLOBAL,/* b x - VAR[CNST[b]]=x */
SETGLOBALDUPW,/*w x x VAR[CNST[w]]=x */ SETGLOBALDUPW,/*w x x VAR[CNST[w]]=x */
SETGLOBALDUP,/* b x x VAR[CNST[b]]=x */ SETGLOBALDUP,/* b x x VAR[CNST[b]]=x */
SETTABLEPOP,/* - v i t - t[i]=v */ SETTABLEPOP,/* - v i t - t[i]=v */
SETTABLEPOPDUP,/* - v i t v t[i]=v */ SETTABLEPOPDUP,/* - v i t v t[i]=v */
SETTABLE,/* b v a_b...a_1 i t a_b...a_1 i t t[i]=v */ SETTABLE,/* b v a_b...a_1 i t a_b...a_1 i t t[i]=v */
SETTABLEDUP,/* b v a_b...a_1 i t v a_b...a_1 i t t[i]=v */ SETTABLEDUP,/* b v a_b...a_1 i t v a_b...a_1 i t t[i]=v */
SETLISTW,/* w c v_c...v_1 t - t[i+w*FPF]=v_i */ SETLISTW,/* w c v_c...v_1 t - t[i+w*FPF]=v_i */
SETLIST,/* b c v_c...v_1 t - t[i+b*FPF]=v_i */ SETLIST,/* b c v_c...v_1 t - t[i+b*FPF]=v_i */
SETMAP,/* b v_b k_b ...v_0 k_0 t t t[k_i]=v_i */ SETMAP,/* b v_b k_b ...v_0 k_0 t t t[k_i]=v_i */
NEQOP,/* - y x (x~=y)? 1 : nil */ NEQOP,/* - y x (x~=y)? 1 : nil */
EQOP,/* - y x (x==y)? 1 : nil */ EQOP,/* - y x (x==y)? 1 : nil */
LTOP,/* - y x (x<y)? 1 : nil */ LTOP,/* - y x (x<y)? 1 : nil */
LEOP,/* - y x (x<y)? 1 : nil */ LEOP,/* - y x (x<y)? 1 : nil */
GTOP,/* - y x (x>y)? 1 : nil */ GTOP,/* - y x (x>y)? 1 : nil */
GEOP,/* - y x (x>=y)? 1 : nil */ GEOP,/* - y x (x>=y)? 1 : nil */
ADDOP,/* - y x x+y */ ADDOP,/* - y x x+y */
SUBOP,/* - y x x-y */ SUBOP,/* - y x x-y */
MULTOP,/* - y x x*y */ MULTOP,/* - y x x*y */
DIVOP,/* - y x x/y */ DIVOP,/* - y x x/y */
POWOP,/* - y x x^y */ POWOP,/* - y x x^y */
CONCOP,/* - y x x..y */ CONCOP,/* - y x x..y */
MINUSOP,/* - x -x */ MINUSOP,/* - x -x */
NOTOP,/* - x (x==nil)? 1 : nil */ NOTOP,/* - x (x==nil)? 1 : nil */
ONTJMPW,/* w x (x!=nil)? x : - (x!=nil)? PC+=w */ ONTJMPW,/* w x (x!=nil)? x : - (x!=nil)? PC+=w */
ONTJMP,/* b x (x!=nil)? x : - (x!=nil)? PC+=b */ ONTJMP,/* b x (x!=nil)? x : - (x!=nil)? PC+=b */
ONFJMPW,/* w x (x==nil)? x : - (x==nil)? PC+=w */ ONFJMPW,/* w x (x==nil)? x : - (x==nil)? PC+=w */
ONFJMP,/* b x (x==nil)? x : - (x==nil)? PC+=b */ ONFJMP,/* b x (x==nil)? x : - (x==nil)? PC+=b */
JMPW,/* w - - PC+=w */ JMPW,/* w - - PC+=w */
JMP,/* b - - PC+=b */ JMP,/* b - - PC+=b */
IFFJMPW,/* w x - (x==nil)? PC+=w */ IFFJMPW,/* w x - (x==nil)? PC+=w */
IFFJMP,/* b x - (x==nil)? PC+=b */ IFFJMP,/* b x - (x==nil)? PC+=b */
IFTUPJMPW,/* w x - (x!=nil)? PC-=w */ IFTUPJMPW,/* w x - (x!=nil)? PC-=w */
IFTUPJMP,/* b x - (x!=nil)? PC-=b */ IFTUPJMP,/* b x - (x!=nil)? PC-=b */
IFFUPJMPW,/* w x - (x==nil)? PC-=w */ IFFUPJMPW,/* w x - (x==nil)? PC-=w */
IFFUPJMP,/* b x - (x==nil)? PC-=b */ IFFUPJMP,/* b x - (x==nil)? PC-=b */
CLOSUREW,/* w c v_c...v_1 closure(CNST[w], v_c...v_1) */ CLOSUREW,/* w c v_c...v_1 closure(CNST[w], v_c...v_1) */
CLOSURE,/* b c v_c...v_1 closure(CNST[b], v_c...v_1) */ CLOSURE,/* b c v_c...v_1 closure(CNST[b], v_c...v_1) */
CALLFUNC,/* b c v_c...v_1 f r_b...r_1 f(v1,...,v_c) */ CALLFUNC,/* b c v_c...v_1 f r_b...r_1 f(v1,...,v_c) */
SETLINEW,/* w - - LINE=w */ SETLINEW,/* w - - LINE=w */
SETLINE,/* b - - LINE=b */ SETLINE,/* b - - LINE=b */
LONGARGW,/* w (add w*(1<<16) to arg of next instruction) */ LONGARGW,/* w (add w*(1<<16) to arg of next instruction) */
LONGARG,/* b (add b*(1<<16) to arg of next instruction) */ LONGARG,/* b (add b*(1<<16) to arg of next instruction) */
CHECKSTACK /* b (assert #temporaries == b; only for internal debuging!) */ CHECKSTACK /* b (assert #temporaries == b; only for internal debuging!) */

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lparser.c,v 1.22 1999/02/24 17:55:51 roberto Exp roberto $ ** $Id: lparser.c,v 1.23 1999/02/25 15:16:26 roberto Exp roberto $
** LL(1) Parser and code generator for Lua ** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -926,7 +926,7 @@ static void exp1 (LexState *ls) {
exp0(ls, &v); exp0(ls, &v);
lua_pushvar(ls, &v); lua_pushvar(ls, &v);
if (is_in(ls->token, expfollow) < 0) if (is_in(ls->token, expfollow) < 0)
luaX_error(ls, "ill formed expression"); luaX_error(ls, "ill-formed expression");
} }

View File

@@ -1,6 +1,6 @@
/* /*
** $Id: lparser.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $ ** $Id: lparser.h,v 1.2 1997/12/22 20:57:18 roberto Exp roberto $
** Syntax analizer and code generator ** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lstrlib.c,v 1.25 1999/02/05 11:22:58 roberto Exp roberto $ ** $Id: lstrlib.c,v 1.26 1999/02/12 19:23:02 roberto Exp roberto $
** Standard library for strings and pattern-matching ** Standard library for strings and pattern-matching
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -532,7 +532,7 @@ static struct luaL_reg strlib[] = {
{"strupper", str_upper}, {"strupper", str_upper},
{"strchar", str_char}, {"strchar", str_char},
{"strrep", str_rep}, {"strrep", str_rep},
{"ascii", str_byte}, /* for compatibility */ {"ascii", str_byte}, /* for compatibility with 3.0 and earlier */
{"strbyte", str_byte}, {"strbyte", str_byte},
{"format", str_format}, {"format", str_format},
{"strfind", str_find}, {"strfind", str_find},

4
ltm.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: ltm.c,v 1.21 1999/02/04 18:59:31 roberto Exp roberto $ ** $Id: ltm.c,v 1.22 1999/02/25 15:16:26 roberto Exp roberto $
** Tag methods ** Tag methods
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -82,7 +82,7 @@ static void checktag (int tag) {
void luaT_realtag (int tag) { void luaT_realtag (int tag) {
if (!(L->last_tag <= tag && tag < LUA_T_NIL)) if (!(L->last_tag <= tag && tag < LUA_T_NIL))
luaL_verror("tag %d is not result of `newtag'", tag); luaL_verror("tag %d was not created by `newtag'", tag);
} }

3
lua.h
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lua.h,v 1.28 1999/02/22 19:13:12 roberto Exp roberto $ ** $Id: lua.h,v 1.29 1999/02/23 14:57:28 roberto Exp roberto $
** Lua - An Extensible Extension Language ** Lua - An Extensible Extension Language
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
** e-mail: lua@tecgraf.puc-rio.br ** e-mail: lua@tecgraf.puc-rio.br
@@ -188,5 +188,6 @@ lua_Object lua_setfallback (char *event, lua_CFunction fallback);
* The Lua language and this implementation have been entirely designed and * The Lua language and this implementation have been entirely designed and
* written by Waldemar Celes Filho, Roberto Ierusalimschy and * written by Waldemar Celes Filho, Roberto Ierusalimschy and
* Luiz Henrique de Figueiredo at TeCGraf, PUC-Rio. * Luiz Henrique de Figueiredo at TeCGraf, PUC-Rio.
*
* This implementation contains no third-party code. * This implementation contains no third-party code.
******************************************************************************/ ******************************************************************************/

11
lzio.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lzio.c,v 1.3 1997/12/22 20:57:18 roberto Exp roberto $ ** $Id: lzio.c,v 1.4 1998/12/28 13:44:54 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
*/ */
@@ -64,16 +64,15 @@ ZIO* zFopen (ZIO* z, FILE* f, char *name)
/* --------------------------------------------------------------- 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;
if (z->n == 0) { if (z->n == 0) {
if (z->filbuf(z) == EOZ) if (z->filbuf(z) == EOZ)
return n; /* retorna quantos faltaram ler */ return n; /* return number of missing bytes */
zungetc(z); /* poe o resultado de filbuf no buffer */ zungetc(z); /* put result from 'filbuf' in the buffer */
} }
m = (n <= z->n) ? n : z->n; /* minimo de n e z->n */ m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
memcpy(b, z->p, m); memcpy(b, z->p, m);
z->n -= m; z->n -= m;
z->p += m; z->p += m;

View File

@@ -1,4 +1,4 @@
% $Id: manual.tex,v 1.22 1999/02/05 12:15:07 roberto Exp roberto $ % $Id: manual.tex,v 1.23 1999/02/12 19:23:02 roberto Exp roberto $
\documentclass[11pt]{article} \documentclass[11pt]{article}
\usepackage{fullpage,bnf} \usepackage{fullpage,bnf}
@@ -41,7 +41,7 @@ Waldemar Celes
\tecgraf\ --- Computer Science Department --- PUC-Rio \tecgraf\ --- Computer Science Department --- PUC-Rio
} }
%\date{\small \verb$Date: 1999/02/05 12:15:07 $} %\date{\small \verb$Date: 1999/02/12 19:23:02 $}
\maketitle \maketitle
@@ -122,8 +122,10 @@ and its documentation.
\noindent \noindent
The Lua language and this implementation have been entirely designed and The Lua language and this implementation have been entirely designed and
written by Waldemar Celes, Roberto Ierusalimschy and Luiz Henrique de written by Waldemar Celes, Roberto Ierusalimschy and Luiz Henrique de
Figueiredo at TeCGraf, PUC-Rio. This implementation contains no third-party Figueiredo at TeCGraf, PUC-Rio.
code.
\noindent
This implementation contains no third-party code.
\end{quotation} \end{quotation}
\newpage \newpage