private int ExecIndexSet(Instruction i, int instructionPtr)
        {
            int nestedMetaOps = 100;             // sanity check, to avoid potential infinite loop here

            // stack: vals.. - base - index
            DynValue idx   = i.Value ?? m_ValueStack.Pop().ToScalar();
            DynValue obj   = m_ValueStack.Pop().ToScalar();
            var      value = GetStoreValue(i);
            DynValue h     = null;

            while (nestedMetaOps > 0)
            {
                --nestedMetaOps;

                if (obj.Type == DataType.Table)
                {
                    if (!obj.Table.Get(idx).IsNil())
                    {
                        obj.Table.Set(idx, value);
                        return(instructionPtr);
                    }

                    h = GetMetamethod(obj, "__newindex");

                    if (h == null || h.IsNil())
                    {
                        obj.Table.Set(idx, value);
                        return(instructionPtr);
                    }
                }
                else if (obj.Type == DataType.UserData)
                {
                    UserData ud = obj.UserData;

                    if (!ud.Descriptor.SetIndex(this.GetScript(), ud.Object, idx, value))
                    {
                        throw ScriptRuntimeException.UserDataMissingField(ud.Descriptor.Name, idx.String);
                    }

                    return(instructionPtr);
                }
                else
                {
                    h = GetMetamethod(obj, "__newindex");

                    if (h == null || h.IsNil())
                    {
                        throw ScriptRuntimeException.IndexType(obj);
                    }
                }

                if (h.Type == DataType.Function || h.Type == DataType.ClrFunction)
                {
                    m_ValueStack.Push(h);
                    m_ValueStack.Push(obj);
                    m_ValueStack.Push(idx);
                    m_ValueStack.Push(value);
                    return(Internal_ExecCall(3, instructionPtr));
                }
                else
                {
                    obj = h;
                    h   = null;
                }
            }
            throw ScriptRuntimeException.LoopInNewIndex();
        }