示例#1
0
        public static LuaValue UnaryOp(OpCode opcode, LuaValue a)
        {
            switch (opcode)
            {
            case OpCode.UNM:
                if (a.ValueType == ValueType.Integer)
                {
                    return(new LuaValue(-a.ConvertToInt()));
                }
                else
                {
                    return(new LuaValue(-a.ConvertToFloat()));
                }

            case OpCode.BNOT:
                return(new LuaValue(~a.ConvertToInt()));

            case OpCode.NOT:
                return(new LuaValue(!a.ConvertToBool()));

            default:
                throw new Exception("invalid opcode " + opcode);
            }
        }