public FunctionSignature(IABI abi, Type returnType, Type[] parameterTypes, MethodCallingConvention callingConvention, PInvokeInfo pinvoke)
        {
            ReturnType = new FunctionParameterType(abi, returnType);
            ParameterTypes = new FunctionParameterType[parameterTypes.Length];
            for (int index = 0; index < parameterTypes.Length; index++)
                ParameterTypes[index] = new FunctionParameterType(abi, parameterTypes[index]);

            CallingConvention = callingConvention;
            PInvokeInfo = pinvoke;
        }
Beispiel #2
0
        public FunctionSignature(IABI abi, Type returnType, Type[] parameterTypes, MethodCallingConvention callingConvention, PInvokeInfo pinvoke)
        {
            ReturnType     = new FunctionParameterType(abi, returnType);
            ParameterTypes = new FunctionParameterType[parameterTypes.Length];
            for (int index = 0; index < parameterTypes.Length; index++)
            {
                ParameterTypes[index] = new FunctionParameterType(abi, parameterTypes[index]);
            }

            CallingConvention = callingConvention;
            PInvokeInfo       = pinvoke;
        }
Beispiel #3
0
        public void PrepareAssembly(AssemblyDefinition assembly)
        {
            this.assembly = assembly;

            RegisterExternalTypes();

            // Resolve corlib assembly
            corlib = assembly.MainModule.Import(typeof(void)).Resolve().Module.Assembly;

            // Prepare LLVM context, module and data layouts
            context = LLVM.GetGlobalContext();
            module  = LLVM.ModuleCreateWithName(assembly.Name.Name);

            // Prepare system types, for easier access
            InitializeCommonTypes();

            // TODO: Choose appropriate triple depending on target
            var target = LLVM.GetTarget(runtimeModule);

            LLVM.SetTarget(module, target);

            // Initialize ABI
            abi = new DefaultABI(context, targetData);

            // Prepare LLVM builders
            builder       = LLVM.CreateBuilderInContext(context);
            builder2      = LLVM.CreateBuilderInContext(context);
            builderAlloca = LLVM.CreateBuilderInContext(context);

            InitializeDebug();

            if (!TestMode)
            {
                // Register SharpLangModule objects for each module
                metadataPerModule = new Dictionary <Mono.Cecil.ModuleDefinition, ValueRef>();
                var mangledModuleName     = Regex.Replace(assembly.Name.Name + ".sharplangmodule", @"(\W)", "_");
                var sharpLangModuleGlobal = LLVM.AddGlobal(module, sharpLangModuleType.ObjectTypeLLVM, mangledModuleName);
                metadataPerModule[assembly.MainModule] = sharpLangModuleGlobal;

                // Generate extern globals for SharpLangModule instances of other modules
                foreach (var referencedAssembly in referencedAssemblies)
                {
                    mangledModuleName = Regex.Replace(referencedAssembly.Name.Name + ".sharplangmodule", @"(\W)", "_");
                    var externalSharpLangModuleGlobal = LLVM.AddGlobal(module, sharpLangModuleType.ObjectTypeLLVM, mangledModuleName);
                    LLVM.SetLinkage(externalSharpLangModuleGlobal, Linkage.ExternalLinkage);
                    metadataPerModule[referencedAssembly.MainModule] = externalSharpLangModuleGlobal;
                }
            }
        }
Beispiel #4
0
        public void PrepareAssembly(AssemblyDefinition assembly)
        {
            this.assembly = assembly;

            RegisterExternalTypes();

            // Resolve corlib assembly
            corlib = assembly.MainModule.Import(typeof (void)).Resolve().Module.Assembly;

            // Prepare LLVM context, module and data layouts
            context = LLVM.GetGlobalContext();
            module = LLVM.ModuleCreateWithName(assembly.Name.Name);

            // Prepare system types, for easier access
            InitializeCommonTypes();

            // TODO: Choose appropriate triple depending on target
            LLVM.SetTarget(module, triple);

            // Initialize ABI
            abi = new DefaultABI(context, targetData);

            // Prepare LLVM builders
            builder = LLVM.CreateBuilderInContext(context);
            builder2 = LLVM.CreateBuilderInContext(context);
            builderAlloca = LLVM.CreateBuilderInContext(context);

            InitializeDebug();

            if (!TestMode)
            {
                // Register SharpLangModule objects for each module
                metadataPerModule = new Dictionary<Mono.Cecil.ModuleDefinition, ValueRef>();
                var mangledModuleName = Regex.Replace(assembly.Name.Name + ".sharplangmodule", @"(\W)", "_");
                var sharpLangModuleGlobal = LLVM.AddGlobal(module, sharpLangModuleType.ObjectTypeLLVM, mangledModuleName);
                metadataPerModule[assembly.MainModule] = sharpLangModuleGlobal;

                // Generate extern globals for SharpLangModule instances of other modules
                foreach (var referencedAssembly in referencedAssemblies)
                {
                    mangledModuleName = Regex.Replace(referencedAssembly.Name.Name + ".sharplangmodule", @"(\W)", "_");
                    var externalSharpLangModuleGlobal = LLVM.AddGlobal(module, sharpLangModuleType.ObjectTypeLLVM, mangledModuleName);
                    LLVM.SetLinkage(externalSharpLangModuleGlobal, Linkage.ExternalLinkage);
                    metadataPerModule[referencedAssembly.MainModule] = externalSharpLangModuleGlobal;
                }
            }
        }
Beispiel #5
0
 public FunctionParameterType(IABI abi, Type type)
 {
     Type             = type;
     ABIParameterInfo = abi.GetParameterInfo(type);
 }
 public FunctionParameterType(IABI abi, Type type)
 {
     Type = type;
     ABIParameterInfo = abi.GetParameterInfo(type);
 }