Ejemplo n.º 1
0
    public void PushCSharpClosure(CSharpFunction f, int n)
    {
        var closure = new LuaClosure(f, n);

        for (int i = n - 1; i >= 0; i--)
        {
            var val = LuaStack.Pop();
            closure.Upvals[i] = LuaUpValue.CreateClosed(val);
        }
        LuaStack.Push(closure);
    }
Ejemplo n.º 2
0
    public ErrState Load(byte[] chunk, string chunkName, string mode)
    {
        var proto = Prototype.Undump(chunk);
        var c     = new LuaClosure(proto);

        LuaStack.Push(c);
        if (proto.UpValues != null && proto.UpValues.Length > 0)
        {
            var env = Registry.Get(Consts.LUA_RIDX_GLOBALS);
            c.Upvals[0] = LuaUpValue.CreateClosed(env);
        }
        return(ErrState.Ok);
    }