Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array postfix notation in fsharp core api #16564

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/FSharp.Core/Linq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ module LeafExpressionConverter =
|> System.Reflection.MethodInfo.GetMethodFromHandle
:?> MethodInfo

let SubstHelperRaw (q:Expr, x:Var[], y:obj[]) : Expr =
let SubstHelperRaw (q:Expr, x:Var array, y:obj array) : Expr =
let d = Map.ofArray (Array.zip x y)
q.Substitute(fun v -> v |> d.TryFind |> Option.map (fun x -> Expr.Value (x, v.Type)))

let SubstHelper<'T> (q:Expr, x:Var[], y:obj[]) : Expr<'T> =
let SubstHelper<'T> (q:Expr, x:Var array, y:obj array) : Expr<'T> =
SubstHelperRaw(q, x, y) |> Expr.Cast

let showAll =
Expand Down Expand Up @@ -390,15 +390,15 @@ module LeafExpressionConverter =
let (|NewAnonymousObjectHelperQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (NewAnonymousObjectHelper))
let (|ArrayLookupQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> LanguagePrimitives.IntrinsicFunctions.GetArray x y))

//let (|ArrayAssignQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun -> LanguagePrimitives.IntrinsicFunctions.SetArray : int[] -> int -> int -> unit))
//let (|ArrayAssignQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun -> LanguagePrimitives.IntrinsicFunctions.SetArray : int array -> int -> int -> unit))
//let (|ArrayTypeQ|_|) (ty:System.Type) = if ty.IsArray && ty.GetArrayRank() = 1 then Some (ty.GetElementType()) else None
let substHelperMeth =
methodhandleof (fun (x:Expr, y:Var[], z:obj[]) -> SubstHelper<obj> (x, y, z))
methodhandleof (fun (x:Expr, y:Var array, z:obj array) -> SubstHelper<obj> (x, y, z))
|> System.Reflection.MethodInfo.GetMethodFromHandle
:?> MethodInfo

let substHelperRawMeth =
methodhandleof (fun (x:Expr, y:Var[], z:obj[]) -> SubstHelperRaw (x, y, z))
methodhandleof (fun (x:Expr, y:Var array, z:obj array) -> SubstHelperRaw (x, y, z))
|> System.Reflection.MethodInfo.GetMethodFromHandle
:?> MethodInfo

Expand Down Expand Up @@ -737,7 +737,7 @@ module LeafExpressionConverter =
else
Reflection.FSharpType.MakeTupleType(argTypes)
let argsP = ConvExprsToLinq env args
let rec build ty (argsP: Expression[]) =
let rec build ty (argsP: Expression array) =
match Reflection.FSharpValue.PreComputeTupleConstructorInfo ty with
| ctorInfo, None -> Expression.New(ctorInfo, argsP) |> asExpr
| ctorInfo, Some (nestedTy) ->
Expand Down Expand Up @@ -879,7 +879,7 @@ module LeafExpressionConverter =
| None ->
null

and ConvExprsToLinq env es : Expression[] =
and ConvExprsToLinq env es : Expression array =
es |> List.map (ConvExprToLinqInContext env) |> Array.ofList

and ConvVarToLinq (v: Var) =
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Core/Linq.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ module LeafExpressionConverter =
/// </summary>
///
/// <example-tbd></example-tbd>
val SubstHelper: Expr * Var[] * obj[] -> Expr<'T>
val SubstHelper: Expr * Var array * obj array -> Expr<'T>

/// <summary>
/// A runtime helper used to evaluate nested quotation literals.
/// </summary>
///
/// <example-tbd></example-tbd>
val SubstHelperRaw: Expr * Var[] * obj[] -> Expr
val SubstHelperRaw: Expr * Var array * obj array -> Expr

val internal (|SpecificCallToMethod|_|):
System.RuntimeMethodHandle -> (Expr -> (Expr option * Reflection.MethodInfo * Expr list) option)
Loading
Loading