From 6ac047afc46cbee935587b5734ec37d2e667a598 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 9 Jan 1998 12:57:43 -0200 Subject: [PATCH] details --- llex.h | 4 ++-- lobject.h | 13 ++++--------- lstate.h | 6 +++--- lstrlib.c | 4 ++-- lzio.h | 4 ++-- manual.tex | 26 ++++++++++++++------------ 6 files changed, 27 insertions(+), 30 deletions(-) diff --git a/llex.h b/llex.h index 7ebfa378..dcce5149 100644 --- a/llex.h +++ b/llex.h @@ -1,5 +1,5 @@ /* -** $Id: llex.h,v 1.5 1997/12/02 12:43:44 roberto Exp roberto $ +** $Id: llex.h,v 1.6 1997/12/17 20:48:58 roberto Exp roberto $ ** Lexical Analizer ** See Copyright Notice in lua.h */ @@ -28,8 +28,8 @@ typedef struct LexState { int linenumber; /* input line counter */ int linelasttoken; /* line where last token was read */ int lastline; /* last line wherein a SETLINE was generated */ - struct ifState ifstate[MAX_IFS]; int iflevel; /* level of nested $if's (for lexical analysis) */ + struct ifState ifstate[MAX_IFS]; } LexState; diff --git a/lobject.h b/lobject.h index 366b1802..6fc61916 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.12 1997/12/23 19:24:19 roberto Exp roberto $ +** $Id: lobject.h,v 1.13 1997/12/26 18:38:16 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -96,8 +96,8 @@ typedef struct TaggedString { union { TObject globalval; struct { - void *v; /* if this is a userdata, here is its value */ int tag; + void *v; /* if this is a userdata, here is its value */ } d; } u; char str[1]; /* \0 byte already reserved */ @@ -111,11 +111,11 @@ typedef struct TaggedString { */ typedef struct TProtoFunc { GCnode head; + struct TObject *consts; + int nconsts; Byte *code; /* ends with opcode ENDCODE */ int lineDefined; TaggedString *fileName; - struct TObject *consts; - int nconsts; struct LocVar *locvars; /* ends with line = -1 */ } TProtoFunc; @@ -166,11 +166,6 @@ typedef struct Hash { } Hash; -/* -** a gross estimation of number of memory "blocks" allocated -** (a block is *roughly* 32 bytes) -*/ - extern char *luaO_typenames[]; extern TObject luaO_nilobject; diff --git a/lstate.h b/lstate.h index 3da2e2ef..06b4aced 100644 --- a/lstate.h +++ b/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 1.5 1997/11/28 16:56:05 roberto Exp roberto $ +** $Id: lstate.h,v 1.6 1997/12/17 20:48:58 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -49,8 +49,6 @@ typedef struct LState { struct C_Lua_Stack Cstack; /* C2lua struct */ void *errorJmp; /* current error recover point */ TObject errorim; /* error tag method */ - struct C_Lua_Stack Cblocks[MAX_C_BLOCKS]; - int numCblocks; /* number of nested Cblocks */ GCnode rootproto; /* list of all prototypes */ GCnode rootcl; /* list of all closures */ GCnode roottable; /* list of all tables */ @@ -69,6 +67,8 @@ typedef struct LState { char *Mbuffbase; /* current first position of Mbuffer */ int Mbuffsize; /* size of Mbuffer */ int Mbuffnext; /* next position to fill in Mbuffer */ + struct C_Lua_Stack Cblocks[MAX_C_BLOCKS]; + int numCblocks; /* number of nested Cblocks */ } LState; diff --git a/lstrlib.c b/lstrlib.c index 34b9da42..8c963b11 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.5 1997/12/17 20:48:58 roberto Exp roberto $ +** $Id: lstrlib.c,v 1.6 1998/01/09 14:44:55 roberto Exp $ ** Standard library for strings and pattern-matching ** See Copyright Notice in lua.h */ @@ -109,11 +109,11 @@ static void str_ascii (void) #define MAX_CAPT 9 struct Capture { + int level; /* total number of captures (finished or unfinished) */ struct { char *init; int len; /* -1 signals unfinished capture */ } capture[MAX_CAPT]; - int level; /* total number of captures (finished or unfinished) */ }; diff --git a/lzio.h b/lzio.h index 54354a8a..94b79da4 100644 --- a/lzio.h +++ b/lzio.h @@ -1,5 +1,5 @@ /* -** $Id: lzio.h,v 1.2 1997/11/21 19:00:46 roberto Exp roberto $ +** $Id: lzio.h,v 1.3 1997/12/22 20:57:18 roberto Exp roberto $ ** Buffered streams ** See Copyright Notice in lua.h */ @@ -42,8 +42,8 @@ struct zio { unsigned char* p; /* current position in buffer */ int (*filbuf)(ZIO* z); void* u; /* additional data */ - unsigned char buffer[ZBSIZE]; /* buffer */ char *name; + unsigned char buffer[ZBSIZE]; /* buffer */ }; diff --git a/manual.tex b/manual.tex index 18803118..4139955b 100644 --- a/manual.tex +++ b/manual.tex @@ -1,4 +1,4 @@ -% $Id: manual.tex,v 1.2 1998/01/06 19:17:31 roberto Exp roberto $ +% $Id: manual.tex,v 1.3 1998/01/07 16:26:48 roberto Exp roberto $ \documentstyle[fullpage,11pt,bnf]{article} @@ -38,7 +38,7 @@ Waldemar Celes \tecgraf\ --- Computer Science Department --- PUC-Rio } -\date{\small \verb$Date: 1998/01/06 19:17:31 $} +\date{\small \verb$Date: 1998/01/07 16:26:48 $} \maketitle @@ -1658,9 +1658,9 @@ void lua_pushCclosure (lua_CFunction fn, int n); \end{verbatim} is used to put the C function on C2lua, with the argument \verb|n| telling how many upvalues must be -associated with the function -(notice that the macro \verb|lua_pushcfunction| is defined as -\verb|lua_pushCclosure| with \verb|n| set to 0). +associated with the function; +in fact, the macro \verb|lua_pushcfunction| is defined as +\verb|lua_pushCclosure| with \verb|n| set to 0. Then, any time the function is called, these upvalues are inserted as the first arguments to the function, before the actual arguments provided in the call. @@ -1718,10 +1718,11 @@ Currently there are three standard libraries: \item mathematical functions (sin, log, etc); \item input and output (plus some system facilities). \end{itemize} -In order to have access to these libraries, +To have access to these libraries, the C host program must call the functions -\verb|lua_strlibopen|, \verb|lua_mathlibopen|, and \verb|lua_iolibopen|, -declared in \verb|lualib.h|. +\verb|lua_strlibopen|, \verb|lua_mathlibopen|, +and \verb|lua_iolibopen|, declared in \verb|lualib.h|. +\Deffunc{lua_strlibopen}\Deffunc{lua_mathlibopen}\Deffunc{lua_iolibopen}. \subsection{Predefined Functions} \label{predefined} @@ -2708,11 +2709,11 @@ Here is a list of all these incompatibilities. \subsection*{Incompatibilities with \Index{version 3.0}} \begin{itemize} -\item To support for multiple contexts, -the whole library must be explicitly opened before used. +\item To support multiple contexts, +Lua 3.1 must be explicitly opened before used. However, all standard libraries check whether Lua is already opened, so any program that opens at least one standard library before using -Lua API does not need to be corrected. +Lua API does not need to be modified. \item Function \verb|dostring| does not accept an optional second argument, with a temporary error method. @@ -2725,7 +2726,8 @@ Closures make this feature irrelevant. \item The syntax for function declaration is now more restricted; for instance, the old syntax \verb|function f[exp] (x) ... end| is not accepted in 3.1. -Programs should use an explicit assignment instead, like this: +In these cases, +programs should use an explicit assignment instead, like \verb|f[exp] = function (x) ... end|. \item Old pre-compiled code is obsolete, and must be re-compiled.