コード例 #1
0
ファイル: CreateSourcePosition.cs プロジェクト: SealedSun/prx
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            if (args.Length == 0)
            {
                return sctx.CreateNativePValue(NoSourcePosition.Instance);
            }

            string file = args[0].CallToString(sctx);
            int? line, column;

            PValue box;
            if (args.Length >= 2 && args[1].TryConvertTo(sctx, IntPType.Instance,true,out box))
            {
                line = (int) box.Value;
            }
            else
            {
                line = null;
            }

            if (args.Length >= 3 && args[2].TryConvertTo(sctx, IntPType.Instance, true, out box))
            {
                column = (int) box.Value;
            }
            else
            {
                column = null;
            }

            return sctx.CreateNativePValue(new SourcePosition(file, line ?? -1, column ?? -1));
        }
コード例 #2
0
ファイル: Print.cs プロジェクト: SealedSun/prx
        /// <summary>
        ///     Prints all arguments.
        /// </summary>
        /// <param name = "sctx">The context in which to convert the arguments to strings.</param>
        /// <param name = "args">The list of arguments to print.</param>
        /// <returns></returns>
        public override PValue Run(StackContext sctx, PValue[] args)
        {
            var s = Concat.ConcatenateString(sctx, args);
            _writer.Write(s);

            return s;
        }
コード例 #3
0
ファイル: ForAll.cs プロジェクト: SealedSun/prx
        public override PValue Run(StackContext sctx, PValue[] args)
        {
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null)
                throw new ArgumentNullException("args");

            if (args.Length < 1)
                throw new PrexoniteException("Exists requires at least two arguments");
            var f = args[0];

            var eargs = new PValue[1];
            for (var i = 1; i < args.Length; i++)
            {
                var arg = args[i];
                var set = Map._ToEnumerable(sctx, arg);
                if (set == null)
                    continue;
                foreach (var value in set)
                {
                    eargs[0] = value;
                    var result = f.IndirectCall(sctx, eargs);
                    PValue existance;
                    if ((!result.TryConvertTo(sctx, PType.Bool, true, out existance)) ||
                        (!(bool) existance.Value))
                        return false;
                }
            }

            return true;
        }
コード例 #4
0
ファイル: HashPType.cs プロジェクト: SealedSun/prx
        public override bool IndirectCall(
            StackContext sctx, PValue subject, PValue[] args, out PValue result)
        {
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (subject == null)
                throw new ArgumentNullException("subject");
            if (args == null)
                args = new PValue[] {};

            result = null;

            var argc = args.Length;

            var pvht = (PValueHashtable) subject.Value;

            if (argc == 0)
            {
                result =
                    sctx.CreateNativePValue(new PValueEnumeratorWrapper(pvht.GetPValueEnumerator()));
            }
            else if (argc == 1)
            {
                if (!pvht.TryGetValue(args[0], out result))
                    result = false;
            }
            else
            {
                pvht.AddOverride(args[0], args[1]);
            }

            return result != null;
        }
コード例 #5
0
ファイル: ThenCommand.cs プロジェクト: SealedSun/prx
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            if (args.Length < 2)
                throw new PrexoniteException("then command requires two arguments.");

            return sctx.CreateNativePValue(new CallComposition(args[0], args[1]));
        }
コード例 #6
0
ファイル: Call_Member.cs プロジェクト: SealedSun/prx
        /// <summary>
        ///     Implementation of (obj, [isSet, ] id, arg1, arg2, arg3, ..., argn) ⇒ obj.id(arg1, arg2, arg3, ..., argn);
        /// </summary>
        /// <remarks>
        ///     <para>
        ///         Wrap Lists in other lists, if you want to pass them without being unfolded: 
        ///         <code>
        ///             function main()
        ///             {   var myList = [1, 2];
        ///             var obj = "{1}hell{0}";
        ///             print( call\member(obj, "format",  [ myList ]) );
        ///             }
        /// 
        ///             //Prints "2hell1"
        ///         </code>
        ///     </para>
        /// </remarks>
        /// <param name = "sctx">The stack context in which to call the callable argument.</param>
        /// <param name = "args">A list of the form [ obj, id, arg1, arg2, arg3, ..., argn].<br />
        ///     Lists and coroutines are expanded.</param>
        /// <returns>The result returned by the member call.</returns>
        public override PValue Run(StackContext sctx, PValue[] args)
        {
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null || args.Length < 2 || args[0] == null)
                throw new ArgumentException(
                    "The command callmember has the signature(obj, [isSet,] id [, arg1, arg2,...,argn]).");

            var isSet = false;
            string id;
            var i = 2;

            if (args[1].Type == PType.Bool && args.Length > 2)
            {
                isSet = (bool) args[1].Value;
                id = args[i++].CallToString(sctx);
            }
            else
            {
                id = args[1].CallToString(sctx);
            }


            var iargs = new PValue[args.Length - i];
            Array.Copy(args, i, iargs, 0, iargs.Length);

            return Run(sctx, args[0], isSet, id, iargs);
        }
コード例 #7
0
ファイル: Each.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");

            if (args.Length < 1)
                throw new PrexoniteException("Each requires at least two arguments");
            var f = args[0];

            var eargs = new PValue[1];
            for (var i = 1; i < args.Length; i++)
            {
                var arg = args[i];
                var set = Map._ToEnumerable(sctx, arg);
                if (set == null)
                    continue;
                foreach (var value in set)
                {
                    eargs[0] = value;
                    f.IndirectCall(sctx, eargs);
                }
            }

            return PType.Null;
        }
コード例 #8
0
ファイル: SetRightCommand.cs プロジェクト: SealedSun/prx
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            // function setright(w,s,f)
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null)
                args = new PValue[] {};

            string s;
            string f;

            switch (args.Length)
            {
                case 0:
                    return "";
                case 1:
                    s = "";
                    goto parseW;
            }
            s = args[1].CallToString(sctx);
            parseW:
            var w = (int) args[0].ConvertTo(sctx, PType.Int).Value;
            if (args.Length > 2)
                f = args[2].CallToString(sctx);
            else
                f = " ";

            return SetRight(w, s, f);
        }
コード例 #9
0
ファイル: Char.cs プロジェクト: SealedSun/prx
        /// <summary>
        ///     Executes the command.
        /// </summary>
        /// <param name = "sctx">The stack context in which to execut the command.</param>
        /// <param name = "args">The arguments to be passed to the command.</param>
        /// <returns>The value returned by the command. Must not be null. (But possibly {null~Null})</returns>
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null)
                throw new ArgumentNullException("args");

            if (args.Length < 1)
                throw new PrexoniteException("Char requires at least one argument.");

            PValue v;
            var arg = args[0];
            if (arg.Type == PType.String)
            {
                var s = (string) arg.Value;
                if (s.Length == 0)
                    throw new PrexoniteException("Cannot create char from empty string.");
                else
                    return s[0];
            }
            else if (arg.TryConvertTo(sctx, PType.Char, true, out v))
            {
                return v;
            }
            else if (arg.TryConvertTo(sctx, PType.Int, true, out v))
            {
                return (char) (int) v.Value;
            }
            else
            {
                throw new PrexoniteException("Cannot create char from " + arg);
            }
        }
コード例 #10
0
        public bool TryDefer(StackContext sctx, PValue[] args,
            out StackContext partialApplicationContext, out PValue result)
        {
            var effectiveArgs = _getEffectiveArgs(args);

            partialApplicationContext = null;
            result = null;

            //The following code exists in a very similar form in PartialCall.cs, FunctionalPartialCall.cs
            if ((_subject.Type is ObjectPType))
            {
                var raw = _subject.Value;
                var stackAware = raw as IStackAware;
                if (stackAware != null)
                {
                    partialApplicationContext = stackAware.CreateStackContext(sctx, effectiveArgs);
                    return true;
                }

                var partialApplication = raw as IMaybeStackAware;
                if (partialApplication != null)
                    return partialApplication.TryDefer(sctx, effectiveArgs,
                        out partialApplicationContext,
                        out result);
            }

            result = _subject.IndirectCall(sctx, effectiveArgs);
            return false;
        }
コード例 #11
0
ファイル: SeqConcat.cs プロジェクト: SealedSun/prx
 public static PValue RunStatically(StackContext sctx, PValue[] args)
 {
     var carrier = new ContextCarrier();
     var corctx = new CoroutineContext(sctx, CoroutineRunStatically(carrier, args));
     carrier.StackContext = corctx;
     return sctx.CreateNativePValue(new Coroutine(corctx));
 }
コード例 #12
0
ファイル: CallAsync.cs プロジェクト: SealedSun/prx
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null || args.Length == 0 || args[0] == null)
                return PType.Null.CreatePValue();

            var iargs = Call.FlattenArguments(sctx, args, 1);

            var retChan = new Channel();
            var T = new Thread(() =>
                {
                    PValue result;
                    try
                    {
                        result = args[0].IndirectCall(sctx, iargs.ToArray());
                    }
                    catch (Exception ex)
                    {
                        result = sctx.CreateNativePValue(ex);
                    }
                    retChan.Send(result);
                })
                {
                    IsBackground = true
                };
            T.Start();
            return PType.Object.CreatePValue(retChan);
        }
コード例 #13
0
ファイル: PartialCall.cs プロジェクト: SealedSun/prx
        protected override bool DoTryDefer(StackContext sctx, PValue[] nonArguments,
            PValue[] arguments, out StackContext partialApplicationContext, out PValue result)
        {
            partialApplicationContext = null;
            result = null;

            //The following code exists in a very similar form in FunctionalPartialCall.cs, FlippedFunctionalPartialCall.cs
            if ((nonArguments[0].Type is ObjectPType))
            {
                var raw = nonArguments[0].Value;
                var stackAware = raw as IStackAware;
                if (stackAware != null)
                {
                    partialApplicationContext = stackAware.CreateStackContext(sctx, arguments);
                    return true;
                }

                var partialApplication = raw as IMaybeStackAware;
                if (partialApplication != null)
                    return partialApplication.TryDefer(sctx, arguments,
                        out partialApplicationContext,
                        out result);
            }

            result = Invoke(sctx, nonArguments, arguments);
            return false;
        }
コード例 #14
0
ファイル: Operators.cs プロジェクト: SealedSun/prx
		public override PValue Run(StackContext sctx, PValue[] args)
		{
			if(args.Length < 2)
				throw new PrexoniteException("The Subtraction operator requires two arguments.");

			return args[0].Subtraction(sctx,args[1]);			
		}
コード例 #15
0
ファイル: Sum.cs プロジェクト: SealedSun/prx
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            if (args == null)
                throw new ArgumentNullException("args");
            if (sctx == null)
                throw new ArgumentNullException("sctx");

            //let sum xs acc = Seq.foldl (fun a b -> a + b) acc xs

            PValue acc;
            IEnumerable<PValue> xsArgs;

            if (args.Length == 0)
                return PType.Null;

            if (args.Length == 1)
            {
                acc = PType.Null;
                xsArgs = args;
            }
            else
            {
                acc = args[args.Length - 1];
                xsArgs = args.Take(args.Length - 1);
            }

            var xss = xsArgs.Select(e => Map._ToEnumerable(sctx, e)).Where(e => e != null);

            foreach (var xs in xss)
                foreach (var x in xs)
                    acc = acc.Addition(sctx, x);

            return acc;
        }
コード例 #16
0
ファイル: Except.cs プロジェクト: SealedSun/prx
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            if (args == null)
                throw new ArgumentNullException("args");
            if (sctx == null)
                throw new ArgumentNullException("sctx");

            var xss = new List<IEnumerable<PValue>>();
            foreach (var arg in args)
            {
                var xs = Map._ToEnumerable(sctx, arg);
                if (xs != null)
                    xss.Add(xs);
            }

            var n = xss.Count;
            if (n < 2)
                throw new PrexoniteException("Except requires at least two sources.");

            var t = new Dictionary<PValue, bool>();
            //All elements of the last source are considered candidates
            foreach (var x in xss[n - 1])
                if (!t.ContainsKey(x))
                    t.Add(x, true);

            for (var i = 0; i < n - 1; i++)
                foreach (var x in xss[i])
                    if (t.ContainsKey(x))
                        t.Remove(x);

            return sctx.CreateNativePValue(t.Keys);
        }
コード例 #17
0
ファイル: StaticPrintLine.cs プロジェクト: SealedSun/prx
        /// <summary>
        ///     Executes the command.
        /// </summary>
        /// <param name = "sctx">The stack context in which to execut the command.</param>
        /// <param name = "args">The arguments to be passed to the command.</param>
        /// <returns>The value returned by the command. Must not be null. (But possibly {null~Null})</returns>
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            var text = Concat.ConcatenateString(sctx, args);
            StaticPrint.Writer.WriteLine(text);

            return text;
        }
コード例 #18
0
ファイル: CharPType.cs プロジェクト: SealedSun/prx
        public override bool TryConstruct(StackContext sctx, PValue[] args, out PValue result)
        {
            char c;
            result = null;

            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null)
                throw new ArgumentNullException("args");

            PValue v;

            if (args.Length < 1 || args[0].IsNull)
            {
                c = '\0';
            }
            else if (args[0].TryConvertTo(sctx, Char, out v))
            {
                c = (char) v.Value;
            }
            else if (args[0].TryConvertTo(sctx, Int, false, out v))
            {
                c = (char) (int) v.Value;
            }
            else
            {
                c = '\0';
            }

            result = c;
            return true;
        }
コード例 #19
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;
        }
コード例 #20
0
ファイル: AsThunkCommand.cs プロジェクト: SealedSun/prx
        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 asThunk command requires a value.");

            return ThunkCommand._EnforceThunk(args[0]);
        }
コード例 #21
0
ファイル: CreateEnumerator.cs プロジェクト: SealedSun/prx
 public EnumeratorProxy(StackContext sctx, PValue moveNext, PValue current,
     PValue dispose)
 {
     _moveNext = moveNext;
     _sctx = sctx;
     _current = current;
     _dispose = dispose;
 }
コード例 #22
0
ファイル: ConsolePrintLine.cs プロジェクト: SealedSun/prx
        /// <summary>
        ///     Executes the command.
        /// </summary>
        /// <param name = "sctx">The stack context in which to execut the command.</param>
        /// <param name = "args">The arguments to be passed to the command.</param>
        /// <returns>The value returned by the command. Must not be null. (But possibly {null~Null})</returns>
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            var buffer = Concat.ConcatenateString(sctx, args);

            Console.WriteLine(buffer);

            return buffer;
        }
コード例 #23
0
ファイル: Caller.cs プロジェクト: SealedSun/prx
 public static PValue GetCallerFromCilFunction(StackContext sctx)
 {
     var stack = sctx.ParentEngine.Stack;
     if (stack.Count == 0)
         return PType.Null;
     else
         return sctx.CreateNativePValue(stack.Last.Value);
 }
コード例 #24
0
 public TransactionBehaviour(StackContext dbContext,
                             IIntegrationEventService integrationEventService,
                             ILogger <TransactionBehaviour <TRequest, TResponse> > logger)
 {
     _dbContext = dbContext ?? throw new ArgumentException(nameof(StackContext));
     _integrationEventService = integrationEventService ?? throw new ArgumentException(nameof(integrationEventService));
     _logger = logger ?? throw new ArgumentException(nameof(ILogger));
 }
コード例 #25
0
ファイル: ObjectPType.cs プロジェクト: SealedSun/prx
 public static Type GetType(StackContext sctx, string clrTypeName)
 {
     Type result;
     if (TryGetType(sctx, clrTypeName, out result))
         return result;
     else
         throw new PrexoniteException("Cannot resolve ClrType name \"" + clrTypeName + "\".");
 }
コード例 #26
0
ファイル: Reverse.cs プロジェクト: SealedSun/prx
 // Bound statically by CIL compiler
 // ReSharper disable UnusedMember.Global
 public static PValue RunStatically(StackContext sctx, PValue[] args)
     // ReSharper restore UnusedMember.Global
 {
     var carrier = new ContextCarrier();
     var corctx = new CoroutineContext(sctx, CoroutineRunStatically(carrier, args));
     carrier.StackContext = corctx;
     return sctx.CreateNativePValue(new Coroutine(corctx));
 }
コード例 #27
0
ファイル: CreateEnumerator.cs プロジェクト: SealedSun/prx
        // ReSharper disable MemberCanBePrivate.Global
        public static PValue RunStatically(StackContext sctx, PValue[] args)
            // ReSharper restore MemberCanBePrivate.Global
        {
            if (args.Length < 3)
                throw new PrexoniteException(Alias + " requires three arguments: " + Alias +
                    "(fMoveNext, fCurrent, fDispose);");

            return sctx.CreateNativePValue(new EnumeratorProxy(sctx, args[0], args[1], args[2]));
        }
コード例 #28
0
ファイル: RealPType.cs プロジェクト: SealedSun/prx
 public override bool TryConstruct(StackContext sctx, PValue[] args, out PValue result)
 {
     if (args.Length <= 1)
     {
         result = Real.CreatePValue(0.0);
         return true;
     }
     return args[0].TryConvertTo(sctx, Real, out result);
 }
        public TestLoadWindow()
        {
            InitializeComponent();
            context = new StackContext();

            context.Records.Load();
            logRecords.ItemsSource = context.Records.Local.ToBindingList();
            Closing += MainWindow_Closing;;
        }
コード例 #30
0
 public StackElement(DateTime beginDate, string className, string method, StackContext context, StackElement father)
 {
     _children  = new List <StackElement>();
     _beginDate = beginDate;
     _className = className;
     _method    = method;
     _context   = context;
     _father    = father;
 }
コード例 #31
0
        public override PValue Run(StackContext sctx, PValue[] args)
        {
            if (args.Length < 1)
                return PType.Null;

            var closed = new PValue[args.Length - 1];
            Array.Copy(args, 1, closed, 0, args.Length - 1);
            return sctx.CreateNativePValue(new FunctionalPartialCall(args[0], closed));
        }
コード例 #32
0
ファイル: ForceCommand.cs プロジェクト: SealedSun/prx
        public static PValue Force(StackContext sctx, PValue arg)
        {
            var t = arg.Value as Thunk;

            var result = t != null ? t.Force(sctx) : arg;

            Debug.Assert(!(result.Value is Thunk), "Force wanted to return an unevaluated thunk.");

            return result;
        }
コード例 #33
0
ファイル: Const.cs プロジェクト: SealedSun/prx
        public static PValue RunStatically(StackContext sctx, PValue[] args)
        {
            PValue constant;
            if (args.Length < 1)
                constant = PType.Null;
            else
                constant = args[0];

            return CreateConstFunction(constant, sctx);
        }
コード例 #34
0
 ///////////////////////////////////////////////////////////////////////////////////
 void FibImpl(int fnext, int f, int count, StackContext stack)
 {
     if (count == 0)
     {
         stack.Exit(f);
     }
     else
     {
         stack.Push(fnext + f, fnext, count - 1);
     }
 }
コード例 #35
0
 public IntegrationEventService(IEventBus eventBus,
                                StackContext dbContext,
                                IntegrationEventLogContext eventLogContext,
                                Func <DbConnection, IIntegrationEventLogService> integrationEventLogServiceFactory,
                                ILogger <IntegrationEventService> logger)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _integrationEventLogServiceFactory = integrationEventLogServiceFactory ??
                                          throw new ArgumentNullException(
                                                    nameof(integrationEventLogServiceFactory));
     _eventBus        = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
     _eventLogService = _integrationEventLogServiceFactory(_dbContext.Database.GetDbConnection());
     _logger          = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #36
0
 public StackTrace(DateTime beginDate, string className, string method)
 {
     _context       = new StackContext();
     _context.Level = 1;
     _root          = new StackElement(beginDate, className, method, _context, null);
 }
コード例 #37
0
 public UserController(StackContext db, UserManager <User> userManager, SignInManager <User> signManager)
 {
     this.db      = db;
     _userManager = userManager;
     _signManager = signManager;
 }
コード例 #38
0
ファイル: RequestManager.cs プロジェクト: rezafaghani/Iac
 public RequestManager(StackContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
コード例 #39
0
 public static void PushOnStack(object o)
 {
     StackContext.PushOnStack(o);
 }
コード例 #40
0
 public ReportRepository(NavaContext latamDbContext, StackContext euDbContext)
 {
     this.latamDbContext = latamDbContext;
     this.euDbContext    = euDbContext;
 }
コード例 #41
0
 public static object PopFromStack()
 {
     return(StackContext.Pop());
 }
コード例 #42
0
 public static object StackPeek()
 {
     return(StackContext.Count == 0 ? null : StackContext.Peek());
 }
コード例 #43
0
 public HomeController(StackContext db, SignInManager <User> SignInManager, UserManager <User> UserManager)
 {
     this.db            = db;
     this.SignInManager = SignInManager;
     this.UserManager   = UserManager;
 }
コード例 #44
0
 public ReversedStackManager(StackContext context)
 {
     _context = context;
 }
コード例 #45
0
 public Repository(StackContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }