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)); }
/// <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; }
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; }
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; }
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])); }
/// <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); }
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; }
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); }
/// <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); } }
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; }
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)); }
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); }
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; }
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]); }
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; }
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); }
/// <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; }
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; }
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; }
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]); }
public EnumeratorProxy(StackContext sctx, PValue moveNext, PValue current, PValue dispose) { _moveNext = moveNext; _sctx = sctx; _current = current; _dispose = dispose; }
/// <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; }
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); }
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)); }
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 + "\"."); }
// 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)); }
// 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])); }
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;; }
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; }
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)); }
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; }
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); }
/////////////////////////////////////////////////////////////////////////////////// void FibImpl(int fnext, int f, int count, StackContext stack) { if (count == 0) { stack.Exit(f); } else { stack.Push(fnext + f, fnext, count - 1); } }
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)); }
public StackTrace(DateTime beginDate, string className, string method) { _context = new StackContext(); _context.Level = 1; _root = new StackElement(beginDate, className, method, _context, null); }
public UserController(StackContext db, UserManager <User> userManager, SignInManager <User> signManager) { this.db = db; _userManager = userManager; _signManager = signManager; }
public RequestManager(StackContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
public static void PushOnStack(object o) { StackContext.PushOnStack(o); }
public ReportRepository(NavaContext latamDbContext, StackContext euDbContext) { this.latamDbContext = latamDbContext; this.euDbContext = euDbContext; }
public static object PopFromStack() { return(StackContext.Pop()); }
public static object StackPeek() { return(StackContext.Count == 0 ? null : StackContext.Peek()); }
public HomeController(StackContext db, SignInManager <User> SignInManager, UserManager <User> UserManager) { this.db = db; this.SignInManager = SignInManager; this.UserManager = UserManager; }
public ReversedStackManager(StackContext context) { _context = context; }
public Repository(StackContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }