aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua.stx35
1 files changed, 16 insertions, 19 deletions
diff --git a/lua.stx b/lua.stx
index d0f832d7..1c9df40b 100644
--- a/lua.stx
+++ b/lua.stx
@@ -1,6 +1,6 @@
1%{ 1%{
2 2
3char *rcs_luastx = "$Id: lua.stx,v 3.21 1995/10/17 11:58:41 roberto Exp roberto $"; 3char *rcs_luastx = "$Id: lua.stx,v 3.22 1995/10/25 13:05:51 roberto Exp roberto $";
4 4
5#include <stdio.h> 5#include <stdio.h>
6#include <stdlib.h> 6#include <stdlib.h>
@@ -447,10 +447,10 @@ globalstat : stat sc
447 447
448function : functiontoken NAME body 448function : functiontoken NAME body
449 { 449 {
450 Word func = luaI_findsymbol($2); 450 code_byte(PUSHFUNCTION);
451 luaI_insertfunction($3); /* may take part in GC */ 451 code_code($3);
452 s_tag(func) = LUA_T_FUNCTION; 452 code_byte(STOREGLOBAL);
453 lua_table[func].object.value.tf = $3; 453 code_word(luaI_findsymbol($2));
454 $3->lineDefined = $1; 454 $3->lineDefined = $1;
455 $3->name1 = $2->ts.str; 455 $3->name1 = $2->ts.str;
456 $3->name2 = NULL; 456 $3->name2 = NULL;
@@ -458,23 +458,19 @@ function : functiontoken NAME body
458 } 458 }
459 ; 459 ;
460 460
461method : functiontoken NAME ':' NAME 461method : functiontoken NAME methkind NAME body
462 {
463 add_localvar(luaI_findsymbolbyname("self"));
464 }
465 body
466 { 462 {
467 /* assign function to table field */ 463 /* assign function to table field */
468 lua_pushvar(luaI_findsymbol($2)+1); 464 lua_pushvar(luaI_findsymbol($2)+1);
469 code_byte(PUSHSTRING); 465 code_byte(PUSHSTRING);
470 code_word(luaI_findconstant($4)); 466 code_word(luaI_findconstant($4));
471 code_byte(PUSHFUNCTION); 467 code_byte(PUSHFUNCTION);
472 code_code($6); 468 code_code($5);
473 code_byte(STOREINDEXED0); 469 code_byte(STOREINDEXED0);
474 $6->lineDefined = $1; 470 $5->lineDefined = $1;
475 $6->name1 = $4->ts.str; 471 $5->name1 = $4->ts.str;
476 $6->name2 = $2->ts.str; 472 $5->name2 = $2->ts.str;
477 $6->fileName = lua_parsedfile; 473 $5->fileName = lua_parsedfile;
478 } 474 }
479 ; 475 ;
480 476
@@ -493,6 +489,10 @@ functiontoken : FUNCTION
493 } 489 }
494 ; 490 ;
495 491
492methkind : ':' { add_localvar(luaI_findsymbolbyname("self")); }
493 | '.' /* no self */
494 ;
495
496body : '(' parlist ')' block END 496body : '(' parlist ')' block END
497 { 497 {
498 codereturn(); 498 codereturn();
@@ -581,10 +581,7 @@ PrepJump : /* empty */
581 code_word (0); 581 code_word (0);
582 } 582 }
583 583
584expr1 : expr 584expr1 : expr { adjust_functioncall($1, 1); }
585 {
586 adjust_functioncall($1, 1);
587 }
588 ; 585 ;
589 586
590expr : '(' expr ')' { $$ = $2; } 587expr : '(' expr ')' { $$ = $2; }