예제 #1
0
        private static void GenFunction(
            LLVMModuleRef module,
            LLVMBuilderRef builder,
            [NotNull] VariableDeclaration variable,
            [NotNull] LambdaType lambdaType)
        {
            var function = LLVMSharp.LLVM.AddFunction(module, variable.Name, GetLlvmType(lambdaType));

            LLVMSharp.LLVM.PositionBuilderAtEnd(builder, LLVMSharp.LLVM.AppendBasicBlock(function, "entry"));
            GenAstHolder.GenAst(module, builder, (LambdaExpression)variable.Expression);
            LLVMSharp.LLVM.VerifyFunction(function, LLVMVerifierFailureAction.LLVMPrintMessageAction);
        }
예제 #2
0
파일: Gen.cs 프로젝트: Cm-lang/Cmc
        public static string Generate(
            [NotNull] string moduleName,
            [NotNull] params Declaration[] declarations)
        {
            var core = new Core();
            var analyzedDeclarations = core.Analyze(declarations);
            var moduleRef            = LLVMSharp.LLVM.ModuleCreateWithName(moduleName);
            var builder = LLVMSharp.LLVM.CreateBuilder();

            foreach (var analyzedDeclaration in analyzedDeclarations)
            {
                GenAstHolder.GenAst(moduleRef, builder, analyzedDeclaration);
            }
//			for (var i = 0; i < Constants.StringConstants.Count; i++)
//			{
//				var str = Constants.StringConstants[i];
//				var len = Constants.StringConstantLengths[i];
//			}
            LLVMSharp.LLVM.DumpModule(moduleRef);
            return("");
        }