aboutsummaryrefslogtreecommitdiff
path: root/lbuiltin.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbuiltin.c')
-rw-r--r--lbuiltin.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/lbuiltin.c b/lbuiltin.c
index b9d81621..36432add 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.6 1997/11/04 15:27:53 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.7 1997/11/07 18:19:13 roberto Exp roberto $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -15,6 +15,7 @@
15#include "lfunc.h" 15#include "lfunc.h"
16#include "lmem.h" 16#include "lmem.h"
17#include "lobject.h" 17#include "lobject.h"
18#include "lstate.h"
18#include "lstring.h" 19#include "lstring.h"
19#include "ltable.h" 20#include "ltable.h"
20#include "ltm.h" 21#include "ltm.h"
@@ -51,7 +52,7 @@ static void nextvar (void)
51 TObject *o = luaA_Address(luaL_nonnullarg(1)); 52 TObject *o = luaA_Address(luaL_nonnullarg(1));
52 TaggedString *g; 53 TaggedString *g;
53 if (ttype(o) == LUA_T_NIL) 54 if (ttype(o) == LUA_T_NIL)
54 g = (TaggedString *)luaS_root.next; 55 g = (TaggedString *)L->rootglobal.next;
55 else { 56 else {
56 luaL_arg_check(ttype(o) == LUA_T_STRING, 1, "variable name expected"); 57 luaL_arg_check(ttype(o) == LUA_T_STRING, 1, "variable name expected");
57 g = tsvalue(o); 58 g = tsvalue(o);
@@ -72,21 +73,21 @@ static void foreachvar (void)
72{ 73{
73 TObject f = *luaA_Address(functionarg(1)); 74 TObject f = *luaA_Address(functionarg(1));
74 GCnode *g; 75 GCnode *g;
75 StkId name = luaD_Cstack.base++; /* place to keep var name (to avoid GC) */ 76 StkId name = L->Cstack.base++; /* place to keep var name (to avoid GC) */
76 ttype(luaD_stack.stack+name) = LUA_T_NIL; 77 ttype(L->stack.stack+name) = LUA_T_NIL;
77 luaD_stack.top++; 78 L->stack.top++;
78 for (g = luaS_root.next; g; g = g->next) { 79 for (g = L->rootglobal.next; g; g = g->next) {
79 TaggedString *s = (TaggedString *)g; 80 TaggedString *s = (TaggedString *)g;
80 if (s->u.globalval.ttype != LUA_T_NIL) { 81 if (s->u.globalval.ttype != LUA_T_NIL) {
81 ttype(luaD_stack.stack+name) = LUA_T_STRING; 82 ttype(L->stack.stack+name) = LUA_T_STRING;
82 tsvalue(luaD_stack.stack+name) = s; /* keep s on stack to avoid GC */ 83 tsvalue(L->stack.stack+name) = s; /* keep s on stack to avoid GC */
83 luaA_pushobject(&f); 84 luaA_pushobject(&f);
84 pushstring(s); 85 pushstring(s);
85 luaA_pushobject(&s->u.globalval); 86 luaA_pushobject(&s->u.globalval);
86 luaD_call((luaD_stack.top-luaD_stack.stack)-2, 1); 87 luaD_call((L->stack.top-L->stack.stack)-2, 1);
87 if (ttype(luaD_stack.top-1) != LUA_T_NIL) 88 if (ttype(L->stack.top-1) != LUA_T_NIL)
88 return; 89 return;
89 luaD_stack.top--; 90 L->stack.top--;
90 } 91 }
91 } 92 }
92} 93}
@@ -115,10 +116,10 @@ static void foreach (void)
115 luaA_pushobject(&f); 116 luaA_pushobject(&f);
116 luaA_pushobject(ref(nd)); 117 luaA_pushobject(ref(nd));
117 luaA_pushobject(val(nd)); 118 luaA_pushobject(val(nd));
118 luaD_call((luaD_stack.top-luaD_stack.stack)-2, 1); 119 luaD_call((L->stack.top-L->stack.stack)-2, 1);
119 if (ttype(luaD_stack.top-1) != LUA_T_NIL) 120 if (ttype(L->stack.top-1) != LUA_T_NIL)
120 return; 121 return;
121 luaD_stack.top--; 122 L->stack.top--;
122 } 123 }
123 } 124 }
124} 125}