mirror of https://github.com/lua/lua
functions now linked into a list headed by main
This commit is contained in:
parent
b3c10c8c41
commit
b04f88d581
19
undump.c
19
undump.c
|
@ -3,7 +3,7 @@
|
||||||
** load bytecodes from files
|
** load bytecodes from files
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_undump="$Id: undump.c,v 1.2 1996/02/23 22:00:26 lhf Exp lhf $";
|
char *rcs_undump="$Id: undump.c,v 1.3 1996/02/24 03:46:57 lhf Exp lhf $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -55,6 +55,7 @@ static char* LoadString(FILE *D)
|
||||||
}
|
}
|
||||||
|
|
||||||
static TFunc *Main=NULL;
|
static TFunc *Main=NULL;
|
||||||
|
static TFunc *lastF=NULL;
|
||||||
|
|
||||||
static void LoadFunction(FILE *D)
|
static void LoadFunction(FILE *D)
|
||||||
{
|
{
|
||||||
|
@ -64,14 +65,16 @@ static void LoadFunction(FILE *D)
|
||||||
tf->lineDefined=LoadWord(D);
|
tf->lineDefined=LoadWord(D);
|
||||||
tf->fileName=LoadString(D);
|
tf->fileName=LoadString(D);
|
||||||
tf->code=LoadBlock(tf->size,D);
|
tf->code=LoadBlock(tf->size,D);
|
||||||
|
tf->next=NULL;
|
||||||
if (tf->lineDefined==0) /* new main */
|
if (tf->lineDefined==0) /* new main */
|
||||||
Main=tf;
|
Main=lastF=tf;
|
||||||
else /* fix PUSHFUNCTION */
|
else /* fix PUSHFUNCTION */
|
||||||
{
|
{
|
||||||
CodeCode c;
|
CodeCode c;
|
||||||
Byte *p=Main->code+tf->marked; /* TODO: tf->marked=? */
|
Byte *p=Main->code+tf->marked; /* TODO: tf->marked=? */
|
||||||
c.tf=tf;
|
c.tf=tf;
|
||||||
*p++=c.m.c1; *p++=c.m.c2; *p++=c.m.c3; *p++=c.m.c4;
|
*p++=c.m.c1; *p++=c.m.c2; *p++=c.m.c3; *p++=c.m.c4;
|
||||||
|
lastF->next=tf; lastF=tf;
|
||||||
}
|
}
|
||||||
while (1) /* unthread */
|
while (1) /* unthread */
|
||||||
{
|
{
|
||||||
|
@ -92,8 +95,6 @@ static void LoadFunction(FILE *D)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("tf=%p\n",tf);
|
|
||||||
PrintFunction(tf); /* TODO: remove */
|
|
||||||
ungetc(c,D);
|
ungetc(c,D);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -122,10 +123,14 @@ static void LoadChunk(FILE *D)
|
||||||
int c=getc(D);
|
int c=getc(D);
|
||||||
if (c=='F') LoadFunction(D); else { ungetc(c,D); break; }
|
if (c=='F') LoadFunction(D); else { ungetc(c,D); break; }
|
||||||
}
|
}
|
||||||
PrintFunction(Main); /* TODO: run Main */
|
{ /* TODO: run Main? */
|
||||||
|
TFunc *tf;
|
||||||
|
for (tf=Main; tf!=NULL; tf=tf->next)
|
||||||
|
PrintFunction(tf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Undump(FILE *D)
|
void luaI_undump(FILE *D)
|
||||||
{
|
{
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -138,6 +143,6 @@ void Undump(FILE *D)
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
Undump(stdin);
|
luaI_undump(stdin);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue