@@ -116,10 +116,10 @@ let isSupportedDirectCall apps =
116116// --------------------------------------------------------------------
117117
118118let mkFuncTypeRef n =
119- if n = 1 then mkILTyRef ( IlxSettings.ilxFsharpCoreLibScopeRef (), IlxSettings.ilxNamespace () ^ " .FSharpFunc`2" )
119+ if n = 1 then mkILTyRef ( IlxSettings.ilxFsharpCoreLibScopeRef (), IlxSettings.ilxNamespace () + " .FSharpFunc`2" )
120120 else mkILNestedTyRef ( IlxSettings.ilxFsharpCoreLibScopeRef (),
121- [ IlxSettings.ilxNamespace () ^ " .OptimizedClosures" ],
122- " FSharpFunc`" ^ string ( n + 1 ))
121+ [ IlxSettings.ilxNamespace () + " .OptimizedClosures" ],
122+ " FSharpFunc`" + string ( n + 1 ))
123123type cenv =
124124 { ilg: ILGlobals ;
125125 tref_Func: ILTypeRef [];
@@ -128,7 +128,7 @@ type cenv =
128128let newIlxPubCloEnv ( ilg ) =
129129 { ilg= ilg;
130130 tref_ Func= Array.init 10 ( fun i -> mkFuncTypeRef( i+ 1 ));
131- mkILTyFuncTy= ILType.Boxed ( mkILNonGenericTySpec ( mkILTyRef ( IlxSettings.ilxFsharpCoreLibScopeRef (), IlxSettings.ilxNamespace () ^ " .FSharpTypeFunc" ))) }
131+ mkILTyFuncTy= ILType.Boxed ( mkILNonGenericTySpec ( mkILTyRef ( IlxSettings.ilxFsharpCoreLibScopeRef (), IlxSettings.ilxNamespace () + " .FSharpTypeFunc" ))) }
132132
133133let mkILTyFuncTy cenv = cenv.mkILTyFuncTy
134134
@@ -354,7 +354,6 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
354354 let nowTy = mkILFormalBoxedTy nowTypeRef td.GenericParams
355355 let nowCloRef = IlxClosureRef( nowTypeRef, clo.cloStructure, nowFields)
356356 let nowCloSpec = mkILFormalCloRef td.GenericParams nowCloRef
357- let tagClo = clo.cloSource
358357 let tagApp = ( Lazy.force clo.cloCode) .SourceMarker
359358
360359 let tyargsl , tmargsl , laterStruct = stripSupportedAbstraction clo.cloStructure
@@ -416,10 +415,10 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
416415 if ( match laterStruct with Lambdas_ return _ -> false | _ -> true ) then
417416
418417 let nowStruct = List.foldBack ( fun x y -> Lambdas_ forall( x, y)) tyargsl ( Lambdas_ return nowReturnTy)
419- let laterTypeName = td.Name^ " T"
418+ let laterTypeName = td.Name+ " T"
420419 let laterTypeRef = mkILNestedTyRef ( ILScopeRef.Local, encl, laterTypeName)
421420 let laterGenericParams = td.GenericParams @ addedGenParams
422- let selfFreeVar = mkILFreeVar( CompilerGeneratedName ( " self" ^ string nowFields.Length), true , nowCloSpec.ILType)
421+ let selfFreeVar = mkILFreeVar( CompilerGeneratedName ( " self" + string nowFields.Length), true , nowCloSpec.ILType)
423422 let laterFields = Array.append nowFields [| selfFreeVar |]
424423 let laterCloRef = IlxClosureRef( laterTypeRef, laterStruct, laterFields)
425424 let laterCloSpec = mkILFormalCloRef laterGenericParams laterCloRef
@@ -434,8 +433,6 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
434433 cloFreeVars= laterFields;
435434 cloCode= notlazy laterCode}
436435
437- let laterTypeDefs = laterTypeDefs |> List.map ( addMethodGeneratedAttrsToTypeDef cenv.ilg)
438-
439436 // This is the code which will get called when then "now"
440437 // arguments get applied. Convert it with the information
441438 // that it is the code for a closure...
@@ -456,6 +453,9 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
456453 let nowTypeDefs =
457454 convIlxClosureDef cenv encl td { clo with cloStructure= nowStruct;
458455 cloCode= notlazy nowCode}
456+
457+ let nowTypeDefs = nowTypeDefs |> List.map ( addMethodGeneratedAttrsToTypeDef cenv.ilg)
458+
459459 nowTypeDefs @ laterTypeDefs
460460 else
461461 // CASE 1b. Build a type application.
@@ -470,11 +470,12 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
470470 MethodBody.IL ( convILMethodBody ( Some nowCloSpec, boxReturnTy) ( Lazy.force clo.cloCode)))
471471 let ctorMethodDef =
472472 mkILStorageCtor
473- ( tagClo ,
473+ ( None ,
474474 [ mkLdarg0; mkNormalCall ( mkILCtorMethSpecForTy ( cenv.mkILTyFuncTy, [])) ],
475475 nowTy,
476476 mkILCloFldSpecs cenv nowFields,
477477 ILMemberAccess.Assembly)
478+ |> addMethodGeneratedAttrs cenv.ilg
478479
479480 let cloTypeDef =
480481 { Name = td.Name;
@@ -509,7 +510,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
509510 // CASE 2a - Too Many Term Arguments or Remaining Type arguments - Split the Closure Class in Two
510511 if ( match laterStruct with Lambdas_ return _ -> false | _ -> true ) then
511512 let nowStruct = List.foldBack ( fun l r -> Lambdas_ lambda( l, r)) nowParams ( Lambdas_ return nowReturnTy)
512- let laterTypeName = td.Name^ " D"
513+ let laterTypeName = td.Name+ " D"
513514 let laterTypeRef = mkILNestedTyRef ( ILScopeRef.Local, encl, laterTypeName)
514515 let laterGenericParams = td.GenericParams
515516 // Number each argument left-to-right, adding one to account for the "this" pointer
@@ -534,10 +535,13 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
534535 [ I_ newobj ( laterCloSpec.Constructor, None) ]
535536 end ,
536537 tagApp)
538+
537539 let nowTypeDefs =
538540 convIlxClosureDef cenv encl td { clo with cloStructure= nowStruct;
539541 cloCode= notlazy nowCode}
542+
540543 let laterCode = rewriteCodeToAccessArgsFromEnv laterCloSpec argToFreeVarMap
544+
541545 let laterTypeDefs =
542546 convIlxClosureDef cenv encl
543547 { td with GenericParams= laterGenericParams;
@@ -546,29 +550,35 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
546550 { clo with cloStructure= laterStruct;
547551 cloFreeVars= laterFields;
548552 cloCode= notlazy laterCode}
553+
549554 // add 'compiler generated' to all the methods in the 'now' classes
550- let laterTypeDefs = laterTypeDefs |> List.map ( addMethodGeneratedAttrsToTypeDef cenv.ilg)
555+ let nowTypeDefs = nowTypeDefs |> List.map ( addMethodGeneratedAttrsToTypeDef cenv.ilg)
556+
551557 nowTypeDefs @ laterTypeDefs
552558
553559 else
554560 // CASE 2b - Build an Term Application Apply method
555561 // CASE 2b2. Build a term application as a virtual method.
556562
557563 let nowEnvParentClass = typ_ Func cenv ( typesOfILParamsList nowParams) nowReturnTy
564+
558565 let cloTypeDef =
559566 let nowApplyMethDef =
560567 mkILNonGenericVirtualMethod
561568 ( " Invoke" , ILMemberAccess.Public,
562569 nowParams,
563570 mkILReturn nowReturnTy,
564571 MethodBody.IL ( convILMethodBody ( Some nowCloSpec, None) ( Lazy.force clo.cloCode)))
572+
565573 let ctorMethodDef =
566574 mkILStorageCtor
567- ( tagClo ,
575+ ( None ,
568576 [ mkLdarg0; mkNormalCall ( mkILCtorMethSpecForTy ( nowEnvParentClass,[])) ],
569577 nowTy,
570578 mkILCloFldSpecs cenv nowFields,
571579 ILMemberAccess.Assembly)
580+ |> addMethodGeneratedAttrs cenv.ilg
581+
572582 { Name = td.Name;
573583 GenericParams= td.GenericParams;
574584 Access = td.Access;
@@ -592,12 +602,15 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
592602 HasSecurity= false ;
593603 SecurityDecls= emptyILSecurityDecls;
594604 tdKind = ILTypeDefKind.Class; }
605+
595606 [ cloTypeDef]
596- | [],[ ], Lambdas_ return _ ->
607+
608+ | [],[], Lambdas_ return _ ->
609+
597610 // No code is being declared: just bake a (mutable) environment
598611 let cloCode ' =
599612 match td.Extends with
600- | None -> ( mkILNonGenericEmptyCtor tagClo cenv.ilg.typ_ Object) .MethodBody
613+ | None -> ( mkILNonGenericEmptyCtor None cenv.ilg.typ_ Object) .MethodBody
601614 | Some _ -> convILMethodBody ( Some nowCloSpec, None) ( Lazy.force clo.cloCode)
602615
603616 let ctorMethodDef =
@@ -615,7 +628,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
615628 mkNormalStfld ( mkILFieldSpecInTy ( nowTy, nm, ty));
616629 ]) flds))
617630 cloCode'.Code,
618- tagClo ))
631+ None ))
619632
620633 let cloTypeDef =
621634 { td with
@@ -626,9 +639,11 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
626639 Methods= mkILMethods ( ctorMethodDef :: List.map ( convMethodDef ( Some nowCloSpec)) td.Methods.AsList);
627640 Fields= mkILFields ( mkILCloFldDefs cenv nowFields @ td.Fields.AsList);
628641 tdKind = ILTypeDefKind.Class; }
642+
629643 [ cloTypeDef]
644+
630645 | a, b,_ ->
631- failwith ( " Unexpected unsupported abstraction sequence, #tyabs = " ^ string a.Length ^ " , #tmabs = " ^ string b.Length)
646+ failwith ( " Unexpected unsupported abstraction sequence, #tyabs = " + string a.Length + " , #tmabs = " + string b.Length)
632647
633648 newTypeDefs
634649
0 commit comments