Ejemplo n.º 1
0
        }         // func SafeExpression

        private static Expression ConvertObjectExpression(Lua runtime, Token tStart, Expression expr, bool lConvertToObject = false)
        {
            if (expr.Type == typeof(LuaResult))
            {
                return(GetResultExpression(runtime, tStart, expr, 0));
            }
            else if (expr.Type == typeof(object) && expr.NodeType == ExpressionType.Dynamic)
            {
                DynamicExpression exprDynamic = (DynamicExpression)expr;
                if (exprDynamic.Binder is InvokeBinder || exprDynamic.Binder is InvokeMemberBinder)
                {
                    return(DynamicExpression.Dynamic(runtime.GetConvertBinder(typeof(object)), typeof(object), expr));
                }
                else if (lConvertToObject)
                {
                    return(Lua.EnsureType(expr, typeof(object)));
                }
                else
                {
                    return(expr);
                }
            }
            else if (lConvertToObject)
            {
                return(Lua.EnsureType(expr, typeof(object)));
            }
            else
            {
                return(expr);
            }
        }         // func ConvertObjectExpression