Ejemplo n.º 1
0
        public static byte[] lua_pushlstring(lua_State L, byte[] s, int len)
        {
            lua_lock(L);
            imp.luaC_checkGC(L);
            TString ts = imp.luaS_newlstr(L, s, len);

            imp.setsvalue2s(L, L.top, ts);
            imp.api_incr_top(L);
            lua_unlock(L);
            return(imp.getstr(ts));
        }
Ejemplo n.º 2
0
 public static string lua_pushstring(lua_State L, string s)
 {
     if (s == null)
     {
         lua_pushnil(L);
         return(null);
     }
     else
     {
         lua_lock(L);
         imp.luaC_checkGC(L);
         TString ts = imp.luaS_new(L, s);
         imp.setsvalue2s(L, L.top, ts);
         imp.api_incr_top(L);
         lua_unlock(L);
         return(imp.getsstr(ts));
     }
 }
Ejemplo n.º 3
0
        public static string aux_upvalue(TValue fi, int n, ref TValue val, ref CClosure owner, ref UpVal uv)
        {
            switch (ttype(fi))
            {
            case LUA_TCCL: {      /* C closure */
                CClosure f = clCvalue(fi);
                if ((1 <= n && n <= f.nupvalues) == false)
                {
                    return(null);
                }
                val = f.upvalue[n - 1];
                if (owner != null)
                {
                    owner = f;
                }
                return("");
            }

            case LUA_TLCL: {      /* Lua closure */
                LClosure f = clLvalue(fi);
                Proto    p = f.p;
                if ((1 <= n && n <= p.sizeupvalues) == false)
                {
                    return(null);
                }
                val = f.upvals[n - 1].v;
                if (uv != null)
                {
                    uv = f.upvals[n - 1];
                }
                TString name = p.upvalues[n - 1].name;
                return((name == null) ? "(*no name)" : byte2str(getstr(name)));
            }

            default: return(null);     /* not a closure */
            }
        }