Correcao da funcao PrintCode

This commit is contained in:
Waldemar Celes 1994-04-15 18:30:12 -03:00
parent c77d27afa2
commit 3ee5e71d0b
1 changed files with 28 additions and 5 deletions

33
lua.stx
View File

@ -1,6 +1,6 @@
%{ %{
char *rcs_luastx = "$Id: lua.stx,v 1.6 1994/04/13 21:37:20 celes Exp celes $"; char *rcs_luastx = "$Id: lua.stx,v 2.1 1994/04/15 19:02:04 celes Exp celes $";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -14,7 +14,7 @@ char *rcs_luastx = "$Id: lua.stx,v 1.6 1994/04/13 21:37:20 celes Exp celes $";
#include "table.h" #include "table.h"
#include "lua.h" #include "lua.h"
#define LISTING 0 #define LISTING 1
#ifndef MAXCODE #ifndef MAXCODE
#define MAXCODE 1024 #define MAXCODE 1024
@ -219,9 +219,6 @@ functionlist : /* empty */
| functionlist { pc=basepc=maincode; nlocalvar=0;} stat sc | functionlist { pc=basepc=maincode; nlocalvar=0;} stat sc
{ {
maincode=pc; maincode=pc;
#if LISTING
PrintCode(basepc,maincode,(Byte*)mainbuffer);
#endif
} }
| functionlist function | functionlist function
| functionlist setdebug | functionlist setdebug
@ -705,6 +702,9 @@ int lua_parse (void)
err = 0; err = 0;
if (yyparse () || (err==1)) return 1; if (yyparse () || (err==1)) return 1;
*maincode++ = HALT; *maincode++ = HALT;
#if LISTING
PrintCode(basepc,maincode,(Byte*)mainbuffer);
#endif
if (lua_execute (initcode)) return 1; if (lua_execute (initcode)) return 1;
maincode = initcode; maincode = initcode;
return 0; return 0;
@ -887,6 +887,29 @@ static void PrintCode (Byte *p, Byte *end, Byte *code)
printf ("%d RETCODE %d\n", p-code, *(++p)); printf ("%d RETCODE %d\n", p-code, *(++p));
p++; p++;
break; break;
case HALT: printf ("%d HALT\n", (p++)-code); break;
case SETFUNCTION:
{
CodeWord c1, c2;
int n = p-code;
p++;
get_word(c1,p);
get_word(c2,p);
printf ("%d SETFUNCTION %d %d\n", n, c1.w, c2.w);
}
break;
case SETLINE:
{
CodeWord c;
int n = p-code;
p++;
get_word(c,p);
printf ("%d SETLINE %d\n", n, c.w);
}
break;
case RESET: printf ("%d RESET\n", (p++)-code); break;
default: printf ("%d Cannot happen: code %d\n", (p++)-code, *(p-1)); break; default: printf ("%d Cannot happen: code %d\n", (p++)-code, *(p-1)); break;
} }
} }