aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/ldo.c b/ldo.c
index 912694bc..10e4c744 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.5 1997/10/24 17:17:24 roberto Exp roberto $ 2** $Id: ldo.c,v 1.6 1997/11/03 21:00:23 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -9,7 +9,6 @@
9#include <stdio.h> 9#include <stdio.h>
10#include <string.h> 10#include <string.h>
11 11
12#include "lbuiltin.h"
13#include "ldo.h" 12#include "ldo.h"
14#include "lfunc.h" 13#include "lfunc.h"
15#include "lgc.h" 14#include "lgc.h"
@@ -30,9 +29,7 @@
30#endif 29#endif
31 30
32 31
33static TObject initial_stack; 32struct Stack luaD_stack;
34
35struct Stack luaD_stack = {&initial_stack, &initial_stack, &initial_stack};
36 33
37 34
38struct C_Lua_Stack luaD_Cstack = {0, 0, 0}; 35struct C_Lua_Stack luaD_Cstack = {0, 0, 0};
@@ -64,24 +61,21 @@ static void initCfunc (TObject *o, lua_CFunction f)
64 61
65 62
66#define STACK_EXTRA 32 63#define STACK_EXTRA 32
64#define INIT_STACK_SIZE 32
65
67 66
68static void initstack (int n) 67void luaD_init (void)
69{ 68{
70 int maxstack = STACK_EXTRA+n; 69 luaD_stack.stack = luaM_newvector(INIT_STACK_SIZE, TObject);
71 luaD_stack.stack = luaM_newvector(maxstack, TObject);
72 luaD_stack.last = luaD_stack.stack+(maxstack-1);
73 luaD_stack.top = luaD_stack.stack; 70 luaD_stack.top = luaD_stack.stack;
74 *luaD_stack.stack = initial_stack; 71 luaD_stack.last = luaD_stack.stack+(INIT_STACK_SIZE-1);
75 luaB_predefine();
76 initCfunc(&luaD_errorim, stderrorim); 72 initCfunc(&luaD_errorim, stderrorim);
77} 73}
78 74
79 75
80void luaD_checkstack (int n) 76void luaD_checkstack (int n)
81{ 77{
82 if (luaD_stack.stack == &initial_stack) 78 if (luaD_stack.last-luaD_stack.top <= n) {
83 initstack(n);
84 else if (luaD_stack.last-luaD_stack.top <= n) {
85 static int limit = STACK_LIMIT; 79 static int limit = STACK_LIMIT;
86 StkId top = luaD_stack.top-luaD_stack.stack; 80 StkId top = luaD_stack.top-luaD_stack.stack;
87 int stacksize = (luaD_stack.last-luaD_stack.stack)+1+STACK_EXTRA+n; 81 int stacksize = (luaD_stack.last-luaD_stack.stack)+1+STACK_EXTRA+n;