AGS.Plugin.Lua.LuaCodeDom.LuaExpression.CastTo C# (CSharp) Method

CastTo() public method

public CastTo ( LuaValueType newType ) : LuaExpression
newType LuaValueType
return LuaExpression
        public virtual LuaExpression CastTo(LuaValueType newType)
        {
            switch (newType)
            {
                case LuaValueType.Boolean:
                    switch (GetType())
                    {
                        case LuaValueType.Number:
                            return new LuaExpression.BinOp(
                                LuaBinaryOperatorType.IsNotEqualTo,
                                this,
                                new LuaExpression.NumberLiteral(0));
                        default: return this;
                    }
                case LuaValueType.Number:
                    switch (GetType())
                    {
                        case LuaValueType.Boolean:
                            return new LuaExpression.BinOp(
                                LuaBinaryOperatorType.LogicalOr,
                                new LuaExpression.BinOp(
                                    LuaBinaryOperatorType.LogicalAnd,
                                    this,
                                    new LuaExpression.NumberLiteral(1)),
                                new LuaExpression.NumberLiteral(0));
                        default: return this;
                    }
                default: return this;
            }
        }