예제 #1
0
        public void CompileAndExecuteFunction(CompilerTestBase test, DfirRoot function)
        {
#if LLVM_TEST
            const string     compiledFunctionName = "test";
            LLVMSharp.Module compiledFunction     = test.RunSemanticAnalysisUpToLLVMCodeGeneration(function, compiledFunctionName);
            _context.LoadFunction(compiledFunction);
            _context.ExecuteFunctionTopLevel(compiledFunctionName);
#else
            Function compiledFunction = test.RunSemanticAnalysisUpToCodeGeneration(function);
            _context.LoadFunction(compiledFunction);
            _context.FinalizeLoad();
            _context.ExecuteFunctionTopLevel(compiledFunction.Name);
#endif
        }
예제 #2
0
        public CompileLoadResult CompileAndLoadFunction(CompilerTestBase test, DfirRoot function, DfirRoot[] otherFunctions)
        {
            var calleesIsYielding = new Dictionary <CompilableDefinitionName, bool>();
            var calleesMayPanic   = new Dictionary <CompilableDefinitionName, bool>();

            foreach (DfirRoot otherFunction in otherFunctions)
            {
                FunctionCompileResult otherCompileResult = test.RunSemanticAnalysisUpToLLVMCodeGeneration(
                    otherFunction,
                    FunctionCompileHandler.FunctionLLVMName(otherFunction.CompileSpecification.Name),
                    calleesIsYielding,
                    calleesMayPanic);
                calleesIsYielding[otherFunction.CompileSpecification.Name] = otherCompileResult.IsYielding;
                calleesMayPanic[otherFunction.CompileSpecification.Name]   = otherCompileResult.MayPanic;
                _context.LoadFunction(otherCompileResult.Module);
            }

            const string          compiledFunctionName = "test";
            FunctionCompileResult compileResult        = test.RunSemanticAnalysisUpToLLVMCodeGeneration(function, compiledFunctionName, calleesIsYielding, calleesMayPanic);

            _context.LoadFunction(compileResult.Module);
            return(new CompileLoadResult(compiledFunctionName, compileResult.IsYielding));
        }