} // func GetResultExpression private static Expression UnaryOperationExpression(Lua runtime, Token tStart, ExpressionType op, Expression expr) { if (op != ExpressionType.ArrayLength) { expr = ConvertObjectExpression(runtime, tStart, expr); } return(SafeExpression(() => LuaEmit.UnaryOperationExpression(runtime, op, expr, expr.Type, true), tStart)); } // func UnaryOperationExpression
} // ctor public override DynamicMetaObject FallbackUnaryOperation(DynamicMetaObject target, DynamicMetaObject errorSuggestion) { // defer the target if (!target.HasValue) { return(Defer(target)); } if (target.Value == null) { return(errorSuggestion ?? new DynamicMetaObject( ThrowExpression(Properties.Resources.rsNilOperatorError), target.Restrictions.Merge(BindingRestrictions.GetInstanceRestriction(target.Expression, null)) )); } else { Expression expr; try { expr = EnsureType(LuaEmit.UnaryOperationExpression(lua, Operation, target.Expression, target.LimitType, false), this.ReturnType); } catch (LuaEmitException e) { if (errorSuggestion != null) { return(errorSuggestion); } expr = ThrowExpression(e.Message, this.ReturnType); } var restrictions = target.Restrictions.Merge(BindingRestrictions.GetTypeRestriction(target.Expression, target.LimitType)); return(new DynamicMetaObject(expr, restrictions)); } } // func FallbackUnaryOperation