aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-08-12 14:43:35 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-08-12 14:43:35 -0300
commit27f8a4a69e15bc9e1ca98db87d10b19c582c6fd3 (patch)
tree22dccfd50baadec8017676587e1baacbf007fd5e
parent8e4ac679ffce4a2d59b0a404473275411854f598 (diff)
downloadlua-27f8a4a69e15bc9e1ca98db87d10b19c582c6fd3.tar.gz
lua-27f8a4a69e15bc9e1ca98db87d10b19c582c6fd3.tar.bz2
lua-27f8a4a69e15bc9e1ca98db87d10b19c582c6fd3.zip
towards 5.0 (one more step)...
-rw-r--r--manual.tex125
1 files changed, 72 insertions, 53 deletions
diff --git a/manual.tex b/manual.tex
index 2bb72535..956d2cac 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 1.57 2002/08/06 19:10:44 roberto Exp roberto $ 1% $Id: manual.tex,v 1.58 2002/08/09 21:03:19 roberto Exp roberto $
2 2
3\documentclass[11pt,twoside,draft]{article} 3\documentclass[11pt,twoside,draft]{article}
4\usepackage{fullpage} 4\usepackage{fullpage}
@@ -133,7 +133,7 @@ Waldemar Celes
133\tecgraf\ --- Computer Science Department --- PUC-Rio 133\tecgraf\ --- Computer Science Department --- PUC-Rio
134} 134}
135 135
136%\date{{\small \tt\$Date: 2002/08/06 19:10:44 $ $}} 136%\date{{\small \tt\$Date: 2002/08/09 21:03:19 $ $}}
137 137
138\maketitle 138\maketitle
139 139
@@ -2616,14 +2616,14 @@ The structure \verb|lua_Debug| is used to carry different pieces of
2616information about an active function: 2616information about an active function:
2617\begin{verbatim} 2617\begin{verbatim}
2618 typedef struct lua_Debug { 2618 typedef struct lua_Debug {
2619 const char *event; /* "call", "return" */ 2619 lua_Hookevent event;
2620 int currentline; /* (l) */
2621 const char *name; /* (n) */ 2620 const char *name; /* (n) */
2622 const char *namewhat; /* (n) `global', `local', `field', `method' */ 2621 const char *namewhat; /* (n) `global', `local', `field', `method' */
2622 const char *what; /* (S) `Lua' function, `C' function, Lua `main' */
2623 const char *source; /* (S) */
2624 int currentline; /* (l) */
2623 int nups; /* (u) number of upvalues */ 2625 int nups; /* (u) number of upvalues */
2624 int linedefined; /* (S) */ 2626 int linedefined; /* (S) */
2625 const char *what; /* (S) "Lua" function, "C" function, Lua "main" */
2626 const char *source; /* (S) */
2627 char short_src[LUA_IDSIZE]; /* (S) */ 2627 char short_src[LUA_IDSIZE]; /* (S) */
2628 2628
2629 /* private part */ 2629 /* private part */
@@ -2760,38 +2760,53 @@ local variables for a function at a given level of the stack:
2760 2760
2761\subsection{Hooks}\label{sub-hooks} 2761\subsection{Hooks}\label{sub-hooks}
2762 2762
2763The Lua interpreter offers two hooks for debugging purposes: 2763The Lua interpreter offers a mechanism of hooks:
2764a \emph{call} hook and a \emph{line} hook. 2764user-defined C functions that are called during the program execution.
2765Both have type \verb|lua_Hook|, defined as follows: 2765A hook may be called in four different events:
2766a \emph{call} event, when Lua calls a function;
2767a \emph{return} event, when Lua returns from a function;
2768a \emph{line} event, when Lua starts executing a new line of code;
2769and a \emph{count} event, that happens every ``count'' instructions.
2770Lua identifies them with the following enumeration:
2771\begin{verbatim}
2772typedef enum lua_Hookevent {
2773 LUA_HOOKCALL, LUA_HOOKRET, LUA_HOOKLINE, LUA_HOOKCOUNT
2774} lua_Hookevent;
2775\end{verbatim}
2776
2777A hook has type \verb|lua_Hook|, defined as follows:
2766\begin{verbatim} 2778\begin{verbatim}
2767 typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); 2779 typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
2768\end{verbatim} 2780\end{verbatim}
2769\DefAPI{lua_Hook} 2781\DefAPI{lua_Hook}
2770You can set the hooks with the following functions: 2782You can set the hook with the following function:
2771\begin{verbatim} 2783\begin{verbatim}
2772 lua_Hook lua_setcallhook (lua_State *L, lua_Hook func); 2784 int lua_sethook (lua_State *L, lua_Hook func, unsigned long mask);
2773 lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
2774\end{verbatim} 2785\end{verbatim}
2775\DefAPI{lua_setcallhook}\DefAPI{lua_setlinehook} 2786\DefAPI{lua_sethook}
2776A hook is disabled when its value is \verb|NULL|, 2787\verb|func| is the hook,
2777which is the initial value of both hooks. 2788and \verb|mask| specifies at which events it will be called.
2778The functions \verb|lua_setcallhook| and \verb|lua_setlinehook| 2789It is formed by a disjunction of the constants
2779set their corresponding hooks and return their previous values. 2790\verb|LUA_MASKCALL|,
2780 2791\verb|LUA_MASKRET|,
2781The call hook is called whenever the 2792\verb|LUA_MASKLINE|,
2782interpreter enters or leaves a function. 2793plus the macro \verb|LUA_MASKCOUNT(count)|.
2783The \verb|event| field of \verb|ar| has the string \verb|"call"| 2794%TODO explicar melhor...
2784or \verb|"return"|. 2795
2785This \verb|ar| can then be used in calls to \verb|lua_getinfo|, 2796A hook is disabled with the mask zero.
2786\verb|lua_getlocal|, and \verb|lua_setlocal| 2797
2787to get more information about the function and to manipulate its 2798You can get the current hook and the current mask with the next functions:
2788local variables. 2799\begin{verbatim}
2789 2800 lua_Hook lua_gethook (lua_State *L);
2790The line hook is called every time the interpreter changes 2801 unsigned long lua_gethookmask (lua_State *L);
2791the line of code it is executing. 2802\end{verbatim}
2792The \verb|event| field of \verb|ar| has the string \verb|"line"|, 2803\DefAPI{lua_gethook}\DefAPI{lua_gethookmask}
2793and the \verb|currentline| field has the new line number. 2804You can get the count inside a mask with the macro \verb|lua_getmaskcount|.
2794Again, you can use this \verb|ar| in other calls to the debug API. 2805
2806Whenever a hook is called, its \verb|ar| argument has its field
2807\verb|event| set to the specific event that triggered the hook.
2808Moreover, for line events, the field \verb|currentline| is also set.
2809For the value of any other field, the hook must call \verb|lua_getinfo|.
2795 2810
2796While Lua is running a hook, it disables other calls to hooks. 2811While Lua is running a hook, it disables other calls to hooks.
2797Therefore, if a hook calls Lua to execute a function or a chunk, 2812Therefore, if a hook calls Lua to execute a function or a chunk,
@@ -4037,37 +4052,38 @@ specially the head of the group, Marcelo Gattass.
4037At the risk of omitting several names, 4052At the risk of omitting several names,
4038we also thank the following individuals for supporting, 4053we also thank the following individuals for supporting,
4039contributing to, and spreading the word about Lua: 4054contributing to, and spreading the word about Lua:
4040Alan Watson, 4055Mark Ian Barlow,
4056John Belmonte,
4057Renato Borges,
4058Carlos Cassino,
4059Renato Cerqueira,
4041Andr\'e Clinio, 4060Andr\'e Clinio,
4042Andr\'e Costa, 4061Andr\'e Costa,
4043Bret Mogilefsky, 4062Steve Dekorte,
4063Jon Erickson,
4064Tom\'as Gorham,
4065Stephan Herrmann,
4066Erik Hougaard,
4067David Jeske,
4068Jon Kleiser,
4044Cameron Laird, 4069Cameron Laird,
4045Carlos Cassino,
4046Carlos Henrique Levy, 4070Carlos Henrique Levy,
4047Claudio Terra, 4071Philippe Lhost,
4048David Jeske,
4049Edgar Toernig,
4050Erik Hougaard,
4051Jim Mathies, 4072Jim Mathies,
4052John Belmonte, 4073Bret Mogilefsky,
4053John Passaniti, 4074John Passaniti,
4054John Roll, 4075Vincent Penquerc'h,
4055Jon Erickson,
4056Jon Kleiser,
4057Mark Ian Barlow,
4058Nick Trout,
4059Noemi Rodriguez,
4060Norman Ramsey, 4076Norman Ramsey,
4061Philippe Lhost,
4062Renata Ratton, 4077Renata Ratton,
4063Renato Borges, 4078Noemi Rodriguez,
4064Renato Cerqueira, 4079John Roll,
4080Antonio Scuri,
4081Claudio Terra,
4065Reuben Thomas, 4082Reuben Thomas,
4066Stephan Herrmann, 4083Edgar Toernig,
4067Steve Dekorte, 4084Nick Trout,
4068Thatcher Ulrich, 4085Thatcher Ulrich,
4069Tom\'as Gorham, 4086Alan Watson.
4070Vincent Penquerc'h.
4071Thank you! 4087Thank you!
4072 4088
4073 4089
@@ -4089,6 +4105,9 @@ A function call as the last expression in a list constructor
4089(like \verb|{a,b,f()}}|) has all its return values inserted in the list. 4105(like \verb|{a,b,f()}}|) has all its return values inserted in the list.
4090 4106
4091\item 4107\item
4108The precedence of \rwd{or} is smaller than the precedence of \rwd{and}.
4109
4110\item
4092\rwd{in} is a reserved word. 4111\rwd{in} is a reserved word.
4093 4112
4094\item 4113\item