diff options
Diffstat (limited to 'manual.tex')
-rw-r--r-- | manual.tex | 50 |
1 files changed, 35 insertions, 15 deletions
@@ -1,4 +1,4 @@ | |||
1 | % $Id: manual.tex,v 1.36 2000/04/17 19:23:48 roberto Exp roberto $ | 1 | % $Id: manual.tex,v 1.37 2000/05/12 19:19:18 roberto Exp roberto $ |
2 | 2 | ||
3 | \documentclass[11pt]{article} | 3 | \documentclass[11pt]{article} |
4 | \usepackage{fullpage,bnf} | 4 | \usepackage{fullpage,bnf} |
@@ -122,7 +122,7 @@ Waldemar Celes | |||
122 | \tecgraf\ --- Computer Science Department --- PUC-Rio | 122 | \tecgraf\ --- Computer Science Department --- PUC-Rio |
123 | } | 123 | } |
124 | 124 | ||
125 | \date{{\small \tt\$Date: 2000/04/17 19:23:48 $ $}} | 125 | \date{{\small \tt\$Date: 2000/05/12 19:19:18 $ $}} |
126 | 126 | ||
127 | \maketitle | 127 | \maketitle |
128 | 128 | ||
@@ -3329,7 +3329,22 @@ selects some fields of \verb|ar| to be filled, | |||
3329 | as indicated by the letter in parentheses in the definition of \verb|lua_Debug|; | 3329 | as indicated by the letter in parentheses in the definition of \verb|lua_Debug|; |
3330 | that is, an \verb|S| fills the fields \verb|source| and \verb|linedefined|, | 3330 | that is, an \verb|S| fills the fields \verb|source| and \verb|linedefined|, |
3331 | and \verb|l| fills the field \verb|currentline|, etc. | 3331 | and \verb|l| fills the field \verb|currentline|, etc. |
3332 | We describe each field below: | 3332 | |
3333 | To get information about a function that is not active (that is, | ||
3334 | it is not in the stack), | ||
3335 | you set the \verb|func| field of the \verb|lua_Debug| structure | ||
3336 | with the function, | ||
3337 | and start the \verb|what| string with the character \verb|>|. | ||
3338 | For instance, to know in which line a function \verb|f| was defined, | ||
3339 | you can write | ||
3340 | \begin{verbatim} | ||
3341 | lua_Debug ar; | ||
3342 | ar.func = lua_getglobal(L, "f"); | ||
3343 | lua_getinfo(L, ">S", &ar); | ||
3344 | printf("%d\n", ar.linedefined); | ||
3345 | \end{verbatim} | ||
3346 | |||
3347 | The fields of \verb|lua_Debug| have the following meaning: | ||
3333 | \begin{description} | 3348 | \begin{description} |
3334 | 3349 | ||
3335 | \item[source] | 3350 | \item[source] |
@@ -3523,21 +3538,26 @@ As a general rule, if your program does not need this library, | |||
3523 | do not open it. | 3538 | do not open it. |
3524 | 3539 | ||
3525 | 3540 | ||
3526 | \subsubsection*{\ff \T{getstack (level, [what])}}\Deffunc{getstack} | 3541 | \subsubsection*{\ff \T{getinfo (function, [what])}}\Deffunc{getinfo} |
3542 | |||
3543 | This function returns a table with information about a function. | ||
3544 | You can give the function directly, | ||
3545 | or you can give a number as the value of \verb|function|, | ||
3546 | which means the function running at level \verb|function| of the stack: | ||
3547 | Level 0 is the current function (\verb|getinfo| itself); | ||
3548 | level 1 is the function that called \verb|getinfo|; | ||
3549 | and so on. | ||
3550 | If \verb|function| is a number larger than the number of active functions, | ||
3551 | \verb|getinfo| returns \nil. | ||
3527 | 3552 | ||
3528 | This function returns a table with information about the function | 3553 | The returned table contains all the fields returned by \verb|lua_getinfo|, |
3529 | running at level \verb|level| of the stack. | ||
3530 | Level 0 is the current function (\verb|getstack| itself); | ||
3531 | level 1 is the function that called \verb|getstack|. | ||
3532 | If \verb|level| is larger than the number of active functions, | ||
3533 | the function returns \nil. | ||
3534 | The table contains all the fields returned by \verb|lua_getinfo|, | ||
3535 | with the string \verb|what| describing what to get. | 3554 | with the string \verb|what| describing what to get. |
3536 | The default for \rerb|what| is to get all information available. | 3555 | The default for \verb|what| is to get all information available. |
3537 | 3556 | ||
3538 | For instance, the expression \verb|getstack(1,"n").name| returns | 3557 | For instance, the expression \verb|getinfo(1,"n").name| returns |
3539 | the name of the current function, | 3558 | the name of the current function, if a reasonable name can be found, |
3540 | if a reasonable name can be found. | 3559 | and \verb|getinfo(print)| returns a table with all available information |
3560 | about the \verb|print| function. | ||
3541 | 3561 | ||
3542 | 3562 | ||
3543 | \subsubsection*{\ff \T{getlocal (level, local)}}\Deffunc{getlocal} | 3563 | \subsubsection*{\ff \T{getlocal (level, local)}}\Deffunc{getlocal} |