Browse Source

opcode PUSHSELF has a parameter that indicates the method to be called

Roberto Ierusalimschy 31 years ago
parent
commit
ce4fb88b34
2 changed files with 16 additions and 6 deletions
  1. 11 4
      lua.stx
  2. 5 2
      opcode.c

+ 11 - 4
lua.stx

@@ -1,6 +1,6 @@
 %{
 %{
 
 
-char *rcs_luastx = "$Id: lua.stx,v 3.11 1994/11/23 14:39:52 roberto Stab roberto $";
+char *rcs_luastx = "$Id: lua.stx,v 3.12 1994/11/25 19:24:57 roberto Exp $";
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
@@ -418,9 +418,8 @@ functioncall : funcvalue funcParams
 funcvalue    : varexp { $$ = 0; }
 funcvalue    : varexp { $$ = 0; }
 	     | varexp ':' NAME 
 	     | varexp ':' NAME 
 	     { 
 	     { 
-	       code_byte(PUSHSTRING);
-	       code_word(luaI_findconstant($3));
                code_byte(PUSHSELF); 
                code_byte(PUSHSELF); 
+	       code_word(luaI_findconstant($3));
                $$ = 1;
                $$ = 1;
 	     }
 	     }
 	     ;
 	     ;
@@ -830,7 +829,15 @@ static void PrintCode (Byte *code, Byte *end)
     			 printf ("%d    STOREGLOBAL   %d\n", n, c.w);
     			 printf ("%d    STOREGLOBAL   %d\n", n, c.w);
 			}
 			}
    			break;
    			break;
-   case PUSHSELF: 	 printf ("%d    PUSHSELF\n", (p++)-code); break;
+   case PUSHSELF:
+    			{
+			 CodeWord c;
+			 int n = p-code;
+			 p++;
+			 get_word(c,p);
+    			 printf ("%d    PUSHSELF   %d\n", n, c.w);
+			}
+			break;
    case STOREINDEXED0:  printf ("%d    STOREINDEXED0\n", (p++)-code); break;
    case STOREINDEXED0:  printf ("%d    STOREINDEXED0\n", (p++)-code); break;
    case STOREINDEXED:   printf ("%d    STOREINDEXED   %d\n", p-code, *(++p));
    case STOREINDEXED:   printf ("%d    STOREINDEXED   %d\n", p-code, *(++p));
     			p++;
     			p++;

+ 5 - 2
opcode.c

@@ -3,7 +3,7 @@
 ** TecCGraf - PUC-Rio
 ** TecCGraf - PUC-Rio
 */
 */
 
 
-char *rcs_opcode="$Id: opcode.c,v 3.22 1994/11/23 14:31:11 roberto Stab roberto $";
+char *rcs_opcode="$Id: opcode.c,v 3.23 1994/11/30 21:20:37 roberto Exp roberto $";
 
 
 #include <setjmp.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <stdio.h>
@@ -803,7 +803,10 @@ static int lua_execute (Byte *pc, int base)
 
 
    case PUSHSELF:
    case PUSHSELF:
    {
    {
-     Object receiver = *(top-2);
+     Object receiver = *(top-1);
+     CodeWord code;
+     get_word(code,pc);
+     tag(top) = LUA_T_STRING; tsvalue(top++) = lua_constant[code.w];
      pushsubscript();
      pushsubscript();
      *(top++) = receiver;
      *(top++) = receiver;
      break;
      break;