Ejemplo n.º 1
0
        private FunctionVariableStorage RunAllocator(DfirRoot function)
        {
            var cancellationToken = new CompileCancellationToken();

            RunCompilationUpToAsyncNodeDecomposition(function, cancellationToken);
            ExecutionOrderSortingVisitor.SortDiagrams(function);

            var asyncStateGrouper = new AsyncStateGrouper();

            asyncStateGrouper.Execute(function, cancellationToken);
            IEnumerable <AsyncStateGroup> asyncStateGroups = asyncStateGrouper.GetAsyncStateGroups();

            using (var contextWrapper = new ContextWrapper())
            {
                var module           = contextWrapper.CreateModule("module");
                var functionImporter = new FunctionImporter(contextWrapper, module);
                var codeGenExpander  = new CodeGenExpander(
                    function,
                    new FunctionModuleContext(contextWrapper, module, functionImporter),
                    new Dictionary <CompilableDefinitionName, bool>());
                asyncStateGroups.ForEach(codeGenExpander.ExpandAsyncStateGroup);

                var variableStorage = new FunctionVariableStorage();
                var allocator       = new Allocator(contextWrapper, variableStorage, asyncStateGroups);
                allocator.Execute(function, cancellationToken);
                return(variableStorage);
            }
        }
Ejemplo n.º 2
0
        private IEnumerable <AsyncStateGroup> GroupAsyncStates(DfirRoot function)
        {
            ExecutionOrderSortingVisitor.SortDiagrams(function);
            var asyncStateGrouper = new AsyncStateGrouper();

            asyncStateGrouper.Execute(function, new NationalInstruments.Compiler.CompileCancellationToken());
            return(asyncStateGrouper.GetAsyncStateGroups());
        }