diff options
author | Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> | 1996-02-28 20:10:46 -0300 |
---|---|---|
committer | Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> | 1996-02-28 20:10:46 -0300 |
commit | 870967ca773c95909f8bccc3307bdac9cf389fc5 (patch) | |
tree | 4c6483d834b10ed4f6548a4078c760d095635e85 /undump.c | |
parent | 66fc0f554aa45616d868ab820f8174a85817978d (diff) | |
download | lua-870967ca773c95909f8bccc3307bdac9cf389fc5.tar.gz lua-870967ca773c95909f8bccc3307bdac9cf389fc5.tar.bz2 lua-870967ca773c95909f8bccc3307bdac9cf389fc5.zip |
headers for Main and others are different
Diffstat (limited to 'undump.c')
-rw-r--r-- | undump.c | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** load bytecodes from files | 3 | ** load bytecodes from files |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_undump="$Id: undump.c,v 1.4 1996/02/24 16:44:28 lhf Exp lhf $"; | 6 | char *rcs_undump="$Id: undump.c,v 1.5 1996/02/26 19:44:17 lhf Exp lhf $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
@@ -20,18 +20,17 @@ static void panic(char *s) /* TODO: remove */ | |||
20 | exit(1); | 20 | exit(1); |
21 | } | 21 | } |
22 | 22 | ||
23 | static void Unthread(Byte *p, int i, int v) | 23 | static void Unthread(Byte *code, int i, int v) |
24 | { | 24 | { |
25 | while (i!=0) | 25 | while (i!=0) |
26 | { | 26 | { |
27 | CodeWord c; | 27 | CodeWord c; |
28 | Byte *q=p+i; | 28 | Byte *p=code+i; |
29 | get_word(c,q); | 29 | get_word(c,p); |
30 | q=p+i; | ||
31 | i=c.w; | 30 | i=c.w; |
32 | c.w=v; | 31 | c.w=v; |
33 | q[0]=c.m.c1; | 32 | p[-2]=c.m.c1; |
34 | q[1]=c.m.c2; | 33 | p[-1]=c.m.c2; |
35 | } | 34 | } |
36 | } | 35 | } |
37 | 36 | ||
@@ -60,22 +59,26 @@ static TFunc *lastF=NULL; | |||
60 | static void LoadFunction(FILE *D) | 59 | static void LoadFunction(FILE *D) |
61 | { | 60 | { |
62 | TFunc *tf=new(TFunc); | 61 | TFunc *tf=new(TFunc); |
62 | tf->next=NULL; | ||
63 | tf->size=LoadWord(D); /* TODO: Long? */ | 63 | tf->size=LoadWord(D); /* TODO: Long? */ |
64 | tf->marked=LoadWord(D); | ||
65 | tf->lineDefined=LoadWord(D); | 64 | tf->lineDefined=LoadWord(D); |
66 | tf->fileName=LoadString(D); /* TODO: not needed if not main */ | 65 | if (IsMain(tf)) /* new main */ |
67 | tf->code=LoadBlock(tf->size,D); | 66 | { |
68 | tf->next=NULL; | 67 | tf->fileName=LoadString(D); |
69 | if (tf->lineDefined==0) /* new main */ | ||
70 | Main=lastF=tf; | 68 | Main=lastF=tf; |
69 | } | ||
71 | else /* fix PUSHFUNCTION */ | 70 | else /* fix PUSHFUNCTION */ |
72 | { | 71 | { |
73 | CodeCode c; | 72 | CodeCode c; |
74 | Byte *p=Main->code+tf->marked; /* TODO: tf->marked=? */ | 73 | Byte *p; |
74 | tf->marked=LoadWord(D); | ||
75 | tf->fileName=Main->fileName; | ||
76 | p=Main->code+tf->marked; /* TODO: tf->marked=? */ | ||
75 | c.tf=tf; | 77 | c.tf=tf; |
76 | *p++=c.m.c1; *p++=c.m.c2; *p++=c.m.c3; *p++=c.m.c4; | 78 | *p++=c.m.c1; *p++=c.m.c2; *p++=c.m.c3; *p++=c.m.c4; |
77 | lastF->next=tf; lastF=tf; | 79 | lastF->next=tf; lastF=tf; |
78 | } | 80 | } |
81 | tf->code=LoadBlock(tf->size,D); | ||
79 | while (1) /* unthread */ | 82 | while (1) /* unthread */ |
80 | { | 83 | { |
81 | int c=getc(D); | 84 | int c=getc(D); |