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

Commite4fb0fc

Browse files
forkidsyme
authored andcommitted
small cleanups in MethodCalls.fs (dotnet#4435)
1 parented8393c commite4fb0fc

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

‎src/fsharp/MethodCalls.fs‎

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -530,22 +530,21 @@ let ComputeConstrainedCallInfo g amap m (objArgs,minfo:MethInfo) =
530530
/// Adjust the 'this' pointer before making a call
531531
/// Take the address of a struct, and coerce to an interface/base/constraint type if necessary
532532
letTakeObjAddrForMethodCall g amap(minfo:MethInfo)isMutable m objArgs f=
533-
letccallInfo= ComputeConstrainedCallInfo g amap m(objArgs,minfo)
534-
letmustTakeAddress=
535-
(minfo.IsStruct&&not minfo.IsExtensionMember)// don't take the address of a struct when passing to an extension member
536-
||
537-
(match ccallInfowith
538-
| Some_->true
539-
| None->false)
533+
letccallInfo= ComputeConstrainedCallInfo g amap m(objArgs,minfo)
534+
540535
letwrap,objArgs=
541536
match objArgswith
542-
|[objArgExpr]->
537+
|[objArgExpr]->
538+
lethasCallInfo= ccallInfo.IsSome
539+
letmustTakeAddress=
540+
(minfo.IsStruct&&not minfo.IsExtensionMember)// don't take the address of a struct when passing to an extension member
541+
|| hasCallInfo
543542
letobjArgTy= tyOfExpr g objArgExpr
544-
letwrap,objArgExpr'= mkExprAddrOfExpr g mustTakeAddress(Option.isSome ccallInfo) isMutable objArgExpr None m
543+
letwrap,objArgExpr'= mkExprAddrOfExpr g mustTakeAddresshasCallInfo isMutable objArgExpr None m
545544

546545
// Extension members and calls to class constraints may need a coercion for their object argument
547546
letobjArgExpr'=
548-
ifOption.isNone ccallInfo&&// minfo.IsExtensionMember && minfo.IsStruct &&
547+
ifnot hasCallInfo&&// minfo.IsExtensionMember && minfo.IsStruct &&
549548
not(TypeDefinitelySubsumesTypeNoCoercion0 g amap m minfo.ApparentEnclosingType objArgTy)then
550549
mkCoerceExpr(objArgExpr',minfo.ApparentEnclosingType,m,objArgTy)
551550
else
@@ -554,7 +553,7 @@ let TakeObjAddrForMethodCall g amap (minfo:MethInfo) isMutable m objArgs f =
554553
wrap,[objArgExpr']
555554

556555
|_->
557-
(fun x-> x), objArgs
556+
id, objArgs
558557
lete,ety= f ccallInfo objArgs
559558
wrap e,ety
560559

@@ -579,7 +578,7 @@ let BuildILMethInfoCall g amap m isProp (minfo:ILMethInfo) valUseFlags minst dir
579578
letilMethRef= minfo.ILMethodRef
580579
letnewobj= ctor&&(match valUseFlagswith NormalValUse->true|_->false)
581580
letexprTy=if ctorthen minfo.ApparentEnclosingTypeelse minfo.GetFSharpReturnTy(amap, m, minst)
582-
letretTy=(ifnot ctor&&(ilMethRef.ReturnType= ILType.Void)then[]else[exprTy])
581+
letretTy=ifnot ctor&& ilMethRef.ReturnType= ILType.Voidthen[]else[exprTy]
583582
letisDllImport= minfo.IsDllImport g
584583
Expr.Op(TOp.ILCall(useCallvirt,isProtected,valu,newobj,valUseFlags,isProp,isDllImport,ilMethRef,minfo.DeclaringTypeInst,minst,retTy),[],args,m),
585584
exprTy
@@ -604,9 +603,7 @@ let BuildFSharpMethodApp g m (vref: ValRef) vexp vexprty (args: Exprs) =
604603
((args,vexprty), arities)||> List.mapFold(fun(args,fty)arity->
605604
match arity,argswith
606605
|(0|1),[]when typeEquiv g(domainOfFunTy g fty) g.unit_ty-> mkUnit g m,(args, rangeOfFunTy g fty)
607-
|0,(arg::argst)->
608-
609-
606+
|0,(arg::argst)->
610607
warning(InternalError(sprintf"Unexpected zero arity, args =%s"(Layout.showL(Layout.sepListL(Layout.rightL(Layout.TaggedTextOps.tagText";"))(List.map exprL args))),m));
611608
arg,(argst, rangeOfFunTy g fty)
612609
|1,(arg:: argst)-> arg,(argst, rangeOfFunTy g fty)
@@ -673,9 +670,8 @@ let TryImportProvidedMethodBaseAsLibraryIntrinsic (amap:Import.ImportMap, m:rang
673670
|_->
674671
match amap.g.knownFSharpCoreModules.TryGetValue(declaringEntity.LogicalName)with
675672
|true,modRef->
676-
match modRef.ModuleOrNamespaceType.AllValsByLogicalName|> Seq.tryPick(fun(KeyValue(_,v))->if v.CompiledName= methodNamethen Some velse None)with
677-
| Some v-> Some(mkNestedValRef modRef v)
678-
| None-> None
673+
modRef.ModuleOrNamespaceType.AllValsByLogicalName
674+
|> Seq.tryPick(fun(KeyValue(_,v))->if v.CompiledName= methodNamethen Some(mkNestedValRef modRef v)else None)
679675
|_-> None
680676
else
681677
None
@@ -693,13 +689,12 @@ let TryImportProvidedMethodBaseAsLibraryIntrinsic (amap:Import.ImportMap, m:rang
693689
// objArgs: the 'this' argument, if any
694690
// args: the arguments, if any
695691
letBuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objArgs args=
696-
697692
letdirect= IsBaseCall objArgs
698693

699694
TakeObjAddrForMethodCall g amap minfo isMutable m objArgs(fun ccallInfo objArgs->
700-
letallArgs=(objArgs@ args)
695+
letallArgs= objArgs@ args
701696
letvalUseFlags=
702-
if(direct&&(match valUseFlagswith NormalValUse->true|_->false))then
697+
if direct&&(match valUseFlagswith NormalValUse->true|_->false)then
703698
VSlotDirectCall
704699
else
705700
match ccallInfowith
@@ -722,7 +717,7 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA
722717
// these calls are provided by the runtime and should not be called from the user code
723718
if isArrayTy g enclTythen
724719
lettpe= TypeProviderError(FSComp.SR.tcRuntimeSuppliedMethodCannotBeUsedInUserCode(minfo.DisplayName), providedMeth.TypeProviderDesignation, m)
725-
error(tpe)
720+
error tpe
726721
letvalu= isStructTy g enclTy
727722
letisCtor= minfo.IsConstructor
728723
if minfo.IsClassConstructorthen
@@ -747,7 +742,7 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA
747742
elif isFunTy g enclTythen[ domainOfFunTy g enclTy; rangeOfFunTy g enclTy]// provided expressions can call Invoke
748743
else minfo.DeclaringTypeInst
749744
letactualMethInst= minst
750-
letretTy=(ifnot isCtor&&(ilMethRef.ReturnType= ILType.Void)then[]else[exprTy])
745+
letretTy=ifnot isCtor&&(ilMethRef.ReturnType= ILType.Void)then[]else[exprTy]
751746
letnoTailCall=false
752747
letexpr= Expr.Op(TOp.ILCall(useCallvirt,isProtected,valu,isNewObj,valUseFlags,isProp,noTailCall,ilMethRef,actualTypeInst,actualMethInst, retTy),[],allArgs,m)
753748
expr,exprTy
@@ -1191,7 +1186,7 @@ module ProvidedMethodCalls =
11911186
|> Array.map(fun pty-> eraseSystemType(amap,m,pty))
11921187
letparamVars=
11931188
erasedParamTys
1194-
|> Array.mapi(fun i erasedParamTy-> erasedParamTy.PApply((fun ty->ProvidedVar.Fresh("arg"+ i.ToString(),ty)),m))
1189+
|> Array.mapi(fun i erasedParamTy-> erasedParamTy.PApply((fun ty-> ProvidedVar.Fresh("arg"+ i.ToString(),ty)),m))
11951190

11961191

11971192
// encode "this" as the first ParameterExpression, if applicable

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp