diff --git a/lbaselib.c b/lbaselib.c index 20fa6382..b6d4ce8e 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.64 2002/04/05 18:54:31 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.65 2002/04/09 19:46:56 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -432,302 +432,8 @@ static void base_open (lua_State *L) { } -/* -** {====================================================== -** Coroutine library -** ======================================================= -*/ - - -static int luaB_resume (lua_State *L) { - lua_State *co = (lua_State *)lua_getfrombox(L, lua_upvalueindex(1)); - lua_settop(L, 0); - if (lua_resume(L, co) != 0) - lua_error(L, "error running co-routine"); - return lua_gettop(L); -} - - - -static int gc_coroutine (lua_State *L) { - lua_State *co = (lua_State *)lua_getfrombox(L, 1); - lua_closethread(L, co); - return 0; -} - - -static int luaB_coroutine (lua_State *L) { - lua_State *NL; - int ref; - int i; - int n = lua_gettop(L); - luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, - "Lua function expected"); - NL = lua_newthread(L); - if (NL == NULL) lua_error(L, "unable to create new thread"); - /* move function and arguments from L to NL */ - for (i=0; i n+1) n = pos-1; - aux_setn(L, 1, n+1); /* t.n = n+1 */ - for (; n>=pos; n--) { - lua_rawgeti(L, 1, n); - lua_rawseti(L, 1, n+1); /* t[n+1] = t[n] */ - } - lua_pushvalue(L, v); - lua_rawseti(L, 1, pos); /* t[pos] = v */ - return 0; -} - - -static int luaB_tremove (lua_State *L) { - int pos, n; - luaL_check_type(L, 1, LUA_TTABLE); - n = lua_getn(L, 1); - pos = luaL_opt_int(L, 2, n); - if (n <= 0) return 0; /* table is `empty' */ - aux_setn(L, 1, n-1); /* t.n = n-1 */ - lua_rawgeti(L, 1, pos); /* result = t[pos] */ - for ( ;pos= P */ - while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { - if (i>u) lua_error(L, "invalid order function for sorting"); - lua_pop(L, 1); /* remove a[i] */ - } - /* repeat --j until a[j] <= P */ - while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { - if (j