| | | 1 | | namespace FSharp.Interop.Dlr |
| | | 2 | | |
| | | 3 | | open System |
| | | 4 | | open System.Diagnostics.CodeAnalysis |
| | | 5 | | open System.Runtime.CompilerServices |
| | | 6 | | |
| | | 7 | | // Every marker below is [<MethodImpl(MethodImplOptions.NoInlining)>]: the F# optimizer inlines |
| | | 8 | | // small functions across assemblies, and after inlining `ignore (target, name, value); outside …` |
| | | 9 | | // the arguments are dead, so a Release build stops capturing them in the block's closure - and |
| | | 10 | | // the translator then has nothing to read. The attribute keeps the call, and its arguments, intact. |
| | | 11 | | module internal Outside = |
| | | 12 | | let outside (name: string) : 'T = |
| | | 13 | | raise (InvalidOperationException(sprintf "'%s' is only meaningful inside dlr { }; it is inspected as a quotation |
| | | 14 | | |
| | | 15 | | open Outside |
| | | 16 | | |
| | | 17 | | [<Sealed; ExcludeFromCodeCoverage>] |
| | | 18 | | type Named<'T> private () = |
| | | 19 | | class end |
| | | 20 | | |
| | | 21 | | [<Sealed; ExcludeFromCodeCoverage>] |
| | | 22 | | type TypeArgs private () = |
| | | 23 | | class end |
| | | 24 | | |
| | | 25 | | [<Sealed; ExcludeFromCodeCoverage>] |
| | | 26 | | type OutArg private () = |
| | | 27 | | class end |
| | | 28 | | |
| | | 29 | | [<Sealed; ExcludeFromCodeCoverage>] |
| | | 30 | | type RefArg<'T> private () = |
| | | 31 | | class end |
| | | 32 | | |
| | | 33 | | [<AutoOpen>] |
| | | 34 | | module Operators = |
| | | 35 | | |
| | | 36 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 37 | | let ( ? ) (target: obj) (name: string) : 'TResult = ignore (target, name); outside "?" |
| | | 38 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 39 | | let ( ?<- ) (target: obj) (name: string) (value: 'TValue) : unit = ignore (target, name, value); outside "?<-" |
| | | 40 | | |
| | | 41 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 42 | | let ( ?%? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?%?" |
| | | 43 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 44 | | let ( ?*? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?*?" |
| | | 45 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 46 | | let ( ?+? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?+?" |
| | | 47 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 48 | | let ( ?-? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?-?" |
| | | 49 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 50 | | let ( ?/? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?/?" |
| | | 51 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 52 | | let ( ?&&&? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?&&&?" |
| | | 53 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 54 | | let ( ?|||? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?|||?" |
| | | 55 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 56 | | let ( ?^^^? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?^^^?" |
| | | 57 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 58 | | let ( ?<<<? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?<<<?" |
| | | 59 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 60 | | let ( ?>>>? ) (left: obj) (right: obj) : 'TResult = ignore (left, right); outside "?>>>?" |
| | | 61 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 62 | | let ( ?<=? ) (left: obj) (right: obj) : bool = ignore (left, right); outside "?<=?" |
| | | 63 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 64 | | let ( ?<>? ) (left: obj) (right: obj) : bool = ignore (left, right); outside "?<>?" |
| | | 65 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 66 | | let ( ?<? ) (left: obj) (right: obj) : bool = ignore (left, right); outside "?<?" |
| | | 67 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 68 | | let ( ?=? ) (left: obj) (right: obj) : bool = ignore (left, right); outside "?=?" |
| | | 69 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 70 | | let ( ?>? ) (left: obj) (right: obj) : bool = ignore (left, right); outside "?>?" |
| | | 71 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | | 72 | | let ( ?>=? ) (left: obj) (right: obj) : bool = ignore (left, right); outside "?>=?" |
| | | 73 | | |
| | | 74 | | [<Sealed; AbstractClass>] |
| | | 75 | | type Dlr = |
| | | 76 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 77 | | static member named (record: 'T) : Named<'T> = ignore record; outside "Dlr.named" |
| | | 78 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 79 | | static member namedOf (args: (string * obj) list) : Named<(string * obj) list> = ignore args; outside "Dlr.namedOf" |
| | | 80 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 81 | | static member argsOf (args: obj list) : Named<obj list> = ignore args; outside "Dlr.argsOf" |
| | 4 | 82 | | static member out with [<MethodImpl(MethodImplOptions.NoInlining)>] get () : OutArg = outside "Dlr.out" |
| | | 83 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 4 | 84 | | static member outAs<'T> () : OutArg = outside "Dlr.outAs" |
| | | 85 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 86 | | static member ref (variable: 'T) : RefArg<'T> = ignore variable; outside "Dlr.ref" |
| | | 87 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 88 | | static member item (indexes: 'TIndexes) (target: obj) : 'T = ignore (indexes, target); outside "Dlr.item" |
| | | 89 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 90 | | static member setItem (indexes: 'TIndexes) (value: 'TValue) (target: obj) : unit = ignore (indexes, value, target); |
| | | 91 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 4 | 92 | | static member typeArgs<'A> () : TypeArgs = outside "Dlr.typeArgs" |
| | | 93 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 4 | 94 | | static member typeArgs<'A, 'B> () : TypeArgs = outside "Dlr.typeArgs" |
| | | 95 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 4 | 96 | | static member typeArgs<'A, 'B, 'C> () : TypeArgs = outside "Dlr.typeArgs" |
| | | 97 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 4 | 98 | | static member typeArgs<'A, 'B, 'C, 'D> () : TypeArgs = outside "Dlr.typeArgs" |
| | | 99 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 100 | | static member typeArgsOf (types: System.Type list) : TypeArgs = ignore types; outside "Dlr.typeArgsOf" |
| | | 101 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 4 | 102 | | static member new'<'T> () : 'T = outside "Dlr.new'" |
| | | 103 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 104 | | static member new'<'T> (a: obj) : 'T = ignore (a); outside "Dlr.new'" |
| | | 105 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 106 | | static member new'<'T> (a: obj, b: obj) : 'T = ignore (a, b); outside "Dlr.new'" |
| | | 107 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 108 | | static member new'<'T> (a: obj, b: obj, c: obj) : 'T = ignore (a, b, c); outside "Dlr.new'" |
| | | 109 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 110 | | static member new'<'T> (a: obj, b: obj, c: obj, d: obj) : 'T = ignore (a, b, c, d); outside "Dlr.new'" |
| | | 111 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 112 | | static member new'<'T> (a: obj, b: obj, c: obj, d: obj, e: obj) : 'T = ignore (a, b, c, d, e); outside "Dlr.new'" |
| | | 113 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 114 | | static member new'<'T> (a: obj, b: obj, c: obj, d: obj, e: obj, f: obj) : 'T = ignore (a, b, c, d, e, f); outside "D |
| | | 115 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 116 | | static member new'<'T> (a: obj, b: obj, c: obj, d: obj, e: obj, f: obj, g: obj) : 'T = ignore (a, b, c, d, e, f, g); |
| | | 117 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 118 | | static member new'<'T> (a: obj, b: obj, c: obj, d: obj, e: obj, f: obj, g: obj, h: obj) : 'T = ignore (a, b, c, d, e |
| | | 119 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 120 | | static member cast<'T> (value: obj) : 'T = ignore value; outside "Dlr.cast" |
| | | 121 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 122 | | static member get (name: string) (target: obj) : 'T = ignore (name, target); outside "Dlr.get" |
| | | 123 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 124 | | static member call (target: obj) : 'T = ignore target; outside "Dlr.call" |
| | | 125 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 126 | | static member apply (args: 'TArgs) (target: obj) : 'T = ignore (args, target); outside "Dlr.apply" |
| | | 127 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 128 | | static member addAssign (name: string) (value: 'TValue) (target: obj) : unit = ignore (name, value, target); outside |
| | | 129 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 130 | | static member subtractAssign (name: string) (value: 'TValue) (target: obj) : unit = ignore (name, value, target); ou |
| | | 131 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 132 | | static member set (name: string) (value: 'TValue) (target: obj) : unit = ignore (name, value, target); outside "Dlr. |
| | | 133 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 134 | | static member invoke (name: string) (args: 'TArgs) (target: obj) : 'T = ignore (name, args, target); outside "Dlr.in |
| | | 135 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 136 | | static member implicit (value: obj) : 'T = ignore value; outside "Dlr.implicit" |
| | | 137 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 138 | | static member neg (value: obj) : 'TResult = ignore value; outside "Dlr.neg" |
| | | 139 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 140 | | static member not (value: obj) : 'TResult = ignore value; outside "Dlr.not" |
| | | 141 | | [<MethodImpl(MethodImplOptions.NoInlining)>] |
| | 6 | 142 | | static member complement (value: obj) : 'TResult = ignore value; outside "Dlr.complement" |
| | | 143 | | |
| | | 144 | | [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] |
| | | 145 | | module Dlr = |
| | | 146 | | [<Sealed; AbstractClass>] |
| | | 147 | | type Static<'T> = |
| | | 148 | | static member Overloads |
| | | 149 | | with [<MethodImpl(MethodImplOptions.NoInlining)>] get () : obj = outside "Dlr.Static<T>.Overloads" |