2012-08-02 3 views

답변

3

시도 뭔가 :이 지금 F 번호에 내장되어

let sourceInfo (e:Quotations.Expr) = 
    let (|Val|_|) e : 't option = 
     match e with 
     | Quotations.Patterns.Value(:? 't as v,_) -> Some v 
     | _ -> None 
    let (|Tup|_|) = Quotations.Patterns.(|NewTuple|_|) 

    e.CustomAttributes 
    |> List.tryPick (function | Tup [Val("DebugRange") 
            Tup [Val(file:string) 
              Val(startLine:int) 
              Val(startCol:int) 
              Val(endLine:int) 
              Val(endCol:int)]] 
            -> Some(file,startLine,startCol,endLine,endCol) 
           | _ -> None) 

sourceInfo <@ "test" @>