@@ -2249,16 +2249,9 @@ internal override TypeSymbol Emit(CodeGenerator cg)
2249
2249
{
2250
2250
if ( ! TargetMethod . IsErrorMethod ( ) )
2251
2251
{
2252
- if ( this . HasArgumentsUnpacking )
2253
- {
2254
- return EmitDirectCall_UnpackingArgs ( cg , IsVirtualCall ? ILOpCode . Callvirt : ILOpCode . Call , TargetMethod , LateStaticTypeRef ) ;
2255
- }
2256
- else
2257
- {
2258
- // the most preferred case when both method and arguments are known,
2259
- // the method can be called directly
2260
- return EmitDirectCall ( cg , IsVirtualCall ? ILOpCode . Callvirt : ILOpCode . Call , TargetMethod , LateStaticTypeRef ) ;
2261
- }
2252
+ // the most preferred case when method is known,
2253
+ // the method can be called directly
2254
+ return EmitDirectCall ( cg , IsVirtualCall ? ILOpCode . Callvirt : ILOpCode . Call , TargetMethod , LateStaticTypeRef ) ;
2262
2255
}
2263
2256
2264
2257
//
@@ -2278,15 +2271,12 @@ internal virtual TypeSymbol EmitDirectCall(CodeGenerator cg, ILOpCode opcode, Me
2278
2271
// TODO: in case of a global user routine -> emit check the function is declared
2279
2272
// <ctx>.AssertFunctionDeclared
2280
2273
2281
- return ( this . ResultType = cg . EmitMethodAccess ( cg . EmitCall ( opcode , method , this . Instance , _arguments , staticType ) , method , Access ) ) ;
2282
- }
2283
-
2284
- internal TypeSymbol EmitDirectCall_UnpackingArgs ( CodeGenerator cg , ILOpCode opcode , MethodSymbol method , BoundTypeRef staticType = null )
2285
- {
2286
- // TODO: in case of a global user routine -> emit check the function is declared
2287
- // <ctx>.AssertFunctionDeclared
2274
+ var stacktype = this . HasArgumentsUnpacking
2275
+ ? cg . EmitCall_UnpackingArgs ( opcode , method , this . Instance , _arguments , staticType ) // call method with respect to argument unpacking
2276
+ : cg . EmitCall ( opcode , method , this . Instance , _arguments , staticType ) ; // call method and pass provided arguments as they are
2288
2277
2289
- return ( this . ResultType = cg . EmitMethodAccess ( cg . EmitCall_UnpackingArgs ( opcode , method , this . Instance , _arguments , staticType ) , method , Access ) ) ;
2278
+ //
2279
+ return ( this . ResultType = cg . EmitMethodAccess ( stacktype , method , Access ) ) ;
2290
2280
}
2291
2281
2292
2282
protected virtual string CallsiteName => null ;
@@ -2410,7 +2400,7 @@ internal override TypeSymbol EmitDynamicCall(CodeGenerator cg)
2410
2400
2411
2401
cg . EmitConvert ( _name . NameExpression , cg . CoreTypes . IPhpCallable ) ; // (IPhpCallable)Name
2412
2402
cg . EmitLoadContext ( ) ; // Context
2413
- cg . Emit_ArgumentsIntoArray ( _arguments ) ; // PhpValue[]
2403
+ cg . Emit_ArgumentsIntoArray ( _arguments , default ( PhpSignatureMask ) ) ; // PhpValue[]
2414
2404
2415
2405
return cg . EmitCall ( ILOpCode . Callvirt , cg . CoreTypes . IPhpCallable . Symbol . LookupMember < MethodSymbol > ( "Invoke" ) ) ;
2416
2406
}
@@ -2498,7 +2488,7 @@ internal override TypeSymbol Emit(CodeGenerator cg)
2498
2488
2499
2489
private TypeSymbol EmitNewClass ( CodeGenerator cg )
2500
2490
{
2501
- if ( ! TargetMethod . IsErrorMethod ( ) && ! this . HasArgumentsUnpacking )
2491
+ if ( ! TargetMethod . IsErrorMethod ( ) )
2502
2492
{
2503
2493
return EmitDirectCall ( cg , ILOpCode . Newobj , TargetMethod ) ;
2504
2494
}
@@ -2515,9 +2505,9 @@ private TypeSymbol EmitNewClass(CodeGenerator cg)
2515
2505
. Single ( )
2516
2506
. Construct ( _typeref . ResolvedType ) ;
2517
2507
2518
- cg . EmitLoadContext ( ) ; // Context
2519
- cg . EmitCallerRuntimeTypeHandle ( ) ; // RuntimeTypeHandle
2520
- cg . Emit_ArgumentsIntoArray ( _arguments ) ; // PhpValue[]
2508
+ cg . EmitLoadContext ( ) ; // Context
2509
+ cg . EmitCallerRuntimeTypeHandle ( ) ; // RuntimeTypeHandle
2510
+ cg . Emit_ArgumentsIntoArray ( _arguments , default ( PhpSignatureMask ) ) ; // PhpValue[]
2521
2511
2522
2512
return cg . EmitCall ( ILOpCode . Call , create_t ) ;
2523
2513
}
@@ -2532,10 +2522,10 @@ private TypeSymbol EmitNewClass(CodeGenerator cg)
2532
2522
SpecialParameterSymbol . IsCallerClassParameter ( s . Parameters [ 0 ] ) )
2533
2523
. Single ( ) ;
2534
2524
2535
- cg . EmitLoadContext ( ) ; // Context
2536
- cg . EmitCallerRuntimeTypeHandle ( ) ; // RuntimeTypeHandle
2537
- _typeref . EmitLoadTypeInfo ( cg , true ) ; // PhpTypeInfo
2538
- cg . Emit_ArgumentsIntoArray ( _arguments ) ; // PhpValue[]
2525
+ cg . EmitLoadContext ( ) ; // Context
2526
+ cg . EmitCallerRuntimeTypeHandle ( ) ; // RuntimeTypeHandle
2527
+ _typeref . EmitLoadTypeInfo ( cg , true ) ; // PhpTypeInfo
2528
+ cg . Emit_ArgumentsIntoArray ( _arguments , default ( PhpSignatureMask ) ) ; // PhpValue[]
2539
2529
2540
2530
return cg . EmitCall ( ILOpCode . Call , create ) ;
2541
2531
}
0 commit comments