コード例 #1
0
ファイル: AllocatorTests.cs プロジェクト: rebarlang/rebar
        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);
            }
        }
コード例 #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());
        }