AGS.Plugin.Lua.LuaCodeDom.LuaExpression.CastTo C# (CSharp) 메소드

CastTo() 공개 메소드

public CastTo ( LuaValueType newType ) : LuaExpression
newType LuaValueType
리턴 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;
            }
        }