public void Concat(LuaState luaState, int number) { if (number == 0) { luaState.Push(new LuaValue("", LuaValueType.String)); } else if (number >= 2) { while (number > 1) { string str1 = null; string str2 = null; if (luaState.Get(luaState.AbsIndex(-1)).ToString(ref str1) && luaState.Get(luaState.AbsIndex(-2)).ToString(ref str2)) { luaState.Pop(2); luaState.Push(new LuaValue(str1 + str2, LuaValueType.String)); --number; continue; } else { LuaValue result = null; try { var b = luaState.Pop(); var a = luaState.Pop(); if (luaState.CallMetaFunc(a, b, GetMetaFuncName(TokenType.Len), out result)) { luaState.Push(result); } } catch { throw new Exception("该类型的变量无法进行拼接"); } } } } else { throw new Exception("该类型的变量无法进行拼接"); } }
/// <summary> /// 连续为寄存器置n个nil值,寄存器起始索引为a,数量为b,c无效 /// </summary> /// <param name="i"></param> public void LoadNil(Instruction i) { int a = 0, b = 0, c = 0; i.ABC(ref a, ref b, ref c); luaState.Push(new LuaValue()); for (int j = a + 1; j <= a + b; j++) { luaState.CopyTo(-1, j); } luaState.Pop(1); }