Skip to content
5 changes: 5 additions & 0 deletions src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,9 @@ let destILArrTy ty =
// Sigs of special types built-in
// --------------------------------------------------------------------

[<Literal>]
let tname_Attribute = "System.Attribute"

[<Literal>]
let tname_Object = "System.Object"

Expand Down Expand Up @@ -3347,6 +3350,8 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly

member x.primaryAssemblyName = x.primaryAssemblyRef.Name

member val typ_Attribute = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_Attribute))

member val typ_Object = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_Object))

member val typ_String = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_String))
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/AbstractIL/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,7 @@ type internal ILGlobals =
member primaryAssemblyScopeRef: ILScopeRef
member primaryAssemblyRef: ILAssemblyRef
member primaryAssemblyName: string
member typ_Attribute: ILType
member typ_Object: ILType
member typ_String: ILType
member typ_Type: ILType
Expand Down
27 changes: 4 additions & 23 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -610,16 +610,10 @@ type PtrsOK =
| PtrTypesNotOK

let GenReadOnlyAttribute (g: TcGlobals) =
mkILCustomAttribute (g.attrib_IsReadOnlyAttribute.TypeRef, [], [], [])
g.AddEmbeddableSystemAttribute(g.attrib_IsReadOnlyAttribute.TypeRef, [], [], [])

let GenReadOnlyAttributeIfNecessary (g: TcGlobals) ty =
let add =
false
&& g.isSystem_Runtime_CompilerServices_IsReadOnlyAttributeAvailable
&& isInByrefTy g ty
&& g.attrib_IsReadOnlyAttribute.TyconRef.CanDeref

if add then
if isInByrefTy g ty then
let attr = GenReadOnlyAttribute g
Some attr
else
Expand Down Expand Up @@ -2088,15 +2082,7 @@ type AnonTypeGenerationTable() =
let ilMethods =
[
for propName, fldName, fldTy in flds ->
let attrs =
if
false
&& g.isSystem_Runtime_CompilerServices_IsReadOnlyAttributeAvailable
&& isStruct
then
[ GenReadOnlyAttribute g ]
else
[]
let attrs = if isStruct then [ GenReadOnlyAttribute g ] else []

mkLdfldMethodDef ("get_" + propName, ILMemberAccess.Public, false, ilTy, fldName, fldTy, attrs)
|> g.AddMethodGeneratedAttributes
Expand Down Expand Up @@ -10897,12 +10883,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) =
let isStruct = isStructTyconRef tcref

let attrs =
if
false
&& g.isSystem_Runtime_CompilerServices_IsReadOnlyAttributeAvailable
&& isStruct
&& not isStatic
then
if isStruct && not isStatic then
[ GenReadOnlyAttribute g ]
else
[]
Expand Down
15 changes: 11 additions & 4 deletions src/Compiler/Driver/CompilerImports.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ and [<Sealed>] TcImports
| ResolvedCcu ccu -> Some ccu
| UnresolvedCcu _ -> None

static let ccuHasType (ccu: CcuThunk) (nsname: string list) (tname: string) =
static let ccuHasType (ccu: CcuThunk) (nsname: string list) (tname: string) (publicOnly: bool) =
let matchNameSpace (entityOpt: Entity option) n =
match entityOpt with
| None -> None
Expand All @@ -1172,7 +1172,14 @@ and [<Sealed>] TcImports
match (Some ccu.Contents, nsname) ||> List.fold matchNameSpace with
| Some ns ->
match Map.tryFind tname ns.ModuleOrNamespaceType.TypesByMangledName with
| Some _ -> true
| Some e ->
if publicOnly then
match e.TypeReprInfo with
| TILObjectRepr data ->
let (TILObjectReprData(_, _, tyDef)) = data
tyDef.Access = ILTypeDefAccess.Public
| _ -> false
else true
| None -> false
| None -> false

Expand Down Expand Up @@ -2461,8 +2468,8 @@ and [<Sealed>] TcImports
ccu
|]

let tryFindSysTypeCcu path typeName =
sysCcus |> Array.tryFind (fun ccu -> ccuHasType ccu path typeName)
let tryFindSysTypeCcu path typeName publicOnly =
sysCcus |> Array.tryFind (fun ccu -> ccuHasType ccu path typeName publicOnly)

let ilGlobals =
mkILGlobals (primaryScopeRef, equivPrimaryAssemblyRefs, fsharpCoreAssemblyScopeRef)
Expand Down
10 changes: 5 additions & 5 deletions src/Compiler/Driver/CompilerOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -331,25 +331,25 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler
let rec processArg args =
match args with
| [] -> ()
| rsp: string :: t when rsp.StartsWithOrdinal("@") ->
| opt: string :: t when opt.StartsWithOrdinal("@") ->
let responseFileOptions =
let fullpath =
try
Some(rsp.TrimStart('@') |> FileSystem.GetFullPathShim)
Some(opt.TrimStart('@') |> FileSystem.GetFullPathShim)
with _ ->
None

match fullpath with
| None ->
errorR (Error(FSComp.SR.optsResponseFileNameInvalid rsp, rangeCmdArgs))
errorR (Error(FSComp.SR.optsResponseFileNameInvalid opt, rangeCmdArgs))
[]
| Some path when not (FileSystem.FileExistsShim path) ->
errorR (Error(FSComp.SR.optsResponseFileNotFound (rsp, path), rangeCmdArgs))
errorR (Error(FSComp.SR.optsResponseFileNotFound (opt, path), rangeCmdArgs))
[]
| Some path ->
match ResponseFile.parseFile path with
| Choice2Of2 _ ->
errorR (Error(FSComp.SR.optsInvalidResponseFile (rsp, path), rangeCmdArgs))
errorR (Error(FSComp.SR.optsInvalidResponseFile (opt, path), rangeCmdArgs))
[]
| Choice1Of2 rspData ->
let onlyOptions l =
Expand Down
5 changes: 2 additions & 3 deletions src/Compiler/Driver/CreateILModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ module MainModuleBuilder =
(
ctok,
tcConfig: TcConfig,
tcGlobals,
tcGlobals: TcGlobals,
tcImports: TcImports,
pdbfile,
assemblyName,
Expand All @@ -304,8 +304,7 @@ module MainModuleBuilder =
RequireCompilationThread ctok

let ilTypeDefs =
//let topTypeDef = mkILTypeDefForGlobalFunctions tcGlobals.ilg (mkILMethods [], emptyILFields)
mkILTypeDefs codegenResults.ilTypeDefs
mkILTypeDefs (codegenResults.ilTypeDefs @ tcGlobals.embeddedTypeDefs)

let mainModule =
let hashAlg =
Expand Down
Loading