示例#1
0
文件: Contains.cs 项目: SealedSun/prx
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null)
                throw new ArgumentNullException("args");

            PValue needle;
            if (args.Length < 2)
                return false;
            else
                needle = args[0];

            foreach (var arg in args.Skip(1))
            {
                var set = Map._ToEnumerable(sctx, arg);
                if (set != null)
                    foreach (var value in set)
                    {
                        PValue result;
                        bool boolResult;
                        if (value.Equality(sctx, needle, out result) &&
                            result.TryConvertTo(sctx, true, out boolResult) && boolResult)
                            return result;
                    }
            }

            return false;
        }
示例#2
0
        // ReSharper disable MemberCanBePrivate.Global
        // Part of CIL compiler infrastructure.
        public static PValue RunStatically(StackContext sctx, PValue[] args)

        {
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null || args.Length == 0 || args[0] == null)
                throw new PrexoniteException("The thunk command requires an expression.");

            var expr = args[0];
            var parameters = args.Skip(1).Select(_EnforceThunk).ToArray();

            return PType.Object.CreatePValue(Thunk.NewExpression(expr, parameters));
        }
示例#3
0
文件: Select.cs 项目: SealedSun/prx
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            bool performSubCall;
            if (args.Length > 0 && args[0].Type.ToBuiltIn() == PType.BuiltIn.Bool)
                performSubCall = (bool) args[0].Value;
            else
                performSubCall = false;

            var rawCases = new List<PValue>();
            foreach (var arg in args.Skip(performSubCall ? 1 : 0))
            {
                var set = Map._ToEnumerable(sctx, arg);
                if (set == null)
                    continue;
                else
                    rawCases.AddRange(set);
            }

            var appCases =
                rawCases.Select(c => _isApplicable(sctx, c)).Where(x => x != null).Select(_extract).
                    ToArray();

            return RunStatically(sctx, appCases, performSubCall);
        }