misc/liblua/lstate.c
author nemo
Thu, 02 Dec 2010 20:40:30 -0500
changeset 4453 15a483b2558a
parent 3697 d5b30d6373fc
child 10017 de822cd3df3a
permissions -rw-r--r--
add visual gear registration
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     1
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     2
** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     3
** Global State
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     4
** See Copyright Notice in lua.h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     5
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     6
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     7
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     8
#include <stddef.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     9
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    10
#define lstate_c
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    11
#define LUA_CORE
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    12
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    13
#include "lua.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    14
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    15
#include "ldebug.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    16
#include "ldo.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    17
#include "lfunc.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    18
#include "lgc.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    19
#include "llex.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    20
#include "lmem.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    21
#include "lstate.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    22
#include "lstring.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    23
#include "ltable.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    24
#include "ltm.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    25
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    26
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    27
#define state_size(x)	(sizeof(x) + LUAI_EXTRASPACE)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    28
#define fromstate(l)	(cast(lu_byte *, (l)) - LUAI_EXTRASPACE)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    29
#define tostate(l)   (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    30
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    31
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    32
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    33
** Main thread combines a thread state and the global state
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    34
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    35
typedef struct LG {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    36
  lua_State l;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    37
  global_State g;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    38
} LG;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 2812
diff changeset
    39
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    40
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    41
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    42
static void stack_init (lua_State *L1, lua_State *L) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    43
  /* initialize CallInfo array */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    44
  L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    45
  L1->ci = L1->base_ci;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    46
  L1->size_ci = BASIC_CI_SIZE;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    47
  L1->end_ci = L1->base_ci + L1->size_ci - 1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    48
  /* initialize stack array */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    49
  L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    50
  L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    51
  L1->top = L1->stack;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    52
  L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    53
  /* initialize first ci */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    54
  L1->ci->func = L1->top;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    55
  setnilvalue(L1->top++);  /* `function' entry for this `ci' */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    56
  L1->base = L1->ci->base = L1->top;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    57
  L1->ci->top = L1->top + LUA_MINSTACK;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    58
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    59
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    60
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    61
static void freestack (lua_State *L, lua_State *L1) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    62
  luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    63
  luaM_freearray(L, L1->stack, L1->stacksize, TValue);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    64
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    65
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    66
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    67
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    68
** open parts that may cause memory-allocation errors
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    69
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    70
static void f_luaopen (lua_State *L, void *ud) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    71
  global_State *g = G(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    72
  UNUSED(ud);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    73
  stack_init(L, L);  /* init stack */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    74
  sethvalue(L, gt(L), luaH_new(L, 0, 2));  /* table of globals */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    75
  sethvalue(L, registry(L), luaH_new(L, 0, 2));  /* registry */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    76
  luaS_resize(L, MINSTRTABSIZE);  /* initial size of string table */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    77
  luaT_init(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    78
  luaX_init(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    79
  luaS_fix(luaS_newliteral(L, MEMERRMSG));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    80
  g->GCthreshold = 4*g->totalbytes;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    81
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    82
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    83
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    84
static void preinit_state (lua_State *L, global_State *g) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    85
  G(L) = g;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    86
  L->stack = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    87
  L->stacksize = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    88
  L->errorJmp = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    89
  L->hook = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    90
  L->hookmask = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    91
  L->basehookcount = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    92
  L->allowhook = 1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    93
  resethookcount(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    94
  L->openupval = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    95
  L->size_ci = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    96
  L->nCcalls = L->baseCcalls = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    97
  L->status = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    98
  L->base_ci = L->ci = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    99
  L->savedpc = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   100
  L->errfunc = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   101
  setnilvalue(gt(L));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   102
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   103
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   104
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   105
static void close_state (lua_State *L) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   106
  global_State *g = G(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   107
  luaF_close(L, L->stack);  /* close all upvalues for this thread */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   108
  luaC_freeall(L);  /* collect all objects */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   109
  lua_assert(g->rootgc == obj2gco(L));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   110
  lua_assert(g->strt.nuse == 0);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   111
  luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   112
  luaZ_freebuffer(L, &g->buff);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   113
  freestack(L, L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   114
  lua_assert(g->totalbytes == sizeof(LG));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   115
  (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   116
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   117
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   118
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   119
lua_State *luaE_newthread (lua_State *L) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   120
  lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   121
  luaC_link(L, obj2gco(L1), LUA_TTHREAD);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   122
  preinit_state(L1, G(L));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   123
  stack_init(L1, L);  /* init stack */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   124
  setobj2n(L, gt(L1), gt(L));  /* share table of globals */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   125
  L1->hookmask = L->hookmask;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   126
  L1->basehookcount = L->basehookcount;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   127
  L1->hook = L->hook;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   128
  resethookcount(L1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   129
  lua_assert(iswhite(obj2gco(L1)));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   130
  return L1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   131
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   132
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   133
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   134
void luaE_freethread (lua_State *L, lua_State *L1) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   135
  luaF_close(L1, L1->stack);  /* close all upvalues for this thread */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   136
  lua_assert(L1->openupval == NULL);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   137
  luai_userstatefree(L1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   138
  freestack(L, L1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   139
  luaM_freemem(L, fromstate(L1), state_size(lua_State));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   140
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   141
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   142
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   143
LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   144
  int i;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   145
  lua_State *L;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   146
  global_State *g;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   147
  void *l = (*f)(ud, NULL, 0, state_size(LG));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   148
  if (l == NULL) return NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   149
  L = tostate(l);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   150
  g = &((LG *)L)->g;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   151
  L->next = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   152
  L->tt = LUA_TTHREAD;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   153
  g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   154
  L->marked = luaC_white(g);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   155
  set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   156
  preinit_state(L, g);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   157
  g->frealloc = f;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   158
  g->ud = ud;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   159
  g->mainthread = L;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   160
  g->uvhead.u.l.prev = &g->uvhead;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   161
  g->uvhead.u.l.next = &g->uvhead;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   162
  g->GCthreshold = 0;  /* mark it as unfinished state */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   163
  g->strt.size = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   164
  g->strt.nuse = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   165
  g->strt.hash = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   166
  setnilvalue(registry(L));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   167
  luaZ_initbuffer(L, &g->buff);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   168
  g->panic = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   169
  g->gcstate = GCSpause;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   170
  g->rootgc = obj2gco(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   171
  g->sweepstrgc = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   172
  g->sweepgc = &g->rootgc;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   173
  g->gray = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   174
  g->grayagain = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   175
  g->weak = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   176
  g->tmudata = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   177
  g->totalbytes = sizeof(LG);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   178
  g->gcpause = LUAI_GCPAUSE;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   179
  g->gcstepmul = LUAI_GCMUL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   180
  g->gcdept = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   181
  for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   182
  if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   183
    /* memory allocation error: free partial state */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   184
    close_state(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   185
    L = NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   186
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   187
  else
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   188
    luai_userstateopen(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   189
  return L;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   190
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   191
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   192
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   193
static void callallgcTM (lua_State *L, void *ud) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   194
  UNUSED(ud);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   195
  luaC_callGCTM(L);  /* call GC metamethods for all udata */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   196
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   197
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   198
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   199
LUA_API void lua_close (lua_State *L) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   200
  L = G(L)->mainthread;  /* only the main thread can be closed */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   201
  lua_lock(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   202
  luaF_close(L, L->stack);  /* close all upvalues for this thread */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   203
  luaC_separateudata(L, 1);  /* separate udata that have GC metamethods */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   204
  L->errfunc = 0;  /* no error function during GC metamethods */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   205
  do {  /* repeat until no more errors */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   206
    L->ci = L->base_ci;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   207
    L->base = L->top = L->ci->base;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   208
    L->nCcalls = L->baseCcalls = 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   209
  } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   210
  lua_assert(G(L)->tmudata == NULL);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   211
  luai_userstateclose(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   212
  close_state(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   213
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   214