Skip to content

Commit

Permalink
Fix #89 - nested quotation literals
Browse files Browse the repository at this point in the history
closes #142
  • Loading branch information
dsyme authored and latkin committed Jan 28, 2015
1 parent f09c852 commit 0a23b20
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 23 deletions.
15 changes: 15 additions & 0 deletions src/fsharp/FSharp.Core.Unittests/SurfaceArea.4.0.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2795,14 +2795,17 @@ Microsoft.FSharp.Core.ReferenceEqualityAttribute: System.String ToString()
Microsoft.FSharp.Core.ReferenceEqualityAttribute: System.Type GetType()
Microsoft.FSharp.Core.ReferenceEqualityAttribute: Void .ctor()
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: Boolean Equals(System.Object)
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: Boolean IncludeValue
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: Boolean IsDefaultAttribute()
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: Boolean Match(System.Object)
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: Boolean get_IncludeValue()
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: Int32 GetHashCode()
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: System.Object TypeId
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: System.Object get_TypeId()
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: System.String ToString()
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: System.Type GetType()
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: Void .ctor()
Microsoft.FSharp.Core.ReflectedDefinitionAttribute: Void .ctor(Boolean)
Microsoft.FSharp.Core.RequireQualifiedAccessAttribute: Boolean Equals(System.Object)
Microsoft.FSharp.Core.RequireQualifiedAccessAttribute: Boolean IsDefaultAttribute()
Microsoft.FSharp.Core.RequireQualifiedAccessAttribute: Boolean Match(System.Object)
Expand Down Expand Up @@ -3210,6 +3213,7 @@ Microsoft.FSharp.Linq.RuntimeHelpers.Grouping`2[K,T]: System.Type GetType()
Microsoft.FSharp.Linq.RuntimeHelpers.Grouping`2[K,T]: Void .ctor(K, System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter: Boolean Equals(System.Object)
Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter: Int32 GetHashCode()
Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter: Microsoft.FSharp.Quotations.FSharpExpr SubstHelperRaw(Microsoft.FSharp.Quotations.FSharpExpr, Microsoft.FSharp.Quotations.FSharpVar[], System.Object[])
Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter: Microsoft.FSharp.Quotations.FSharpExpr`1[T] SubstHelper[T](Microsoft.FSharp.Quotations.FSharpExpr, Microsoft.FSharp.Quotations.FSharpVar[], System.Object[])
Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter: System.Linq.Expressions.Expression QuotationToExpression(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter: System.Linq.Expressions.Expression`1[T] ImplicitExpressionConversionHelper[T](T)
Expand Down Expand Up @@ -3299,6 +3303,8 @@ Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr P
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr PropertySet(Microsoft.FSharp.Quotations.FSharpExpr, System.Reflection.PropertyInfo, Microsoft.FSharp.Quotations.FSharpExpr, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Quotations.FSharpExpr]])
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr PropertySet(System.Reflection.PropertyInfo, Microsoft.FSharp.Quotations.FSharpExpr, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Quotations.FSharpExpr]])
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr Quote(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr QuoteRaw(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr QuoteTyped(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr Sequential(Microsoft.FSharp.Quotations.FSharpExpr, Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr Substitute(Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Quotations.FSharpVar,Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Quotations.FSharpExpr]])
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr TryFinally(Microsoft.FSharp.Quotations.FSharpExpr, Microsoft.FSharp.Quotations.FSharpExpr)
Expand All @@ -3307,19 +3313,24 @@ Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr T
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr TypeTest(Microsoft.FSharp.Quotations.FSharpExpr, System.Type)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr UnionCaseTest(Microsoft.FSharp.Quotations.FSharpExpr, Microsoft.FSharp.Reflection.UnionCaseInfo)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr Value(System.Object, System.Type)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr ValueWithName(System.Object, System.Type, System.String)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr ValueWithName[T](T, System.String)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr Value[T](T)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr Var(Microsoft.FSharp.Quotations.FSharpVar)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr VarSet(Microsoft.FSharp.Quotations.FSharpVar, Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr WhileLoop(Microsoft.FSharp.Quotations.FSharpExpr, Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr WithValue(System.Object, System.Type, Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr`1[T] Cast[T](Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr`1[T] GlobalVar[T](System.String)
Microsoft.FSharp.Quotations.FSharpExpr: Microsoft.FSharp.Quotations.FSharpExpr`1[T] WithValue[T](T, Microsoft.FSharp.Quotations.FSharpExpr`1[T])
Microsoft.FSharp.Quotations.FSharpExpr: System.Collections.Generic.IEnumerable`1[Microsoft.FSharp.Quotations.FSharpVar] GetFreeVars()
Microsoft.FSharp.Quotations.FSharpExpr: System.String ToString()
Microsoft.FSharp.Quotations.FSharpExpr: System.String ToString(Boolean)
Microsoft.FSharp.Quotations.FSharpExpr: System.Type GetType()
Microsoft.FSharp.Quotations.FSharpExpr: System.Type Type
Microsoft.FSharp.Quotations.FSharpExpr: System.Type get_Type()
Microsoft.FSharp.Quotations.FSharpExpr: Void RegisterReflectedDefinitions(System.Reflection.Assembly, System.String, Byte[])
Microsoft.FSharp.Quotations.FSharpExpr: Void RegisterReflectedDefinitions(System.Reflection.Assembly, System.String, Byte[], System.Type[])
Microsoft.FSharp.Quotations.FSharpExpr`1[T]: Boolean Equals(System.Object)
Microsoft.FSharp.Quotations.FSharpExpr`1[T]: Int32 GetHashCode()
Microsoft.FSharp.Quotations.FSharpExpr`1[T]: Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Quotations.FSharpExpr] CustomAttributes
Expand Down Expand Up @@ -3350,6 +3361,8 @@ Microsoft.FSharp.Quotations.PatternsModule: Int32 GetHashCode()
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Quotations.FSharpExpr]] NewTuplePattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Quotations.FSharpExpr] AddressOfPattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Quotations.FSharpExpr] QuotePattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Quotations.FSharpExpr] QuoteRawPattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Quotations.FSharpExpr] QuoteTypedPattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Quotations.FSharpVar] VarPattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[Microsoft.FSharp.Quotations.FSharpVar,Microsoft.FSharp.Quotations.FSharpExpr]],Microsoft.FSharp.Quotations.FSharpExpr]] LetRecursivePattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Quotations.FSharpExpr],System.Reflection.FieldInfo]] FieldGetPattern(Microsoft.FSharp.Quotations.FSharpExpr)
Expand All @@ -3374,6 +3387,8 @@ Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Quotations.FSharpExpr],System.Reflection.PropertyInfo,Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Quotations.FSharpExpr]]] PropertyGetPattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[Microsoft.FSharp.Quotations.FSharpExpr,Microsoft.FSharp.Quotations.FSharpExpr,Microsoft.FSharp.Quotations.FSharpExpr]] IfThenElsePattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[Microsoft.FSharp.Quotations.FSharpVar,Microsoft.FSharp.Quotations.FSharpExpr,Microsoft.FSharp.Quotations.FSharpExpr]] LetPattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Object,System.Type,Microsoft.FSharp.Quotations.FSharpExpr]] WithValuePattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Object,System.Type,System.String]] ValueWithNamePattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Type,Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Quotations.FSharpVar],Microsoft.FSharp.Quotations.FSharpExpr]] NewDelegatePattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`4[Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Quotations.FSharpExpr],System.Reflection.PropertyInfo,Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Quotations.FSharpExpr],Microsoft.FSharp.Quotations.FSharpExpr]] PropertySetPattern(Microsoft.FSharp.Quotations.FSharpExpr)
Microsoft.FSharp.Quotations.PatternsModule: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`4[Microsoft.FSharp.Quotations.FSharpVar,Microsoft.FSharp.Quotations.FSharpExpr,Microsoft.FSharp.Quotations.FSharpExpr,Microsoft.FSharp.Quotations.FSharpExpr]] ForIntegerRangeLoopPattern(Microsoft.FSharp.Quotations.FSharpExpr)
Expand Down
23 changes: 20 additions & 3 deletions src/fsharp/FSharp.Core/Linq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ module LeafExpressionConverter =
|> System.Reflection.MethodInfo.GetMethodFromHandle
:?> MethodInfo

let SubstHelper<'T> (q:Expr, x:Var[], y:obj[]) : Expr<'T> =
let SubstHelperRaw (q:Expr, x:Var[], y:obj[]) : 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))) |> Expr.Cast
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> = SubstHelperRaw(q,x,y) |> Expr.Cast

let showAll =
#if FX_RESHAPED_REFLECTION
Expand Down Expand Up @@ -385,6 +387,12 @@ module LeafExpressionConverter =
methodhandleof (fun (x:Expr,y:Var[],z:obj[]) -> SubstHelper<obj> (x,y,z))
|> System.Reflection.MethodInfo.GetMethodFromHandle
:?> MethodInfo

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

let (-->) ty1 ty2 = Reflection.FSharpType.MakeFunctionType(ty1, ty2)

/// Extract member initialization expression stored in 'MemberInitializationHelper' (by QueryExtensions.fs)
Expand Down Expand Up @@ -762,7 +770,7 @@ module LeafExpressionConverter =
| Patterns.IfThenElse(g, t, e) ->
Expression.Condition(ConvExprToLinqInContext env g, ConvExprToLinqInContext env t, ConvExprToLinqInContext env e) |> asExpr

| Patterns.Quote x ->
| Patterns.QuoteTyped x ->
let fvs = x.GetFreeVars()

Expression.Call(substHelperMeth.MakeGenericMethod [| x.Type |],
Expand All @@ -771,6 +779,15 @@ module LeafExpressionConverter =
(Expression.NewArrayInit(typeof<obj>, [| for fv in fvs -> Expression.Convert(env.varEnv.[fv], typeof<obj>) |> asExpr |]) |> asExpr) |])
|> asExpr

| Patterns.QuoteRaw x ->
let fvs = x.GetFreeVars()

Expression.Call(substHelperRawMeth,
[| (Expression.Constant x) |> asExpr;
(Expression.NewArrayInit(typeof<Var>, [| for fv in fvs -> Expression.Constant fv |> asExpr |]) |> asExpr);
(Expression.NewArrayInit(typeof<obj>, [| for fv in fvs -> Expression.Convert(env.varEnv.[fv], typeof<obj>) |> asExpr |]) |> asExpr) |])
|> asExpr

| Patterns.Let (v, e, b) ->
let vP = ConvVarToLinq v
let envinner = { env with varEnv = Map.add v (vP |> asExpr) env.varEnv }
Expand Down
3 changes: 3 additions & 0 deletions src/fsharp/FSharp.Core/Linq.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,8 @@ namespace Microsoft.FSharp.Linq.RuntimeHelpers
/// A runtime helper used to evaluate nested quotation literals.
val SubstHelper : Expr * Var[] * obj[] -> Expr<'T>

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

val internal (|SpecificCallToMethod|_|) : System.RuntimeMethodHandle -> (Expr -> (Expr option * Type list * Expr list) option)
#endif
10 changes: 5 additions & 5 deletions src/fsharp/FSharp.Core/Query.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1128,15 +1128,15 @@ module Query =

let (|AnyNestedQuery|_|) e =
match e with
| CallQueryBuilderRunValue (None, _, [_; Quote e ])
| CallQueryBuilderRunEnumerable (None, _, [_; Quote e ])
| CallQueryBuilderRunQueryable (Some _, _, [ Quote e ]) -> Some e
| CallQueryBuilderRunValue (None, _, [_; QuoteTyped e ])
| CallQueryBuilderRunEnumerable (None, _, [_; QuoteTyped e ])
| CallQueryBuilderRunQueryable (Some _, _, [ QuoteTyped e ]) -> Some e
| _ -> None

let (|EnumerableNestedQuery|_|) e =
match e with
| CallQueryBuilderRunEnumerable (None, _, [_; Quote e ])
| CallQueryBuilderRunQueryable (Some _, _, [ Quote e ]) -> Some e
| CallQueryBuilderRunEnumerable (None, _, [_; QuoteTyped e ])
| CallQueryBuilderRunQueryable (Some _, _, [ QuoteTyped e ]) -> Some e
| _ -> None

/// Represents the result of TransInner - either a normal expression, or something we're about to turn into
Expand Down
32 changes: 23 additions & 9 deletions src/fsharp/FSharp.Core/quotations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ and
| CoerceOp of Type
| NewArrayOp of Type
| NewDelegateOp of Type
| QuoteOp
| QuoteOp of bool
| SequentialOp
| AddressOfOp
| VarSetOp
Expand Down Expand Up @@ -293,7 +293,7 @@ and [<CompiledName("FSharpExpr")>]
| VarTerm(v) -> wordL v.Name
| LambdaTerm(v,b) -> combL "Lambda" [varL v; expr b]
| HoleTerm _ -> wordL "_"
| CombTerm(QuoteOp,args) -> combL "Quote" (exprs args)
| CombTerm(QuoteOp _,args) -> combL "Quote" (exprs args)
| _ -> failwithf "Unexpected term in layout %A" x.Tree


Expand Down Expand Up @@ -357,6 +357,7 @@ module Patterns =

let mkArrayTy (t:Type) = t.MakeArrayType();
let mkExprTy (t:Type) = exprTyC.MakeGenericType([| t |])
let rawExprTy = typeof<Expr>


//--------------------------------------------------------------------------
Expand All @@ -381,7 +382,13 @@ module Patterns =
let (|Lambda|_|) (E x) = match x with LambdaTerm(a,b) -> Some (a,b) | _ -> None

[<CompiledName("QuotePattern")>]
let (|Quote|_|) (E x) = match x with CombTerm(QuoteOp,[a]) -> Some (a) | _ -> None
let (|Quote|_|) (E x) = match x with CombTerm(QuoteOp _,[a]) -> Some (a) | _ -> None

[<CompiledName("QuoteRawPattern")>]
let (|QuoteRaw|_|) (E x) = match x with CombTerm(QuoteOp false,[a]) -> Some (a) | _ -> None

[<CompiledName("QuoteTypedPattern")>]
let (|QuoteTyped|_|) (E x) = match x with CombTerm(QuoteOp true,[a]) -> Some (a) | _ -> None

[<CompiledName("IfThenElsePattern")>]
let (|IfThenElse|_|) = function Comb3(IfThenElseOp,e1,e2,e3) -> Some(e1,e2,e3) | _ -> None
Expand Down Expand Up @@ -577,14 +584,15 @@ module Patterns =
| NewDelegateOp ty,_ -> ty
| DefaultValueOp ty,_ -> ty
| TypeTestOp _,_ -> typeof<bool>
| QuoteOp,[expr] -> mkExprTy (typeOf expr)
| QuoteOp true,[expr] -> mkExprTy (typeOf expr)
| QuoteOp false,[_] -> rawExprTy
| TryFinallyOp,[e1;_] -> typeOf e1
| TryWithOp,[e1;_;_] -> typeOf e1
| WhileLoopOp,_
| VarSetOp,_
| AddressSetOp,_ -> typeof<Unit>
| AddressOfOp,_ -> raise <| System.InvalidOperationException (SR.GetString(SR.QcannotTakeAddress))
| (QuoteOp | SequentialOp | TryWithOp | TryFinallyOp | IfThenElseOp | AppOp),_ -> failwith "unreachable"
| (QuoteOp _ | SequentialOp | TryWithOp | TryFinallyOp | IfThenElseOp | AppOp),_ -> failwith "unreachable"


//--------------------------------------------------------------------------
Expand Down Expand Up @@ -656,7 +664,7 @@ module Patterns =

// [Correct by definition]
let mkVar v = E(VarTerm v )
let mkQuote(a) = E(CombTerm(QuoteOp,[(a:>Expr)] ))
let mkQuote(a,isTyped) = E(CombTerm(QuoteOp isTyped,[(a:>Expr)] ))

let mkValue (v,ty) = mkFE0 (ValueOp(v,ty,None))
let mkValueWithName (v,ty,nm) = mkFE0 (ValueOp(v,ty,Some nm))
Expand Down Expand Up @@ -1363,12 +1371,14 @@ module Patterns =
let idx = u_int st
(fun env -> E(HoleTerm(a env.typeInst , idx)))
| 4 -> let a = u_Expr st
(fun env -> mkQuote(a env))
(fun env -> mkQuote(a env, true))
| 5 -> let a = u_Expr st
let attrs = u_list u_Expr st
(fun env -> let e = (a env) in EA(e.Tree,(e.CustomAttributes @ List.map (fun attrf -> attrf env) attrs)))
| 6 -> let a = u_dtype st
(fun env -> mkVar(Var.Global("this", a env.typeInst)))
| 7 -> let a = u_Expr st
(fun env -> mkQuote(a env, false))
| _ -> failwith "u_Expr"

and u_VarDecl st =
Expand Down Expand Up @@ -1922,7 +1932,11 @@ type Expr with
static member PropertySet (property:PropertyInfo, value:Expr, ?args) =
mkStaticPropSet(property, defaultArg args [], value)

static member Quote (expr:Expr) = mkQuote expr
static member Quote (expr:Expr) = mkQuote (expr, true)

static member QuoteRaw (expr:Expr) = mkQuote (expr, false)

static member QuoteTyped (expr:Expr) = mkQuote (expr, true)

static member Sequential (e1:Expr, e2:Expr) =
mkSequential (e1, e2)
Expand Down Expand Up @@ -2178,7 +2192,7 @@ module ExprShape =
| WhileLoopOp,[e1;e2] -> mkWhileLoop(e1,e2)
| TryFinallyOp,[e1;e2] -> mkTryFinally(e1,e2)
| TryWithOp,[e1;Lambda(v1,e2);Lambda(v2,e3)] -> mkTryWith(e1,v1,e2,v2,e3)
| QuoteOp,[e1] -> mkQuote(e1)
| QuoteOp flg,[e1] -> mkQuote(e1,flg)
| ValueOp(v,ty,None),[] -> mkValue(v,ty)
| ValueOp(v,ty,Some nm),[] -> mkValueWithName(v,ty,nm)
| WithValueOp(v,ty),[e] -> mkValueWithDefn(v,ty,e)
Expand Down
Loading

0 comments on commit 0a23b20

Please sign in to comment.