|
@@ -3,7 +3,7 @@
|
|
|
** 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 <string.h>
|
|
@@ -55,6 +55,7 @@ static char* LoadString(FILE *D)
|
|
|
}
|
|
|
|
|
|
static TFunc *Main=NULL;
|
|
|
+static TFunc *lastF=NULL;
|
|
|
|
|
|
static void LoadFunction(FILE *D)
|
|
|
{
|
|
@@ -64,14 +65,16 @@ static void LoadFunction(FILE *D)
|
|
|
tf->lineDefined=LoadWord(D);
|
|
|
tf->fileName=LoadString(D);
|
|
|
tf->code=LoadBlock(tf->size,D);
|
|
|
+ tf->next=NULL;
|
|
|
if (tf->lineDefined==0) /* new main */
|
|
|
- Main=tf;
|
|
|
+ Main=lastF=tf;
|
|
|
else /* fix PUSHFUNCTION */
|
|
|
{
|
|
|
CodeCode c;
|
|
|
Byte *p=Main->code+tf->marked; /* TODO: tf->marked=? */
|
|
|
c.tf=tf;
|
|
|
*p++=c.m.c1; *p++=c.m.c2; *p++=c.m.c3; *p++=c.m.c4;
|
|
|
+ lastF->next=tf; lastF=tf;
|
|
|
}
|
|
|
while (1) /* unthread */
|
|
|
{
|
|
@@ -92,8 +95,6 @@ static void LoadFunction(FILE *D)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-printf("tf=%p\n",tf);
|
|
|
-PrintFunction(tf); /* TODO: remove */
|
|
|
ungetc(c,D);
|
|
|
return;
|
|
|
}
|
|
@@ -122,10 +123,14 @@ static void LoadChunk(FILE *D)
|
|
|
int c=getc(D);
|
|
|
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)
|
|
|
{
|
|
@@ -138,6 +143,6 @@ void Undump(FILE *D)
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
{
|
|
|
- Undump(stdin);
|
|
|
+ luaI_undump(stdin);
|
|
|
return 0;
|
|
|
}
|