diff options
Diffstat (limited to 'opcode.c')
-rw-r--r-- | opcode.c | 30 |
1 files changed, 12 insertions, 18 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.74 1996/09/20 12:51:16 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.75 1996/09/24 17:30:28 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
@@ -897,41 +897,35 @@ static void comparison (lua_Type tag_less, lua_Type tag_equal, | |||
897 | } | 897 | } |
898 | 898 | ||
899 | 899 | ||
900 | void luaI_packarg (Object *firstelem, Object *arg) | 900 | static void adjust_varargs (StkId first_extra_arg) |
901 | { | 901 | { |
902 | int nvararg = (firstelem != NULL) ? top-firstelem : 0; | 902 | Object arg; |
903 | Object *firstelem = stack+first_extra_arg; | ||
904 | int nvararg = top-firstelem; | ||
903 | int i; | 905 | int i; |
904 | if (nvararg < 0) nvararg = 0; | 906 | if (nvararg < 0) nvararg = 0; |
905 | avalue(arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */ | 907 | avalue(&arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */ |
906 | tag(arg) = LUA_T_ARRAY; | 908 | tag(&arg) = LUA_T_ARRAY; |
907 | for (i=0; i<nvararg; i++) | 909 | for (i=0; i<nvararg; i++) { |
908 | { | ||
909 | Object index; | 910 | Object index; |
910 | tag(&index) = LUA_T_NUMBER; | 911 | tag(&index) = LUA_T_NUMBER; |
911 | nvalue(&index) = i+1; | 912 | nvalue(&index) = i+1; |
912 | *(lua_hashdefine(avalue(arg), &index)) = *(firstelem+i); | 913 | *(lua_hashdefine(avalue(&arg), &index)) = *(firstelem+i); |
913 | } | 914 | } |
914 | /* store counter in field "n" */ | 915 | /* store counter in field "n" */ { |
915 | { | ||
916 | Object index, extra; | 916 | Object index, extra; |
917 | tag(&index) = LUA_T_STRING; | 917 | tag(&index) = LUA_T_STRING; |
918 | tsvalue(&index) = lua_createstring("n"); | 918 | tsvalue(&index) = lua_createstring("n"); |
919 | tag(&extra) = LUA_T_NUMBER; | 919 | tag(&extra) = LUA_T_NUMBER; |
920 | nvalue(&extra) = nvararg; | 920 | nvalue(&extra) = nvararg; |
921 | *(lua_hashdefine(avalue(arg), &index)) = extra; | 921 | *(lua_hashdefine(avalue(&arg), &index)) = extra; |
922 | } | 922 | } |
923 | } | ||
924 | |||
925 | |||
926 | static void adjust_varargs (StkId first_extra_arg) | ||
927 | { | ||
928 | Object arg; | ||
929 | luaI_packarg(stack+first_extra_arg, &arg); | ||
930 | adjust_top(first_extra_arg); | 923 | adjust_top(first_extra_arg); |
931 | *top = arg; incr_top; | 924 | *top = arg; incr_top; |
932 | } | 925 | } |
933 | 926 | ||
934 | 927 | ||
928 | |||
935 | /* | 929 | /* |
936 | ** Execute the given opcode, until a RET. Parameters are between | 930 | ** Execute the given opcode, until a RET. Parameters are between |
937 | ** [stack+base,top). Returns n such that the the results are between | 931 | ** [stack+base,top). Returns n such that the the results are between |