/// <summary> /// Resolves list of input arguments. /// Implicit parameters passed by compiler are ignored. /// </summary> /// <param name="routine">Routine.</param> /// <param name="ctx">TYpe context to transmer type masks into.</param> /// <returns>List of input PHP arguments.</returns> public static PhpParam[] GetExpectedArguments(this IPhpRoutineSymbol routine, TypeRefContext ctx) { Contract.ThrowIfNull(routine); var ps = routine.Parameters; var table = (routine as SourceRoutineSymbol)?.LocalsTable; var result = new List <PhpParam>(ps.Length); foreach (ParameterSymbol p in ps) { if (result.Count == 0 && p.IsImplicitlyDeclared) { continue; } // default value (bound expression) ConstantValue cvalue; var psrc = p as SourceParameterSymbol; var defaultexpr = psrc != null ? psrc.Initializer : ((cvalue = p.ExplicitDefaultConstantValue) != null ? new BoundLiteral(cvalue.Value) : null); // var phpparam = new PhpParam( TypeRefFactory.CreateMask(ctx, p.Type), p.RefKind != RefKind.None, p.IsParams, defaultexpr); result.Add(phpparam); } // return(result.ToArray()); }
/// <summary> /// Resolves list of input arguments. /// Implicit parameters passed by compiler are ignored. /// </summary> /// <param name="routine">Routine.</param> /// <param name="ctx">Type context to transfer type masks into.</param> /// <returns>List of input PHP arguments.</returns> public static IList <PhpParam> GetExpectedArguments(this IPhpRoutineSymbol routine, TypeRefContext ctx) { Contract.ThrowIfNull(routine); Contract.ThrowIfNull(ctx); List <PhpParam> result = null; int index = 0; var ps = routine.Parameters; foreach (ParameterSymbol p in ps) { if (result == null && p.IsImplicitlyDeclared && !p.IsParams) { continue; } // var phpparam = new PhpParam(p, index++, TypeRefFactory.CreateMask(ctx, p.Type, notNull: p.HasNotNull)); result ??= new List <PhpParam>(ps.Length); result.Add(phpparam); } // return(result ?? (IList <PhpParam>)Array.Empty <PhpParam>()); }
/// <summary> /// Resolves list of input arguments. /// Implicit parameters passed by compiler are ignored. /// </summary> /// <param name="routine">Routine.</param> /// <param name="ctx">Type context to transfer type masks into.</param> /// <returns>List of input PHP arguments.</returns> public static IList <PhpParam> GetExpectedArguments(this IPhpRoutineSymbol routine, TypeRefContext ctx) { Contract.ThrowIfNull(routine); Contract.ThrowIfNull(ctx); List <PhpParam> result = null; int index = 0; var ps = routine.Parameters; foreach (ParameterSymbol p in ps) { if (result == null && p.IsImplicitlyDeclared && !p.IsParams) { continue; } // var phpparam = new PhpParam( index++, TypeRefFactory.CreateMask(ctx, p.Type, notNull: p.HasNotNullAttribute()), p.RefKind != RefKind.None, p.IsParams, isPhpRw: p.GetPhpRwAttribute() != null, defaultValue: p.Initializer); if (result == null) { result = new List <PhpParam>(ps.Length); } result.Add(phpparam); } // return(result ?? (IList <PhpParam>)Array.Empty <PhpParam>()); }
/// <summary> /// Resolves list of input arguments. /// Implicit parameters passed by compiler are ignored. /// </summary> /// <param name="routine">Routine.</param> /// <param name="ctx">TYpe context to transmer type masks into.</param> /// <returns>List of input PHP arguments.</returns> public static PhpParam[] GetExpectedArguments(this IPhpRoutineSymbol routine, TypeRefContext ctx) { Contract.ThrowIfNull(routine); var ps = routine.Parameters; var table = (routine as SourceRoutineSymbol)?.LocalsTable; var result = new List<PhpParam>(ps.Length); foreach (ParameterSymbol p in ps) { if (result.Count == 0 && p.IsImplicitlyDeclared) { continue; } // default value (bound expression) ConstantValue cvalue; var psrc = p as SourceParameterSymbol; var defaultexpr = psrc != null ? psrc.Initializer : ((cvalue = p.ExplicitDefaultConstantValue) != null ? new BoundLiteral(cvalue.Value) : null); // var phpparam = new PhpParam( TypeRefFactory.CreateMask(ctx, p.Type), p.RefKind != RefKind.None, p.IsParams, defaultexpr); result.Add(phpparam); } // return result.ToArray(); }