diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-11 12:00:08 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-11 12:00:08 -0200 |
commit | 0c5ac77c9949ecfe83537ebe2de355a5286ce6ae (patch) | |
tree | 641ab37cf5e35e28a75676afb87e07960eaa5b1a | |
parent | b8996eaabad0ef09dca743ca0bdf8c439f678611 (diff) | |
download | lua-0c5ac77c9949ecfe83537ebe2de355a5286ce6ae.tar.gz lua-0c5ac77c9949ecfe83537ebe2de355a5286ce6ae.tar.bz2 lua-0c5ac77c9949ecfe83537ebe2de355a5286ce6ae.zip |
small corrections to avoid 'warings' with acc.
do_call was moving results in the wrong order.
-rw-r--r-- | opcode.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.8 1994/11/10 17:11:52 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.9 1994/11/10 17:36:54 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
@@ -101,7 +101,7 @@ static void lua_initstack (void) | |||
101 | */ | 101 | */ |
102 | static void lua_checkstack (Word n) | 102 | static void lua_checkstack (Word n) |
103 | { | 103 | { |
104 | if (n > maxstack) | 104 | if ((Long)n > maxstack) |
105 | { | 105 | { |
106 | int t; | 106 | int t; |
107 | if (stack == NULL) | 107 | if (stack == NULL) |
@@ -186,16 +186,17 @@ static int lua_tostring (Object *obj) | |||
186 | /* | 186 | /* |
187 | ** Adjust stack. Set top to the given value, pushing NILs if needed. | 187 | ** Adjust stack. Set top to the given value, pushing NILs if needed. |
188 | */ | 188 | */ |
189 | static void adjust_top (Object *newtop) | 189 | static void adjust_top (int newtop) |
190 | { | 190 | { |
191 | while (top < newtop) tag(top++) = LUA_T_NIL; | 191 | Object *nt = stack+newtop; |
192 | top = newtop; /* top could be bigger than newtop */ | 192 | while (top < nt) tag(top++) = LUA_T_NIL; |
193 | top = nt; /* top could be bigger than newtop */ | ||
193 | } | 194 | } |
194 | 195 | ||
195 | 196 | ||
196 | static void adjustC (int nParams) | 197 | static void adjustC (int nParams) |
197 | { | 198 | { |
198 | adjust_top(stack+CBase+nParams); | 199 | adjust_top(CBase+nParams); |
199 | } | 200 | } |
200 | 201 | ||
201 | 202 | ||
@@ -240,14 +241,15 @@ static void do_call (Object *func, int base, int nResults, int whereRes) | |||
240 | } | 241 | } |
241 | /* adjust the number of results */ | 242 | /* adjust the number of results */ |
242 | if (nResults != MULT_RET && top - (stack+firstResult) != nResults) | 243 | if (nResults != MULT_RET && top - (stack+firstResult) != nResults) |
243 | adjust_top(stack+firstResult+nResults); | 244 | adjust_top(firstResult+nResults); |
244 | /* move results to the given position */ | 245 | /* move results to the given position */ |
245 | if (firstResult != whereRes) | 246 | if (firstResult != whereRes) |
246 | { | 247 | { |
247 | int i = top - (stack+firstResult); /* number of results */ | 248 | int i; |
248 | top -= firstResult-whereRes; | 249 | nResults = top - (stack+firstResult); /* actual number of results */ |
249 | while (i--) | 250 | for (i=0; i<nResults; i++) |
250 | *(stack+whereRes+i) = *(stack+firstResult+i); | 251 | *(stack+whereRes+i) = *(stack+firstResult+i); |
252 | top -= firstResult-whereRes; | ||
251 | } | 253 | } |
252 | } | 254 | } |
253 | 255 | ||
@@ -830,11 +832,11 @@ static int lua_execute (Byte *pc, int base) | |||
830 | break; | 832 | break; |
831 | 833 | ||
832 | case ADJUST0: | 834 | case ADJUST0: |
833 | adjust_top((stack+base)); | 835 | adjust_top(base); |
834 | break; | 836 | break; |
835 | 837 | ||
836 | case ADJUST: | 838 | case ADJUST: |
837 | adjust_top((stack+base) + *(pc++)); | 839 | adjust_top(base + *(pc++)); |
838 | break; | 840 | break; |
839 | 841 | ||
840 | case CREATEARRAY: | 842 | case CREATEARRAY: |