Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a206f9

Browse files
authored
Read/store ILCustomAttrs, ILSecurityDecls, ILTypeDef sensibly (dotnet#4597)
* Read/store ILCustomAttrs, ILSecurityDecls, ILTypeDef sensibly (dotnet#4597)* hide representation of ILPreTypeDef* fix build* remove unnecessary use of lists with repeated tail-appends* add comment* fix test
1 parentb6dfbb6 commit2a206f9

25 files changed

+757
-670
lines changed

‎src/absil/il.fs‎

Lines changed: 274 additions & 146 deletions
Large diffs are not rendered by default.

‎src/absil/il.fsi‎

Lines changed: 190 additions & 269 deletions
Large diffs are not rendered by default.

‎src/absil/ilmorph.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ let morphILTypesInILInstr ((factualty,fformalty)) i =
200200
| ILToken.ILField fr-> I_ldtoken(ILToken.ILField(conv_fspec fr))
201201
| x-> x
202202

203-
letreturn_typ2typ ilg f(r:ILReturn)={rwith Type=f r.Type;CustomAttrs=cattrs_typ2typ ilg f r.CustomAttrs}
204-
letparam_typ2typ ilg f(p:ILParameter)={pwith Type=f p.Type;CustomAttrs=cattrs_typ2typ ilg f p.CustomAttrs}
203+
letreturn_typ2typ ilg f(r:ILReturn)={rwith Type=f r.Type;CustomAttrsStored= storeILCustomAttrs(cattrs_typ2typ ilg f r.CustomAttrs)}
204+
letparam_typ2typ ilg f(p:ILParameter)={pwith Type=f p.Type;CustomAttrsStored= storeILCustomAttrs(cattrs_typ2typ ilg f p.CustomAttrs)}
205205

206206
letmorphILMethodDefs f(m:ILMethodDefs)= mkILMethods(List.map f m.AsList)
207207
letfdefs_fdef2fdef f(m:ILFieldDefs)= mkILFields(List.map f m.AsList)
@@ -287,14 +287,14 @@ and tdefs_typ2typ_ilmbody2ilmbody_mdefs2mdefs ilg enc fs tdefs =
287287
// --------------------------------------------------------------------
288288

289289
letmanifest_typ2typ ilg f(m:ILAssemblyManifest)=
290-
{ mwithCustomAttrs= cattrs_typ2typ ilg f m.CustomAttrs}
290+
{ mwithCustomAttrsStored=storeILCustomAttrs(cattrs_typ2typ ilg f m.CustomAttrs)}
291291

292292
letmorphILTypeInILModule_ilmbody2ilmbody_mdefs2mdefs ilg((ftype:ILModuleDef->(ILTypeDef list* ILTypeDef)option->ILMethodDef option->ILType->ILType),fmdefs)m=
293293

294294
letftdefs= tdefs_typ2typ_ilmbody2ilmbody_mdefs2mdefs ilg[](ftype m,fmdefs m)
295295

296296
{ mwith TypeDefs=ftdefs m.TypeDefs;
297-
CustomAttrs=cattrs_typ2typ ilg(ftype m None None) m.CustomAttrs;
297+
CustomAttrsStored= storeILCustomAttrs(cattrs_typ2typ ilg(ftype m None None) m.CustomAttrs);
298298
Manifest=Option.map(manifest_typ2typ ilg(ftype m None None)) m.Manifest}
299299

300300
letmodule_instr2instr_typ2typ ilg fs x=

‎src/absil/ilprint.fs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,11 +1021,10 @@ let goutput_manifest env os m =
10211021
output_sqstring os m.Name;
10221022
output_string os" {\n";
10231023
output_string os".hash algorithm"; output_i32 os m.AuxModuleHashAlgorithm; output_string os"\n";
1024-
goutput_custom_attrs env os m.CustomAttrs;
1025-
goutput_security_decls env os m.SecurityDecls;
1026-
(output_option output_publickey) os m.PublicKey;
1027-
(output_option output_ver) os m.Version;
1028-
(output_option output_locale) os m.Locale;
1024+
goutput_custom_attrs env os m.CustomAttrs
1025+
(output_option output_publickey) os m.PublicKey
1026+
(output_option output_ver) os m.Version
1027+
(output_option output_locale) os m.Locale
10291028
output_string os" }\n"
10301029

10311030

‎src/absil/ilread.fs‎

Lines changed: 88 additions & 55 deletions
Large diffs are not rendered by default.

‎src/absil/ilreflect.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ let buildGenParamsPass1b cenv emEnv (genArgs : Type array) (gps : ILGenericParam
14311431
|_-> failwith"buildGenParam: multiple base types"
14321432
);
14331433
// set interface constraints (interfaces that instances of gp must meet)
1434-
gpB.SetInterfaceConstraints(Array.ofList interfaceTs);
1434+
gpB.SetInterfaceConstraints(Array.ofList interfaceTs)
14351435
gp.CustomAttrs|> emitCustomAttrs cenv emEnv(wrapCustomAttr gpB.SetCustomAttribute)
14361436

14371437
letflags= GenericParameterAttributes.None

‎src/fsharp/CompileOps.fs‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3781,13 +3781,15 @@ let MakeILResource rname bytes =
37813781
{ Name= rname
37823782
Location= ILResourceLocation.LocalOut bytes
37833783
Access= ILResourceAccess.Public
3784-
CustomAttrs= emptyILCustomAttrs}
3784+
CustomAttrsStored= storeILCustomAttrs emptyILCustomAttrs
3785+
MetadataIndex= NoMetadataIdx}
37853786

37863787
letPickleToResource inMem file g scope rname p x=
37873788
{ Name= rname
37883789
Location=(letbytes= pickleObjWithDanglingCcus inMem file g scope p xin ILResourceLocation.LocalOut bytes)
37893790
Access= ILResourceAccess.Public
3790-
CustomAttrs= emptyILCustomAttrs}
3791+
CustomAttrsStored= storeILCustomAttrs emptyILCustomAttrs
3792+
MetadataIndex= NoMetadataIdx}
37913793

37923794
letGetSignatureData(file,ilScopeRef,ilModule,byteReader):PickledDataWithReferences<PickledCcuInfo>=
37933795
unpickleObjWithDanglingCcus file ilScopeRef ilModule unpickleCcuInfo byteReader
@@ -5205,11 +5207,11 @@ module private ScriptPreprocessClosure =
52055207
letallRootDiagnostics= allRootDiagnostics|> List.filter(fst>> isRootRange)
52065208

52075209
letresult:LoadClosure=
5208-
{ SourceFiles= List.groupByFirstsourceFiles
5209-
References= List.groupByFirstreferences
5210+
{ SourceFiles= List.groupBy fstsourceFiles|> List.map(map2Of2(List.map snd))
5211+
References= List.groupBy fstreferences|> List.map(map2Of2(List.map snd))
52105212
UnresolvedReferences= unresolvedReferences
52115213
Inputs= sourceInputs
5212-
NoWarns= List.groupByFirstglobalNoWarns
5214+
NoWarns= List.groupBy fstglobalNoWarns|> List.map(map2Of2(List.map snd))
52135215
OriginalLoadReferences= tcConfig.loadedSources
52145216
ResolutionDiagnostics= resolutionDiagnostics
52155217
AllRootFileDiagnostics= allRootDiagnostics
@@ -5430,7 +5432,7 @@ let TypeCheckOneInputEventually
54305432
letm= qualNameOfFile.Range
54315433
TcOpenDecl tcSink tcGlobals amap m m tcEnv prefixPath
54325434

5433-
letres=(EmptyTopAttrs,[], tcEnv, tcEnv, tcState.tcsTcImplEnv, RootSigsAndImpls(rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp), tcState.tcsCcuType, createsGeneratedProvidedTypes)
5435+
letres=(EmptyTopAttrs,None, tcEnv, tcEnv, tcState.tcsTcImplEnv, RootSigsAndImpls(rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp), tcState.tcsCcuType, createsGeneratedProvidedTypes)
54345436
return res
54355437

54365438
| ParsedInput.ImplFile(ParsedImplFileInput(filename,_, qualNameOfFile,_,_,_,_)as file)->
@@ -5490,7 +5492,7 @@ let TypeCheckOneInputEventually
54905492
if verbosethen dprintf"done TypeCheckOneInputEventually...\n"
54915493

54925494
lettopSigsAndImpls= RootSigsAndImpls(rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp)
5493-
letres=(topAttrs,[implFile], tcEnvAtEnd, tcSigEnv, tcImplEnv, topSigsAndImpls, ccuType, createsGeneratedProvidedTypes)
5495+
letres=(topAttrs,SomeimplFile, tcEnvAtEnd, tcSigEnv, tcImplEnv, topSigsAndImpls, ccuType, createsGeneratedProvidedTypes)
54945496
return res}
54955497

54965498
return(tcEnvAtEnd, topAttrs, implFiles),
@@ -5502,7 +5504,7 @@ let TypeCheckOneInputEventually
55025504
tcsRootSigsAndImpls= topSigsAndImpls}
55035505
with e->
55045506
errorRecovery e range0
5505-
return(tcState.TcEnvFromSignatures, EmptyTopAttrs,[]), tcState
5507+
return(tcState.TcEnvFromSignatures, EmptyTopAttrs,None), tcState
55065508
}
55075509

55085510
/// Typecheck a single file (or interactive entry into F# Interactive)
@@ -5518,7 +5520,7 @@ let TypeCheckMultipleInputsFinish(results, tcState: TcState) =
55185520
lettcEnvsAtEndFile,topAttrs,implFiles= List.unzip3 results
55195521

55205522
lettopAttrs= List.foldBack CombineTopAttrs topAttrs EmptyTopAttrs
5521-
letimplFiles= List.concat implFiles
5523+
letimplFiles= List.choose id implFiles
55225524
// This is the environment required by fsi.exe when incrementally adding definitions
55235525
lettcEnvAtEndOfLastFile=(match tcEnvsAtEndFilewith h::_-> h|_-> tcState.TcEnvFromSignatures)
55245526

‎src/fsharp/CompileOps.fsi‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,10 @@ val GetInitialTcState:
724724
/// Check one input, returned as an Eventually computation
725725
val TypeCheckOneInputEventually:
726726
checkForErrors:(unit-> bool)* TcConfig* TcImports* TcGlobals* Ast.LongIdent option* NameResolution.TcResultsSink* TcState* Ast.ParsedInput
727-
-> Eventually<(TcEnv* TopAttribs* TypedImplFilelist)* TcState>
727+
-> Eventually<(TcEnv* TopAttribs* TypedImplFileoption)* TcState>
728728

729729
/// Finish the checking of multiple inputs
730-
val TypeCheckMultipleInputsFinish:(TcEnv* TopAttribs* 'Tlist) list* TcState->(TcEnv* TopAttribs* 'T list)* TcState
730+
val TypeCheckMultipleInputsFinish:(TcEnv* TopAttribs* 'Toption) list* TcState->(TcEnv* TopAttribs* 'T list)* TcState
731731
732732
/// Finish the checking of a closed set of inputs
733733
val TypeCheckClosedInputSetFinish: TypedImplFile list* TcState-> TcState* TypedImplFile list

‎src/fsharp/IlxGen.fs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,7 +3454,8 @@ and GenGenericParam cenv eenv (tp:Typar) =
34543454

34553455
Constraints= subTypeConstraints
34563456
Variance=NonVariant
3457-
CustomAttrs= mkILCustomAttrs(GenAttrs cenv eenv tp.Attribs)
3457+
CustomAttrsStored= storeILCustomAttrs(mkILCustomAttrs(GenAttrs cenv eenv tp.Attribs))
3458+
MetadataIndex= NoMetadataIdx
34583459
HasReferenceTypeConstraint=refTypeConstraint
34593460
HasNotNullableValueTypeConstraint=notNullableValueTypeConstraint
34603461
HasDefaultConstructorConstraint= defaultConstructorConstraint}
@@ -3474,7 +3475,8 @@ and GenSlotParam m cenv eenv (TSlotParam(nm,ty,inFlag,outFlag,optionalFlag,attri
34743475
IsIn=inFlag|| inFlag2
34753476
IsOut=outFlag|| outFlag2
34763477
IsOptional=optionalFlag|| optionalFlag2
3477-
CustomAttrs= mkILCustomAttrs(GenAttrs cenv eenv attribs)}
3478+
CustomAttrsStored= storeILCustomAttrs(mkILCustomAttrs(GenAttrs cenv eenv attribs))
3479+
MetadataIndex= NoMetadataIdx}
34783480

34793481
andGenFormalSlotsig m cenv eenv(TSlotSig(_,typ,ctps,mtps,paraml,returnTy))=
34803482
letparaml= List.concat paraml
@@ -5005,7 +5007,8 @@ and GenParams cenv eenv (mspec:ILMethodSpec) (attribs:ArgReprInfo list) (implVal
50055007
IsIn=inFlag
50065008
IsOut=outFlag
50075009
IsOptional=optionalFlag
5008-
CustomAttrs= mkILCustomAttrs(GenAttrs cenv eenv attribs)}
5010+
CustomAttrsStored= storeILCustomAttrs(mkILCustomAttrs(GenAttrs cenv eenv attribs))
5011+
MetadataIndex= NoMetadataIdx}
50095012

50105013
param, takenNames)
50115014
|> fst
@@ -5014,7 +5017,8 @@ and GenReturnInfo cenv eenv ilRetTy (retInfo : ArgReprInfo) : ILReturn =
50145017
letmarshal,attrs= GenMarshal cenv retInfo.Attribs
50155018
{ Type=ilRetTy
50165019
Marshal=marshal
5017-
CustomAttrs= mkILCustomAttrs(GenAttrs cenv eenv attrs)}
5020+
CustomAttrsStored= storeILCustomAttrs(mkILCustomAttrs(GenAttrs cenv eenv attrs))
5021+
MetadataIndex= NoMetadataIdx}
50185022

50195023
andGenPropertyForMethodDef compileAsInstance tref mdef(v:Val)(memberInfo:ValMemberInfo)ilArgTys ilPropTy ilAttrs compiledName=
50205024
letname=match compiledNamewith| Some n-> n|_-> v.PropertyNamein(* chop "get_"*)

‎src/fsharp/InternalCollections.fs‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -198,37 +198,3 @@ type internal MruCache<'Token, 'Key,'Value when 'Value : not struct>(keepStrongl
198198
memberbc.Resize(tok,newKeepStrongly,?newKeepMax)=
199199
cache.Resize(tok, newKeepStrongly, ?newKeepMax=newKeepMax)
200200

201-
/// List helpers
202-
[<Sealed>]
203-
typeinternalList=
204-
/// Return a new list with one element for each unique 'Key. Multiple 'TValues are flattened.
205-
/// The original order of the first instance of 'Key is preserved.
206-
static membergroupByFirst(l:('Key* 'Value)list):('Key* 'Value list)list=
207-
letnextIndex= ref0
208-
letresult= System.Collections.Generic.List<'Key* System.Collections.Generic.List<'Value>>()
209-
letkeyToIndex= Dictionary<'Key,int>(HashIdentity.Structural)
210-
letindexOfKey(key)=
211-
match keyToIndex.TryGetValue(key)with
212-
|true, v-> v
213-
|false,_->
214-
keyToIndex.Add(key,!nextIndex)
215-
nextIndex:=!nextIndex+1
216-
!nextIndex-1
217-
218-
for kvin ldo
219-
letindex= indexOfKey(fst kv)
220-
if index>= result.Countthen
221-
letk,vs= fst kv,System.Collections.Generic.List<'Value>()
222-
vs.Add(snd kv)
223-
result.Add(k,vs)
224-
else
225-
let_,vs= result.[index]
226-
vs.Add(snd kv)
227-
228-
result|> Seq.map(fun(k,vs)-> k,vs|> List.ofSeq)|> List.ofSeq
229-
230-
/// Return each distinct item in the list using reference equality.
231-
static memberreferenceDistinct(l:'T list):'T list when 'T:not struct=
232-
letset= System.Collections.Generic.Dictionary<'T,bool>(HashIdentity.Reference)
233-
l|> List.iter(fun i->set.Add(i,true))
234-
set|> Seq.map(fun kv->kv.Key)|> List.ofSeq

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp