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;
}
}