private int ExecLen(Instruction i, int instructionPtr) { DynValue r = m_ValueStack.Pop().ToScalar(); if (r.Type == DataType.String) { m_ValueStack.Push(DynValue.NewNumber(r.String.Length)); } else { int ip = Internal_InvokeUnaryMetaMethod(r, "__len", instructionPtr); if (ip >= 0) { return(ip); } else if (r.Type == DataType.Table) { m_ValueStack.Push(DynValue.NewNumber(r.Table.Length)); } else { throw ScriptRuntimeException.LenOnInvalidType(r); } } return(instructionPtr); }