mirror of https://github.com/rusefi/lua.git
new fallback "getglobal".
This commit is contained in:
parent
abfebf1e21
commit
43382ce5a2
|
@ -3,7 +3,7 @@
|
||||||
** TecCGraf - PUC-Rio
|
** TecCGraf - PUC-Rio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_fallback="$Id: fallback.c,v 1.16 1995/10/17 11:52:38 roberto Exp roberto $";
|
char *rcs_fallback="$Id: fallback.c,v 1.17 1995/10/17 14:30:05 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -36,8 +36,10 @@ struct FB luaI_fallBacks[] = {
|
||||||
{"concat", {LUA_T_CFUNCTION, {concatFB}}, 2, 1},
|
{"concat", {LUA_T_CFUNCTION, {concatFB}}, 2, 1},
|
||||||
{"settable", {LUA_T_CFUNCTION, {gettableFB}}, 3, 0},
|
{"settable", {LUA_T_CFUNCTION, {gettableFB}}, 3, 0},
|
||||||
{"gc", {LUA_T_CFUNCTION, {GDFB}}, 1, 0},
|
{"gc", {LUA_T_CFUNCTION, {GDFB}}, 1, 0},
|
||||||
{"function", {LUA_T_CFUNCTION, {funcFB}}, -1, -1}
|
{"function", {LUA_T_CFUNCTION, {funcFB}}, -1, -1},
|
||||||
/* no fixed number of params or results */
|
/* no fixed number of params or results */
|
||||||
|
{"getglobal", {LUA_T_CFUNCTION, {indexFB}}, 1, 1}
|
||||||
|
/* same default behavior of index FB */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define N_FB (sizeof(luaI_fallBacks)/sizeof(struct FB))
|
#define N_FB (sizeof(luaI_fallBacks)/sizeof(struct FB))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: fallback.h,v 1.9 1995/10/09 13:14:29 roberto Exp roberto $
|
** $Id: fallback.h,v 1.10 1995/10/17 11:52:38 roberto Exp roberto $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef fallback_h
|
#ifndef fallback_h
|
||||||
|
@ -23,6 +23,7 @@ extern struct FB {
|
||||||
#define FB_SETTABLE 6
|
#define FB_SETTABLE 6
|
||||||
#define FB_GC 7
|
#define FB_GC 7
|
||||||
#define FB_FUNCTION 8
|
#define FB_FUNCTION 8
|
||||||
|
#define FB_GETGLOBAL 9
|
||||||
|
|
||||||
void luaI_setfallback (void);
|
void luaI_setfallback (void);
|
||||||
int luaI_lock (Object *object);
|
int luaI_lock (Object *object);
|
||||||
|
|
21
opcode.c
21
opcode.c
|
@ -3,7 +3,7 @@
|
||||||
** TecCGraf - PUC-Rio
|
** TecCGraf - PUC-Rio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_opcode="$Id: opcode.c,v 3.52 1996/01/09 20:22:44 roberto Exp roberto $";
|
char *rcs_opcode="$Id: opcode.c,v 3.53 1996/01/23 18:43:07 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -374,6 +374,18 @@ static void storesubscript (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void getglobal (Word n)
|
||||||
|
{
|
||||||
|
*top = lua_table[n].object;
|
||||||
|
incr_top;
|
||||||
|
if (tag(top-1) == LUA_T_NIL)
|
||||||
|
{ /* must call getglobal fallback */
|
||||||
|
tag(top-1) = LUA_T_STRING;
|
||||||
|
tsvalue(top-1) = &lua_table[n].varname->ts;
|
||||||
|
callFB(FB_GETGLOBAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Traverse all objects on stack
|
** Traverse all objects on stack
|
||||||
*/
|
*/
|
||||||
|
@ -704,10 +716,8 @@ int lua_lock (void)
|
||||||
*/
|
*/
|
||||||
lua_Object lua_getglobal (char *name)
|
lua_Object lua_getglobal (char *name)
|
||||||
{
|
{
|
||||||
Word n = luaI_findsymbolbyname(name);
|
|
||||||
adjustC(0);
|
adjustC(0);
|
||||||
*top = s_object(n);
|
getglobal(luaI_findsymbolbyname(name));
|
||||||
incr_top;
|
|
||||||
CBase++; /* incorporate object in the stack */
|
CBase++; /* incorporate object in the stack */
|
||||||
return Ref(top-1);
|
return Ref(top-1);
|
||||||
}
|
}
|
||||||
|
@ -919,8 +929,7 @@ static StkId lua_execute (Byte *pc, StkId base)
|
||||||
{
|
{
|
||||||
CodeWord code;
|
CodeWord code;
|
||||||
get_word(code,pc);
|
get_word(code,pc);
|
||||||
*top = s_object(code.w);
|
getglobal(code.w);
|
||||||
incr_top;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue