Exemplo n.º 1
0
        private IEnumerable <Expression> GetParametersForSwitchCase(int pArgsLength)
        {
            int k = 0;

            for (int i = 0, length = parameters.Length - (tailArray ? 1 : 0); i < length; i++)
            {
                if (i == posNew)
                {
                    yield return(EcmaValueUtility.ConvertFromEcmaValueExpression(pNewTarget, parameters[i].ParameterType));
                }
                else if (i == posThis)
                {
                    yield return(EcmaValueUtility.ConvertFromEcmaValueExpression(pThisArg, parameters[i].ParameterType));
                }
                else if (k >= pArgsLength)
                {
                    yield return(GetDefaultExpression(parameters[i].ParameterType));
                }
                else
                {
                    yield return(GetArgumentFromArray(k++, i));
                }
            }
            if (tailArray)
            {
                if (k >= pArgsLength)
                {
                    yield return(Expression.MakeMemberAccess(null, typeof(EcmaValue).GetField("EmptyArray", BindingFlags.Static | BindingFlags.Public)));
                }
                else
                {
                    yield return(GetTailArray(k));
                }
            }
        }
Exemplo n.º 2
0
        private IEnumerable <Expression> GetParametersForSwitchDefault()
        {
            int k = 0;

            for (int i = 0, length = parameters.Length - (tailArray ? 1 : 0); i < length; i++)
            {
                if (i == posNew)
                {
                    yield return(EcmaValueUtility.ConvertFromEcmaValueExpression(pNewTarget, parameters[i].ParameterType));
                }
                else if (i == posThis)
                {
                    yield return(EcmaValueUtility.ConvertFromEcmaValueExpression(pThisArg, parameters[i].ParameterType));
                }
                else
                {
                    yield return(Expression.Condition(
                                     Expression.GreaterThan(Expression.Property(pArgs, "Length"), Expression.Constant(i)),
                                     EcmaValueUtility.ConvertFromEcmaValueExpression(Expression.ArrayIndex(pArgs, Expression.Constant(k++)), parameters[i].ParameterType),
                                     GetDefaultExpression(parameters[i].ParameterType)));
                }
            }
            if (tailArray)
            {
                yield return(GetTailArray(k));
            }
        }
Exemplo n.º 3
0
 private Expression GetArgumentFromArray(int argsIndex, int nativeParameterIndex)
 {
     return(EcmaValueUtility.ConvertFromEcmaValueExpression(Expression.ArrayIndex(pArgs, Expression.Constant(argsIndex)), parameters[nativeParameterIndex].ParameterType));
 }