diff options
author | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-10-11 11:38:17 -0300 |
---|---|---|
committer | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-10-11 11:38:17 -0300 |
commit | ceaaa0cca8e02b102963730e8df25ac4fbe5f2dd (patch) | |
tree | 3483f2a4299b5605f1838d5651446f6a2b0b1111 | |
parent | 82ceb12b7af8411e543ac8672a4d5ad4652de0fc (diff) | |
download | lua-ceaaa0cca8e02b102963730e8df25ac4fbe5f2dd.tar.gz lua-ceaaa0cca8e02b102963730e8df25ac4fbe5f2dd.tar.bz2 lua-ceaaa0cca8e02b102963730e8df25ac4fbe5f2dd.zip |
Correcao do tratamento de erro reportado dentro de uma funcao.
-rw-r--r-- | inout.c | 13 | ||||
-rw-r--r-- | inout.h | 4 | ||||
-rw-r--r-- | lua.stx | 4 | ||||
-rw-r--r-- | opcode.c | 9 |
4 files changed, 16 insertions, 14 deletions
@@ -4,9 +4,10 @@ | |||
4 | ** facilities. | 4 | ** facilities. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | char *rcs_inout="$Id: inout.c,v 2.2 1994/08/17 22:22:44 roberto Exp celes $"; | 7 | char *rcs_inout="$Id: inout.c,v 2.3 1994/09/05 21:22:43 celes Exp celes $"; |
8 | 8 | ||
9 | #include <stdio.h> | 9 | #include <stdio.h> |
10 | #include <stdlib.h> | ||
10 | #include <string.h> | 11 | #include <string.h> |
11 | 12 | ||
12 | #include "opcode.h" | 13 | #include "opcode.h" |
@@ -25,7 +26,7 @@ int lua_debugline; | |||
25 | #ifndef MAXFUNCSTACK | 26 | #ifndef MAXFUNCSTACK |
26 | #define MAXFUNCSTACK 64 | 27 | #define MAXFUNCSTACK 64 |
27 | #endif | 28 | #endif |
28 | static struct { int file; int function; } funcstack[MAXFUNCSTACK]; | 29 | static struct { char *file; int function; } funcstack[MAXFUNCSTACK]; |
29 | static int nfuncstack=0; | 30 | static int nfuncstack=0; |
30 | 31 | ||
31 | static FILE *fp; | 32 | static FILE *fp; |
@@ -123,15 +124,15 @@ void lua_error (char *s) | |||
123 | ** Called to execute SETFUNCTION opcode, this function pushs a function into | 124 | ** Called to execute SETFUNCTION opcode, this function pushs a function into |
124 | ** function stack. Return 0 on success or 1 on error. | 125 | ** function stack. Return 0 on success or 1 on error. |
125 | */ | 126 | */ |
126 | int lua_pushfunction (int file, int function) | 127 | int lua_pushfunction (char *file, int function) |
127 | { | 128 | { |
128 | if (nfuncstack >= MAXFUNCSTACK-1) | 129 | if (nfuncstack >= MAXFUNCSTACK-1) |
129 | { | 130 | { |
130 | lua_error ("function stack overflow"); | 131 | lua_error ("function stack overflow"); |
131 | return 1; | 132 | return 1; |
132 | } | 133 | } |
133 | funcstack[nfuncstack].file = file; | ||
134 | funcstack[nfuncstack].function = function; | 134 | funcstack[nfuncstack].function = function; |
135 | funcstack[nfuncstack].file = file; | ||
135 | nfuncstack++; | 136 | nfuncstack++; |
136 | return 0; | 137 | return 0; |
137 | } | 138 | } |
@@ -160,12 +161,12 @@ void lua_reportbug (char *s) | |||
160 | sprintf (strchr(msg,0), | 161 | sprintf (strchr(msg,0), |
161 | "\n\tin statement begining at line %d in function \"%s\" of file \"%s\"", | 162 | "\n\tin statement begining at line %d in function \"%s\" of file \"%s\"", |
162 | lua_debugline, lua_varname(funcstack[nfuncstack-1].function), | 163 | lua_debugline, lua_varname(funcstack[nfuncstack-1].function), |
163 | lua_file[funcstack[nfuncstack-1].file]); | 164 | funcstack[nfuncstack-1].file); |
164 | sprintf (strchr(msg,0), "\n\tactive stack\n"); | 165 | sprintf (strchr(msg,0), "\n\tactive stack\n"); |
165 | for (i=nfuncstack-1; i>=0; i--) | 166 | for (i=nfuncstack-1; i>=0; i--) |
166 | sprintf (strchr(msg,0), "\t-> function \"%s\" of file \"%s\"\n", | 167 | sprintf (strchr(msg,0), "\t-> function \"%s\" of file \"%s\"\n", |
167 | lua_varname(funcstack[i].function), | 168 | lua_varname(funcstack[i].function), |
168 | lua_file[funcstack[i].file]); | 169 | funcstack[i].file); |
169 | } | 170 | } |
170 | else | 171 | else |
171 | { | 172 | { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: $ | 2 | ** $Id: inout.h,v 1.1 1993/12/17 18:41:19 celes Exp $ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | 5 | ||
@@ -14,7 +14,7 @@ int lua_openfile (char *fn); | |||
14 | void lua_closefile (void); | 14 | void lua_closefile (void); |
15 | int lua_openstring (char *s); | 15 | int lua_openstring (char *s); |
16 | void lua_closestring (void); | 16 | void lua_closestring (void); |
17 | int lua_pushfunction (int file, int function); | 17 | int lua_pushfunction (char *file, int function); |
18 | void lua_popfunction (void); | 18 | void lua_popfunction (void); |
19 | void lua_reportbug (char *s); | 19 | void lua_reportbug (char *s); |
20 | 20 | ||
@@ -1,6 +1,6 @@ | |||
1 | %{ | 1 | %{ |
2 | 2 | ||
3 | char *rcs_luastx = "$Id: lua.stx,v 2.7 1994/08/05 19:31:09 celes Exp celes $"; | 3 | char *rcs_luastx = "$Id: lua.stx,v 2.8 1994/10/11 13:02:39 celes Exp celes $"; |
4 | 4 | ||
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
@@ -283,7 +283,7 @@ function : FUNCTION NAME | |||
283 | if (lua_debug) | 283 | if (lua_debug) |
284 | { | 284 | { |
285 | code_byte(SETFUNCTION); | 285 | code_byte(SETFUNCTION); |
286 | code_word(lua_nfile-1); | 286 | code_code((Byte *)lua_file[lua_nfile-1]); |
287 | code_word($<vWord>3); | 287 | code_word($<vWord>3); |
288 | } | 288 | } |
289 | lua_codeadjust (0); | 289 | lua_codeadjust (0); |
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 2.7 1994/09/20 15:11:11 celes Exp celes $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 2.8 1994/09/27 21:43:30 celes Exp celes $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
@@ -600,10 +600,11 @@ int lua_execute (Byte *pc) | |||
600 | 600 | ||
601 | case SETFUNCTION: | 601 | case SETFUNCTION: |
602 | { | 602 | { |
603 | CodeWord file, func; | 603 | CodeCode file; |
604 | get_word(file,pc); | 604 | CodeWord func; |
605 | get_code(file,pc); | ||
605 | get_word(func,pc); | 606 | get_word(func,pc); |
606 | if (lua_pushfunction (file.w, func.w)) | 607 | if (lua_pushfunction ((char *)file.b, func.w)) |
607 | return 1; | 608 | return 1; |
608 | } | 609 | } |
609 | break; | 610 | break; |