Skip to content

Commit

Permalink
update tpsdk
Browse files Browse the repository at this point in the history
add sig file
  • Loading branch information
kevmal committed Nov 4, 2023
1 parent 9127f98 commit 254fb4d
Show file tree
Hide file tree
Showing 6 changed files with 2,570 additions and 17,909 deletions.
6 changes: 3 additions & 3 deletions Qit.Tests/Library1.fs
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,15 @@ module Basic =
match <@@ parameters @@> with
| Patterns.NewTuple(exprs) ->
let ptypes = exprs |> List.map (fun x -> x.Type) |> List.toArray
match tp.GetConstructor(bindAll,null,ptypes,null) with
match tp.GetConstructor(BindingFlags.All,null,ptypes,null) with
| null -> failwithf "Ctor with paremters (%s) not found in %s" (ptypes |> Array.map (fun x -> x.Name) |> String.concat ",") tp.Name
| m -> Expr.NewObject(m, exprs)
| Quote <@@()@@> ->
match tp.GetConstructor(bindAll,null,[||],null) with
match tp.GetConstructor(BindingFlags.All,null,[||],null) with
| null -> failwithf "Ctor with no paremters not found in %s" tp.Name
| m -> Expr.NewObject(m, [])
| expr ->
match tp.GetConstructor(bindAll,null,[|expr.Type|],null) with
match tp.GetConstructor(BindingFlags.All,null,[|expr.Type|],null) with
| null -> failwithf "Ctor with paremters (%s) not found in %s" expr.Type.Name tp.Name
| m -> Expr.NewObject(m, [expr])
RType(tp,e)
Expand Down
12 changes: 10 additions & 2 deletions Qit/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ module Reflection =
sprintf "%s<%s>" name (targs |> String.concat ", ")
else
t.FullName


[<AutoOpen>]
module ReflectionExt =
type BindingFlags with
static member All = BindingFlags.DeclaredOnly ||| BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Static ||| BindingFlags.Instance

module ReflectionPatterns =
/// <summary>
/// Active pattern for decomposing an F# function type into its argument types and return type.
Expand Down Expand Up @@ -1288,7 +1293,10 @@ module Quote =
ProvidedMethod("meth", [], typeof<'a>, invokeCode = f q, isStatic = true), (fun mt -> Expr.Lambda(Var("", typeof<unit>), Expr.Call(mt, [])))
t.AddMember m
asm.AddTypes [t]
let ctx = ProvidedTypesContext(refs |> Seq.filter (fun x -> not x.IsDynamic) |> Seq.map (fun x -> x.Location) |> Seq.toList, [], refs |> Seq.toList)//[System.Reflection.Assembly.GetExecutingAssembly()])
let rt = typeof<int>.Assembly
let cfg = CompilerServices.TypeProviderConfig(rt.GetType >> isNull >> not)
cfg.ReferencedAssemblies <- refs |> Seq.filter (fun x -> not x.IsDynamic) |> Seq.map (fun x -> x.Location) |> Seq.toArray
let ctx = ProvidedTypesContext(cfg, [], refs |> Seq.toList)//[System.Reflection.Assembly.GetExecutingAssembly()])
let t2 = ctx.ConvertSourceProvidedTypeDefinitionToTarget(t)
let compiler = AssemblyCompiler(t2.Assembly :?> _, ctx)
let bytes = compiler.Compile(false)
Expand Down
Loading

0 comments on commit 254fb4d

Please sign in to comment.