diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-01-30 13:25:23 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-01-30 13:25:23 -0200 |
commit | 43382ce5a22838af182807b451a12c474e21da78 (patch) | |
tree | 44a6572d07f256494289e8efd6d96e6218950579 /opcode.c | |
parent | abfebf1e2110eb661e146f01ea82836727b3e794 (diff) | |
download | lua-43382ce5a22838af182807b451a12c474e21da78.tar.gz lua-43382ce5a22838af182807b451a12c474e21da78.tar.bz2 lua-43382ce5a22838af182807b451a12c474e21da78.zip |
new fallback "getglobal".
Diffstat (limited to 'opcode.c')
-rw-r--r-- | opcode.c | 21 |
1 files changed, 15 insertions, 6 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.52 1996/01/09 20:22:44 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.53 1996/01/23 18:43:07 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
@@ -374,6 +374,18 @@ static void storesubscript (void) | |||
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | static void getglobal (Word n) | ||
378 | { | ||
379 | *top = lua_table[n].object; | ||
380 | incr_top; | ||
381 | if (tag(top-1) == LUA_T_NIL) | ||
382 | { /* must call getglobal fallback */ | ||
383 | tag(top-1) = LUA_T_STRING; | ||
384 | tsvalue(top-1) = &lua_table[n].varname->ts; | ||
385 | callFB(FB_GETGLOBAL); | ||
386 | } | ||
387 | } | ||
388 | |||
377 | /* | 389 | /* |
378 | ** Traverse all objects on stack | 390 | ** Traverse all objects on stack |
379 | */ | 391 | */ |
@@ -704,10 +716,8 @@ int lua_lock (void) | |||
704 | */ | 716 | */ |
705 | lua_Object lua_getglobal (char *name) | 717 | lua_Object lua_getglobal (char *name) |
706 | { | 718 | { |
707 | Word n = luaI_findsymbolbyname(name); | ||
708 | adjustC(0); | 719 | adjustC(0); |
709 | *top = s_object(n); | 720 | getglobal(luaI_findsymbolbyname(name)); |
710 | incr_top; | ||
711 | CBase++; /* incorporate object in the stack */ | 721 | CBase++; /* incorporate object in the stack */ |
712 | return Ref(top-1); | 722 | return Ref(top-1); |
713 | } | 723 | } |
@@ -919,8 +929,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
919 | { | 929 | { |
920 | CodeWord code; | 930 | CodeWord code; |
921 | get_word(code,pc); | 931 | get_word(code,pc); |
922 | *top = s_object(code.w); | 932 | getglobal(code.w); |
923 | incr_top; | ||
924 | } | 933 | } |
925 | break; | 934 | break; |
926 | 935 | ||