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

Add entity.DeclaringEntity to F# Compiler Service #4633

Merged
merged 7 commits into from
Mar 28, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions fcs/README.md
Expand Up @@ -60,9 +60,9 @@ which does things like:
You can push the packages if you have permissions, either automatically using ``build Release`` or manually

set APIKEY=...
..\fsharp\.nuget\nuget.exe push %HOMEDRIVE%%HOMEPATH%\Downloads\FSharp.Compiler.Service.22.0.2.nupkg %APIKEY% -Source https://nuget.org
..\fsharp\.nuget\nuget.exe push %HOMEDRIVE%%HOMEPATH%\Downloads\FSharp.Compiler.Service.MSBuild.v12.22.0.2.nupkg %APIKEY% -Source https://nuget.org
..\fsharp\.nuget\nuget.exe push %HOMEDRIVE%%HOMEPATH%\Downloads\FSharp.Compiler.Service.ProjectCracker.22.0.2.nupkg %APIKEY% -Source https://nuget.org
..\fsharp\.nuget\nuget.exe push %HOMEDRIVE%%HOMEPATH%\Downloads\FSharp.Compiler.Service.22.0.3.nupkg %APIKEY% -Source https://nuget.org
..\fsharp\.nuget\nuget.exe push %HOMEDRIVE%%HOMEPATH%\Downloads\FSharp.Compiler.Service.MSBuild.v12.22.0.3.nupkg %APIKEY% -Source https://nuget.org
..\fsharp\.nuget\nuget.exe push %HOMEDRIVE%%HOMEPATH%\Downloads\FSharp.Compiler.Service.ProjectCracker.22.0.3.nupkg %APIKEY% -Source https://nuget.org


### Use of Paket and FAKE
Expand Down
3 changes: 3 additions & 0 deletions fcs/RELEASE_NOTES.md
@@ -1,3 +1,6 @@
#### 22.0.3
* [Add entity.DeclaringEntity](https://github.com/Microsoft/visualfsharp/pull/4633), [FCS feature request](https://github.com/fsharp/FSharp.Compiler.Service/issues/830)

#### 22.0.2
* Use correct version number in DLLs (needed until https://github.com/Microsoft/visualfsharp/issues/3113 is fixed)

Expand Down
2 changes: 1 addition & 1 deletion fcs/fcs.props
Expand Up @@ -3,7 +3,7 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>

<VersionPrefix>22.0.2</VersionPrefix>
<VersionPrefix>22.0.3</VersionPrefix>
<OtherFlags>--version:$(VersionPrefix)</OtherFlags>
<!-- FSharp.Compiler.Tools is currently only used to get a working FSI.EXE to execute some scripts during the build -->
<!-- The LKG FSI.EXE requires MSBuild 15 to be installed, which is painful -->
Expand Down
55 changes: 24 additions & 31 deletions src/absil/il.fs
Expand Up @@ -408,8 +408,6 @@ type ILAssemblyRef(data) =

ILAssemblyRef.Create(aname.Name,None,publicKey,retargetable,version,locale)



member aref.QualifiedName =
let b = new System.Text.StringBuilder(100)
let add (s:string) = (b.Append(s) |> ignore)
Expand Down Expand Up @@ -478,13 +476,6 @@ type ILScopeRef =
member x.AssemblyRef = match x with ILScopeRef.Assembly x -> x | _ -> failwith "not an assembly reference"

member scoref.QualifiedName =
match scoref with
| ILScopeRef.Local -> ""
| ILScopeRef.Module mref -> "module "^mref.Name
| ILScopeRef.Assembly aref when aref.Name = "mscorlib" -> ""
| ILScopeRef.Assembly aref -> aref.QualifiedName

member scoref.QualifiedNameWithNoShortPrimaryAssembly =
match scoref with
| ILScopeRef.Local -> ""
| ILScopeRef.Module mref -> "module "+mref.Name
Expand Down Expand Up @@ -602,18 +593,12 @@ type ILTypeRef =
member tref.BasicQualifiedName =
(String.concat "+" (tref.Enclosing @ [ tref.Name ] )).Replace(",", @"\,")

member tref.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(basic) =
let sco = tref.Scope.QualifiedNameWithNoShortPrimaryAssembly
if sco = "" then basic else String.concat ", " [basic;sco]

member tref.QualifiedNameWithNoShortPrimaryAssembly =
tref.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(tref.BasicQualifiedName)

member tref.QualifiedName =
let basic = tref.BasicQualifiedName
member tref.AddQualifiedNameExtension(basic) =
let sco = tref.Scope.QualifiedName
if sco = "" then basic else String.concat ", " [basic;sco]

member tref.QualifiedName =
tref.AddQualifiedNameExtension(tref.BasicQualifiedName)

override x.ToString() = x.FullName

Expand All @@ -624,22 +609,30 @@ and
{ tspecTypeRef: ILTypeRef;
/// The type instantiation if the type is generic.
tspecInst: ILGenericArgs }

member x.TypeRef=x.tspecTypeRef

member x.Scope=x.TypeRef.Scope

member x.Enclosing=x.TypeRef.Enclosing

member x.Name=x.TypeRef.Name

member x.GenericArgs=x.tspecInst

static member Create(tref,inst) = { tspecTypeRef =tref; tspecInst=inst }

override x.ToString() = x.TypeRef.ToString() + if isNil x.GenericArgs then "" else "<...>"

member x.BasicQualifiedName =
let tc = x.TypeRef.BasicQualifiedName
if isNil x.GenericArgs then
tc
else
tc + "[" + String.concat "," (x.GenericArgs |> List.map (fun arg -> "[" + arg.QualifiedNameWithNoShortPrimaryAssembly + "]")) + "]"
tc + "[" + String.concat "," (x.GenericArgs |> List.map (fun arg -> "[" + arg.QualifiedName + "]")) + "]"

member x.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(basic) =
x.TypeRef.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(basic)
member x.AddQualifiedNameExtension(basic) =
x.TypeRef.AddQualifiedNameExtension(basic)

member x.FullName=x.TypeRef.FullName

Expand All @@ -666,19 +659,19 @@ and [<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
| ILType.Byref _ty -> failwith "unexpected byref type"
| ILType.FunctionPointer _mref -> failwith "unexpected function pointer type"

member x.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(basic) =
member x.AddQualifiedNameExtension(basic) =
match x with
| ILType.TypeVar _n -> basic
| ILType.Modified(_,_ty1,ty2) -> ty2.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(basic)
| ILType.Array (ILArrayShape(_s),ty) -> ty.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(basic)
| ILType.Value tr | ILType.Boxed tr -> tr.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(basic)
| ILType.Modified(_,_ty1,ty2) -> ty2.AddQualifiedNameExtension(basic)
| ILType.Array (ILArrayShape(_s),ty) -> ty.AddQualifiedNameExtension(basic)
| ILType.Value tr | ILType.Boxed tr -> tr.AddQualifiedNameExtension(basic)
| ILType.Void -> failwith "void"
| ILType.Ptr _ty -> failwith "unexpected pointer type"
| ILType.Byref _ty -> failwith "unexpected byref type"
| ILType.FunctionPointer _mref -> failwith "unexpected function pointer type"

member x.QualifiedNameWithNoShortPrimaryAssembly =
x.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(x.BasicQualifiedName)
member x.QualifiedName =
x.AddQualifiedNameExtension(x.BasicQualifiedName)

member x.TypeSpec =
match x with
Expand Down Expand Up @@ -3301,7 +3294,7 @@ let rec encodeCustomAttrElemType x =
| ILType.Boxed tspec when tspec.Name = tname_String -> [| et_STRING |]
| ILType.Boxed tspec when tspec.Name = tname_Object -> [| 0x51uy |]
| ILType.Boxed tspec when tspec.Name = tname_Type -> [| 0x50uy |]
| ILType.Value tspec -> Array.append [| 0x55uy |] (encodeCustomAttrString tspec.TypeRef.QualifiedNameWithNoShortPrimaryAssembly)
| ILType.Value tspec -> Array.append [| 0x55uy |] (encodeCustomAttrString tspec.TypeRef.QualifiedName)
| ILType.Array (shape, elemType) when shape = ILArrayShape.SingleDimensional ->
Array.append [| et_SZARRAY |] (encodeCustomAttrElemType elemType)
| _ -> failwith "encodeCustomAttrElemType: unrecognized custom element type"
Expand Down Expand Up @@ -3372,8 +3365,8 @@ let rec encodeCustomAttrPrimValue ilg c =
| ILAttribElem.UInt64 x -> u64AsBytes x
| ILAttribElem.Single x -> ieee32AsBytes x
| ILAttribElem.Double x -> ieee64AsBytes x
| ILAttribElem.Type (Some ty) -> encodeCustomAttrString ty.QualifiedNameWithNoShortPrimaryAssembly
| ILAttribElem.TypeRef (Some tref) -> encodeCustomAttrString tref.QualifiedNameWithNoShortPrimaryAssembly
| ILAttribElem.Type (Some ty) -> encodeCustomAttrString ty.QualifiedName
| ILAttribElem.TypeRef (Some tref) -> encodeCustomAttrString tref.QualifiedName
| ILAttribElem.Array (_,elems) ->
[| yield! i32AsBytes elems.Length; for elem in elems do yield! encodeCustomAttrPrimValue ilg elem |]

Expand Down Expand Up @@ -3427,7 +3420,7 @@ let mkPermissionSet (ilg: ILGlobals) (action,attributes: list<(ILTypeRef * (stri
[| yield (byte '.');
yield! z_unsigned_int attributes.Length;
for (tref:ILTypeRef,props) in attributes do
yield! encodeCustomAttrString tref.QualifiedNameWithNoShortPrimaryAssembly
yield! encodeCustomAttrString tref.QualifiedName
let bytes =
[| yield! z_unsigned_int props.Length;
for (nm,typ,value) in props do
Expand Down
42 changes: 37 additions & 5 deletions src/absil/il.fsi
Expand Up @@ -184,26 +184,32 @@ type ILTypeRef =

member QualifiedName: string

#if !NO_EXTENSIONTYPING
member QualifiedNameWithNoShortPrimaryAssembly: string
#endif

interface System.IComparable

/// Type specs and types.
[<Sealed>]
type ILTypeSpec =
/// Create an ILTypeSpec.
static member Create: typeRef:ILTypeRef * instantiation:ILGenericArgs -> ILTypeSpec

/// Which type is being referred to?
member TypeRef: ILTypeRef

/// The type instantiation if the type is generic, otherwise empty
member GenericArgs: ILGenericArgs

/// Where is the type, i.e. is it in this module, in another module in this assembly or in another assembly?
member Scope: ILScopeRef

/// The list of enclosing type names for a nested type. If non-nil then the first of these also contains the namespace.
member Enclosing: string list

/// The name of the type. This also contains the namespace if Enclosing is empty.
member Name: string

/// The name of the type in the assembly using the '.' notation for nested types.
member FullName: string

interface System.IComparable

and
Expand Down Expand Up @@ -244,13 +250,20 @@ and
ILType

member TypeSpec: ILTypeSpec

member Boxity: ILBoxity

member TypeRef: ILTypeRef

member IsNominal: bool

member GenericArgs: ILGenericArgs

member IsTyvar: bool

member BasicQualifiedName: string
member QualifiedNameWithNoShortPrimaryAssembly: string

member QualifiedName: string

and [<StructuralEquality; StructuralComparison>]
ILCallingSignature =
Expand All @@ -271,13 +284,21 @@ type ILMethodRef =
static member Create: enclosingTypeRef: ILTypeRef * callingConv: ILCallingConv * name: string * genericArity: int * argTypes: ILTypes * returnType: ILType -> ILMethodRef

member DeclaringTypeRef: ILTypeRef

member CallingConv: ILCallingConv

member Name: string

member GenericArity: int

member ArgCount: int

member ArgTypes: ILTypes

member ReturnType: ILType

member CallingSignature: ILCallingSignature

interface System.IComparable

/// Formal identities of fields.
Expand All @@ -295,13 +316,21 @@ type ILMethodSpec =
static member Create: ILType * ILMethodRef * ILGenericArgs -> ILMethodSpec

member MethodRef: ILMethodRef

member DeclaringType: ILType

member GenericArgs: ILGenericArgs

member CallingConv: ILCallingConv

member GenericArity: int

member Name: string

member FormalArgTypes: ILTypes

member FormalReturnType: ILType

interface System.IComparable

/// Field specs. The data given for a ldfld, stfld etc. instruction.
Expand All @@ -311,8 +340,11 @@ type ILFieldSpec =
DeclaringType: ILType }

member DeclaringTypeRef: ILTypeRef

member Name: string

member FormalType: ILType

member ActualType: ILType

/// ILCode labels. In structured code each code label refers to a basic block somewhere in the code of the method.
Expand Down