public static UnaryExpression Throw(Expression value, Type type) { ContractUtils.RequiresNotNull(type, nameof(type)); TypeUtils.ValidateType(type, nameof(type)); if (value != null) { RequiresCanRead(value, nameof(value)); if (value.Type.GetTypeInfo().IsValueType) throw Error.ArgumentMustNotHaveValueType(nameof(value)); } return new UnaryExpression(ExpressionType.Throw, value, type, null); }
internal MetaObject /*!*/ CreateMetaObject(MetaObjectBinder /*!*/ action, MetaObject /*!*/[] /*!*/ siteArgs) { var expr = _error ? Ast.Throw(_result) : _result; Restrictions restrictions; if (_condition != null) { var deferral = action.Defer(siteArgs); expr = Ast.Condition(_condition, AstUtils.Convert(expr, typeof(object)), deferral.Expression); restrictions = deferral.Restrictions; } else { restrictions = Restrictions.Empty; } if (_temps != null) { expr = Ast.Block(_temps, expr); } if (_restriction != null) { restrictions = restrictions.Merge(Restrictions.GetExpressionRestriction(_restriction)); } return(new MetaObject(expr, restrictions)); }