/// <inheritdoc/> public Value ExecuteBatchAsync(List <ProcessInitialInfo> processInitialInfoList) { #if DEBUG //Log($"processInitialInfoList = {processInitialInfoList.WriteListToString()}"); #endif var codeFramesList = new List <CodeFrame>(); foreach (var processInitialInfo in processInitialInfoList) { var codeFrame = new CodeFrame(); codeFrame.CompiledFunctionBody = processInitialInfo.CompiledFunctionBody; codeFrame.LocalContext = processInitialInfo.LocalContext; var processInfo = new ProcessInfo(); codeFrame.ProcessInfo = processInfo; processInfo.CodeFrame = codeFrame; codeFrame.Metadata = processInitialInfo.Metadata; _context.InstancesStorage.AppendProcessInfo(processInfo); codeFramesList.Add(codeFrame); } #if DEBUG //_context.InstancesStorage.PrintProcessesList(); #endif var threadExecutor = new AsyncThreadExecutor(_context); threadExecutor.SetCodeFrames(codeFramesList); return(threadExecutor.Start()); }
private void CallExecutable(IExecutable executable, KindOfFunctionParameters kindOfParameters, Dictionary <StrongIdentifierValue, Value> namedParameters, List <Value> positionedParameters, bool isSync) { if (executable.IsSystemDefined) { Value result = null; switch (kindOfParameters) { case KindOfFunctionParameters.PositionedParameters: result = executable.SystemHandler.Call(positionedParameters, _currentCodeFrame.LocalContext); break; default: throw new ArgumentOutOfRangeException(nameof(kindOfParameters), kindOfParameters, null); } #if DEBUG //Log($"result = {result}"); #endif _currentCodeFrame.ValuesStack.Push(result); #if DEBUG //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif return; } else { var newCodeFrame = ConvertExecutableToCodeFrame(executable, kindOfParameters, namedParameters, positionedParameters); #if DEBUG //Log($"newCodeFrame = {newCodeFrame}"); #endif _context.InstancesStorage.AppendProcessInfo(newCodeFrame.ProcessInfo); #if DEBUG //Log($"isSync = {isSync}"); #endif if (isSync) { _currentCodeFrame.CurrentPosition++; SetCodeFrame(newCodeFrame); } else { _currentCodeFrame.CurrentPosition++; var threadExecutor = new AsyncThreadExecutor(_context); threadExecutor.SetCodeFrame(newCodeFrame); var task = threadExecutor.Start(); _currentCodeFrame.ValuesStack.Push(task); } } }