/// <inheritdoc />
        public override async Task <Tuple <CompileCacheEntry, CompileSignature> > BackEndCompileAsyncCore(
            SpecAndQName specAndQName,
            DfirRoot targetDfir,
            CompileCancellationToken cancellationToken,
            ProgressToken progressToken,
            CompileThreadState compileThreadState)
        {
            CompileSignature topSignature = new CompileSignature(
                targetDfir.Name,
                Enumerable.Empty <CompileSignatureParameter>(), // GenerateParameters(targetDfir),
                targetDfir.GetDeclaringType(),
                targetDfir.Reentrancy,
                true,
                true,
                ThreadAffinity.Standard,
                false,
                true,
                ExecutionPriority.Normal,
                CallingConvention.StdCall);
            BuildSpec htmlVIBuildSpec = specAndQName.BuildSpec;

            foreach (var dependency in targetDfir.Dependencies.OfType <CompileInvalidationDfirDependency>().ToList())
            {
                var compileSignature = await Compiler.GetCompileSignatureAsync(dependency.SpecAndQName, cancellationToken, progressToken, compileThreadState);

                if (compileSignature != null)
                {
                    targetDfir.AddDependency(
                        targetDfir,
                        new CompileSignatureDependency(dependency.SpecAndQName, compileSignature));
                }
            }

            IBuiltPackage builtPackage = null;

            if (!RebarFeatureToggles.IsLLVMCompilerEnabled)
            {
                Function compiledFunction = CompileFunctionForBytecodeInterpreter(targetDfir, cancellationToken);
                builtPackage = new FunctionBuiltPackage(specAndQName, Compiler.TargetName, compiledFunction);
            }
            else
            {
                Module compiledFunctionModule = CompileFunctionForLLVM(targetDfir, cancellationToken);
                builtPackage = new LLVM.FunctionBuiltPackage(specAndQName, Compiler.TargetName, compiledFunctionModule);
            }

            BuiltPackageToken token = Compiler.AddToBuiltPackagesCache(builtPackage);
            CompileCacheEntry entry = await Compiler.CreateStandardCompileCacheEntryFromDfirRootAsync(
                CompileState.Complete,
                targetDfir,
                new Dictionary <ExtendedQualifiedName, CompileSignature>(),
                token,
                cancellationToken,
                progressToken,
                compileThreadState,
                false);

            return(new Tuple <CompileCacheEntry, CompileSignature>(entry, topSignature));
        }
Esempio n. 2
0
        /// <inheritdoc />
        public override async Task <Tuple <CompileCacheEntry, CompileSignature> > CompileCoreAsync(
            CompileSpecification compileSpecification,
            DfirRoot targetDfir,
            CompileCancellationToken cancellationToken,
            ProgressToken progressToken,
            CompileThreadState compileThreadState)
        {
            CompileSignature topSignature = new CompileSignature(
                targetDfir.Name,
                Enumerable.Empty <CompileSignatureParameter>(), // GenerateParameters(targetDfir),
                targetDfir.GetDeclaringType(),
                targetDfir.Reentrancy,
                true,
                true,
                ThreadAffinity.Standard,
                false,
                true,
                ExecutionPriority.Normal,
                CallingConvention.StdCall);
            BuildSpec typeDiagramBuildSpec = compileSpecification.BuildSpec;

#if FALSE
            foreach (var dependency in targetDfir.Dependencies.OfType <CompileInvalidationDfirDependency>().ToList())
            {
                var compileSignature = await Compiler.GetCompileSignatureAsync(dependency.SpecAndQName, cancellationToken, progressToken, compileThreadState);

                if (compileSignature != null)
                {
                    targetDfir.AddDependency(
                        targetDfir,
                        new CompileSignatureDependency(dependency.SpecAndQName, compileSignature));
                }
            }
#endif

            IBuiltPackage builtPackage = null;
            // TODO: create TypeDiagramBuiltPackage
            builtPackage = new EmptyBuiltPackage(
                compileSpecification,
                Compiler.TargetName,
                Enumerable.Empty <CompileSpecification>(),
                CompileMetadata.Empty);

            BuiltPackageToken token = Compiler.AddToBuiltPackagesCache(builtPackage);
            CompileCacheEntry entry = await Compiler.CreateStandardCompileCacheEntryFromDfirRootAsync(
                CompileState.Complete,
                targetDfir,
                new Dictionary <CompilableDefinitionName, CompileSignature>(),
                token,
                cancellationToken,
                progressToken,
                compileThreadState,
                false);

            return(new Tuple <CompileCacheEntry, CompileSignature>(entry, topSignature));
        }
        /// <inheritdoc />
        public override async Task <Tuple <CompileCacheEntry, CompileSignature> > CompileCoreAsync(
            CompileSpecification compileSpecification,
            DfirRoot targetDfir,
            CompileCancellationToken cancellationToken,
            ProgressToken progressToken,
            CompileThreadState compileThreadState)
        {
            CompileSignature topSignature = new CompileSignature(
                targetDfir.Name,
                Enumerable.Empty <CompileSignatureParameter>(),
                targetDfir.GetDeclaringType(),
                targetDfir.Reentrancy,
                true,
                true,
                ThreadAffinity.Standard,
                false,
                true,
                ExecutionPriority.Normal,
                CallingConvention.StdCall);

            var builtPackage = new EmptyBuiltPackage(
                compileSpecification,
                Compiler.TargetName,
                Enumerable.Empty <CompileSpecification>(),
                CompileMetadata.Empty);

            BuiltPackageToken token = Compiler.AddToBuiltPackagesCache(builtPackage);
            CompileCacheEntry entry = await Compiler.CreateStandardCompileCacheEntryFromDfirRootAsync(
                CompileState.Complete,
                targetDfir,
                new Dictionary <CompilableDefinitionName, CompileSignature>(),
                token,
                cancellationToken,
                progressToken,
                compileThreadState,
                false);

            return(new Tuple <CompileCacheEntry, CompileSignature>(entry, topSignature));
        }
Esempio n. 4
0
        /// <inheritdoc />
        public override async Task <Tuple <CompileCacheEntry, CompileSignature> > CompileCoreAsync(
            CompileSpecification compileSpecification,
            DfirRoot targetDfir,
            CompileCancellationToken cancellationToken,
            ProgressToken progressToken,
            CompileThreadState compileThreadState)
        {
            var compileSignatureParameters = new List <CompileSignatureParameter>();

            foreach (DataItem dataItem in targetDfir.DataItems.OrderBy(dataItem => dataItem.ConnectorPaneIndex))
            {
                var compileSignatureParameter = new CompileSignatureParameter(
                    dataItem.Name,
                    dataItem.Name,
                    dataItem.DataType,
                    dataItem.ConnectorPaneInputPassingRule,
                    dataItem.ConnectorPaneOutputPassingRule,
                    dataItem.ConnectorPaneIndex);
                compileSignatureParameters.Add(compileSignatureParameter);
            }

            var compileSignatures    = new Dictionary <CompilableDefinitionName, CompileSignature>();
            var dependencyIdentities = new HashSet <CompileSpecification>();

            foreach (var dependency in targetDfir.Dependencies.OfType <CompileInvalidationDfirDependency>().ToList())
            {
                dependencyIdentities.Add(ConvertToCompileSpecificationDuringMigration(dependency.DependeeName));
                var compileSignature = await Compiler.GetCompileSignatureAsync(dependency.DependeeName, cancellationToken, progressToken, compileThreadState);

                if (compileSignature != null)
                {
                    targetDfir.AddDependency(
                        targetDfir,
                        new CompileSignatureDependency(dependency.DependeeName, compileSignature));
                    compileSignatures[ConvertToCompilableDefinitionNameDuringMigration(dependency.DependeeName)] = compileSignature;
                }
            }

            var calleesIsYielding = new Dictionary <CompilableDefinitionName, bool>();
            var calleesMayPanic   = new Dictionary <CompilableDefinitionName, bool>();

            foreach (var methodCallNode in targetDfir.GetAllNodesIncludingSelf().OfType <MethodCallNode>())
            {
                CompileSignature calleeSignature = compileSignatures[methodCallNode.TargetName];
                var  functionCompileSignature    = calleeSignature as FunctionCompileSignature;
                bool mayPanic = functionCompileSignature?.MayPanic ?? false;
                calleesIsYielding[methodCallNode.TargetName] = calleeSignature.IsYielding;
                calleesMayPanic[methodCallNode.TargetName]   = mayPanic;
            }

            LLVM.FunctionCompileResult functionCompileResult = CompileFunctionForLLVM(
                targetDfir,
                cancellationToken,
                calleesIsYielding,
                calleesMayPanic);
            var builtPackage = new LLVM.FunctionBuiltPackage(
                compileSpecification,
                Compiler.TargetName,
                dependencyIdentities.ToArray(),
                functionCompileResult.Module,
                functionCompileResult.IsYielding);

            BuiltPackageToken token = Compiler.AddToBuiltPackagesCache(builtPackage);
            CompileCacheEntry entry = await Compiler.CreateStandardCompileCacheEntryFromDfirRootAsync(
                CompileState.Complete,
                targetDfir,
                compileSignatures,
                token,
                cancellationToken,
                progressToken,
                compileThreadState,
                false);

            var topSignature = new FunctionCompileSignature(
                functionName: targetDfir.Name,
                compileSignatureParameters: compileSignatureParameters,
                isYielding: functionCompileResult.IsYielding,
                mayPanic: functionCompileResult.MayPanic);

            return(new Tuple <CompileCacheEntry, CompileSignature>(entry, topSignature));
        }