当前位置: 首页>>代码示例>>C#>>正文


C# ModuleContainer.CreateType方法代码示例

本文整理汇总了C#中Mono.CSharp.ModuleContainer.CreateType方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleContainer.CreateType方法的具体用法?C# ModuleContainer.CreateType怎么用?C# ModuleContainer.CreateType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.CSharp.ModuleContainer的用法示例。


在下文中一共展示了ModuleContainer.CreateType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compile


//.........这里部分代码省略.........
            string output_file_name;
            if (output_file == null) {
                output_file_name = Location.FirstFile;

                if (output_file_name == null) {
                    Report.Error (1562, "If no source files are specified you must specify the output file with -out:");
                    return false;
                }

                int pos = output_file_name.LastIndexOf ('.');

                if (pos > 0)
                    output_file_name = output_file_name.Substring (0, pos);

                output_file_name += settings.TargetExt;
                output_file = output_file_name;
            } else {
                output_file_name = Path.GetFileName (output_file);
            }

            #if STATIC
            var importer = new StaticImporter (module);
            var references_loader = new StaticLoader (importer, ctx);

            tr.Start (TimeReporter.TimerType.AssemblyBuilderSetup);
            var assembly = new AssemblyDefinitionStatic (module, references_loader, output_file_name, output_file);
            assembly.Create (references_loader.Domain);
            tr.Stop (TimeReporter.TimerType.AssemblyBuilderSetup);

            // Create compiler types first even before any referenced
            // assembly is loaded to allow forward referenced types from
            // loaded assembly into compiled builder to be resolved
            // correctly
            tr.Start (TimeReporter.TimerType.CreateTypeTotal);
            module.CreateType ();
            importer.AddCompiledAssembly (assembly);
            tr.Stop (TimeReporter.TimerType.CreateTypeTotal);

            references_loader.LoadReferences (module);

            tr.Start (TimeReporter.TimerType.PredefinedTypesInit);
            if (!ctx.BuildinTypes.CheckDefinitions (module))
                return false;

            tr.Stop (TimeReporter.TimerType.PredefinedTypesInit);

            references_loader.LoadModules (assembly, module.GlobalRootNamespace);
            #else
            var assembly = new AssemblyDefinitionDynamic (module, output_file_name, output_file);
            module.SetDeclaringAssembly (assembly);

            var importer = new ReflectionImporter (module, ctx.BuildinTypes);
            assembly.Importer = importer;

            var loader = new DynamicLoader (importer, ctx);
            loader.LoadReferences (module);

            if (!ctx.BuildinTypes.CheckDefinitions (module))
                return false;

            if (!assembly.Create (AppDomain.CurrentDomain, AssemblyBuilderAccess.Run))
                return false;

            module.CreateType ();

            loader.LoadModules (assembly, module.GlobalRootNamespace);
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:67,代码来源:driver.cs

示例2: Compile

		//
		// Main compilation method
		//
		public bool Compile ()
		{
			var module = new ModuleContainer (ctx);
			RootContext.ToplevelTypes = module;

			if (timestamps) {
				stopwatch = Stopwatch.StartNew ();
				first_time = DateTime.Now;
			}

			Parse (module);
			ShowTime ("Parsing source files");

			if (Report.Errors > 0)
				return false;

			if (RootContext.TokenizeOnly || RootContext.ParseOnly)
				return true;

			if (RootContext.ToplevelTypes.NamespaceEntry != null)
				throw new InternalErrorException ("who set it?");

			//
			// Quick hack
			//
			var output_file = RootContext.OutputFile;
			string output_file_name;
			if (output_file == null) {
				if (first_source == null) {
					Report.Error (1562, "If no source files are specified you must specify the output file with -out:");
					return false;
				}

				int pos = first_source.LastIndexOf ('.');

				if (pos > 0)
					output_file = first_source.Substring (0, pos) + RootContext.TargetExt;
				else
					output_file = first_source + RootContext.TargetExt;

				output_file_name = output_file;
			} else {
				output_file_name = Path.GetFileName (output_file);
			}

			//
			// Load assemblies required
			//
			if (timestamps)
				stopwatch = Stopwatch.StartNew ();

#if STATIC
			var importer = new StaticImporter ();
			var references_loader = new StaticLoader (importer, ctx);

			var assembly = new AssemblyDefinitionStatic (module, references_loader, output_file_name, output_file);
			assembly.Create (references_loader.Domain);

			// Create compiler types first even before any referenced
			// assembly is loaded to allow forward referenced types from
			// loaded assembly into compiled builder to be resolved
			// correctly
			module.CreateType ();
			ShowTime ("Creating compiled types");

			importer.AddCompiledAssembly (assembly);
			references_loader.LoadReferences (module);
			ShowTime ("Imporing referenced assemblies");

			if (!ctx.BuildinTypes.CheckDefinitions (module))
				return false;

			ShowTime ("Initializing predefined types");

			references_loader.LoadModules (assembly, module.GlobalRootNamespace);
#else
			var assembly = new AssemblyDefinitionDynamic (module, output_file_name, output_file);
			module.SetDeclaringAssembly (assembly);

			var importer = new ReflectionImporter (ctx.BuildinTypes);
			assembly.Importer = importer;

			var loader = new DynamicLoader (importer, ctx);
			loader.LoadReferences (module);

			ShowTime ("Imporing referenced assemblies");

			if (!ctx.BuildinTypes.CheckDefinitions (module))
				return false;

			ShowTime ("Initializing predefined types");

			if (!assembly.Create (AppDomain.CurrentDomain, AssemblyBuilderAccess.Save))
				return false;

			loader.LoadModules (assembly, module.GlobalRootNamespace);
#endif
//.........这里部分代码省略.........
开发者ID:kumpera,项目名称:mono,代码行数:101,代码来源:driver.cs


注:本文中的Mono.CSharp.ModuleContainer.CreateType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。