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


C# CSharp.ModuleContainer类代码示例

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


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

示例1: Simple

		public void Simple ()
		{
			//string content = @"class A { }";
			string content = @"

class Foo
{
	void Bar ()
	{
completionList.Add (""delegate"" + sb, ""md-keyword"", GettextCatalog.GetString (""Creates anonymous delegate.""), ""delegate"" + sb + "" {"" + Document.Editor.EolMarker + stateTracker.Engine.ThisLineIndent + TextEditorProperties.IndentString + ""|"" + Document.Editor.EolMarker + stateTracker.Engine.ThisLineIndent +""};"");
	}
}"
	;


			var stream = new MemoryStream (Encoding.UTF8.GetBytes (content));

			var ctx = new CompilerContext (new CompilerSettings (), new AssertReportPrinter ());

			ModuleContainer module = new ModuleContainer (ctx);
			var file = new SourceFile ("test", "asdfas", 0);
			CSharpParser parser = new CSharpParser (
				new SeekableStreamReader (stream, Encoding.UTF8),
				new CompilationSourceFile (module, file),
				ctx.Report,
				new ParserSession ());

			RootContext.ToplevelTypes = module;
			Location.Initialize (new List<SourceFile> { file });
			parser.parse ();

			Assert.AreEqual (0, ctx.Report.Errors);

			module.Accept (new TestVisitor ());
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:35,代码来源:ASTVisitorTest.cs

示例2: Parse

		void Parse (ModuleContainer module)
		{
			bool tokenize_only = module.Compiler.Settings.TokenizeOnly;
			var sources = module.Compiler.SourceFiles;

			Location.Initialize (sources);

			var session = new ParserSession () {
				UseJayGlobalArrays = true,
				LocatedTokens = new Tokenizer.LocatedToken[15000],
				AsLocatedTokens = new Mono.PlayScript.Tokenizer.LocatedToken[15000]
			};

			bool has_playscript_files = false;

			for (int i = 0; i < sources.Count; ++i) {
				if (tokenize_only) {
					tokenize_file (sources[i], module, session);
				} else {
					Parse (sources[i], module, session, Report);
				}
				if (sources[i].FileType == SourceFileType.PlayScript) {
					has_playscript_files = true;
				}
			}

			// PlayScript needs to add generated code after parsing.
			if (has_playscript_files) {
				Mono.PlayScript.CodeGenerator.GenerateCode(module, session, Report);
			}
		}
开发者ID:bbqchickenrobot,项目名称:playscript-mono,代码行数:31,代码来源:driver.cs

示例3: tokenize_file

		void tokenize_file (SourceFile sourceFile, ModuleContainer module)
		{
			Stream input;

			try {
				input = File.OpenRead (sourceFile.Name);
			} catch {
				Report.Error (2001, "Source file `" + sourceFile.Name + "' could not be found");
				return;
			}

			using (input){
				SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding);
				var file = new CompilationSourceFile (module, sourceFile);

				Tokenizer lexer = new Tokenizer (reader, file);
				int token, tokens = 0, errors = 0;

				while ((token = lexer.token ()) != Token.EOF){
					tokens++;
					if (token == Token.ERROR)
						errors++;
				}
				Console.WriteLine ("Tokenized: " + tokens + " found " + errors + " errors");
			}
			
			return;
		}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例4: CreateModuleContainer

        private static ModuleContainer CreateModuleContainer([NotNull] CompilerContext context)
        {
            var container = new ModuleContainer(context);
            RootContext.ToplevelTypes = container;

            return container;
        }
开发者ID:Tauron1990,项目名称:Radio-Streamer,代码行数:7,代码来源:Compiler.cs

示例5: Visit

		public virtual void Visit (ModuleContainer mc)
		{
			foreach (var container in mc.Containers) {
				container.Accept (this);
			}
			
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:7,代码来源:visit.cs

示例6: StaticDataContainer

			public StaticDataContainer (ModuleContainer module)
				: base (module, new MemberName ("<PrivateImplementationDetails>", Location.Null),
					Modifiers.STATIC | Modifiers.INTERNAL)
			{
				size_types = new Dictionary<int, Struct> ();
				data_hashes = new Dictionary<string, FieldSpec> (StringComparer.Ordinal);
			}
开发者ID:chriswebb,项目名称:mono,代码行数:7,代码来源:module.cs

示例7: Parse

		public void Parse (CompilationSourceFile file, ModuleContainer module)
		{
			Stream input;

			try {
				input = File.OpenRead (file.Name);
			} catch {
				Report.Error (2001, "Source file `{0}' could not be found", file.Name);
				return;
			}

			// Check 'MZ' header
			if (input.ReadByte () == 77 && input.ReadByte () == 90) {
				Report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
				input.Close ();
				return;
			}

			input.Position = 0;
			SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding);

			Parse (reader, file, module);
			reader.Dispose ();
			input.Close ();
		}	
开发者ID:severinh,项目名称:monodevelop-vala-afrodite-update,代码行数:25,代码来源:driver.cs

示例8: Parse

        public void Parse(ModuleContainer module)
        {
            bool tokenize_only = module.Compiler.Settings.TokenizeOnly;
            var sources = module.Compiler.SourceFiles;

            Location.Initialize(sources);

            var session = new ParserSession
            {
                UseJayGlobalArrays = true,
                LocatedTokens = new LocatedToken[15000]
            };

            for (int i = 0; i < sources.Count; ++i)
            {
                if (tokenize_only)
                {
                    tokenize_file(sources[i], module, session);
                }
                else
                {
                    Parse(sources[i], module, session, Report);
                }
            }
        }
开发者ID:krukru,项目名称:code-boxing,代码行数:25,代码来源:CustomDynamicDriver.cs

示例9: Parse

        public static void Parse(SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module, ParserSession session, Report report)
        {
            var file = new CompilationSourceFile(module, sourceFile);
            module.AddTypeContainer(file);

            CSharpParser parser = new CSharpParser(reader, file, report, session);
            parser.parse();
        }
开发者ID:Nystul-the-Magician,项目名称:daggerfall-unity,代码行数:8,代码来源:CustomDynamicDriver.cs

示例10: DocumentationBuilder

		public DocumentationBuilder (ModuleContainer module)
		{
			doc_module = new ModuleContainer (module.Compiler);
			doc_module.DocumentationBuilder = this;

			this.module = module;
			XmlDocumentation = new XmlDocument ();
			XmlDocumentation.PreserveWhitespace = false;
		}
开发者ID:royleban,项目名称:mono,代码行数:9,代码来源:doc.cs

示例11: Visit

			public override void Visit(ModuleContainer mc)
			{
				bool first = true;
				foreach (var container in mc.Containers) {
					var nspace = container as NamespaceContainer;
					if (nspace == null) {
						container.Accept(this);
						continue;
					}
					NamespaceDeclaration nDecl = null;
					var loc = LocationsBag.GetLocations(nspace);
					
					if (nspace.NS != null && !string.IsNullOrEmpty(nspace.NS.Name)) {
						nDecl = new NamespaceDeclaration ();
						if (loc != null) {
							nDecl.AddChild(new CSharpTokenNode (Convert(loc [0])), Roles.NamespaceKeyword);
						}
						ConvertNamespaceName(nspace.RealMemberName, nDecl);
						if (loc != null && loc.Count > 1) {
							nDecl.AddChild(new CSharpTokenNode (Convert(loc [1])), Roles.LBrace);
						}
						AddToNamespace(nDecl);
						namespaceStack.Push(nDecl);
					}
					
					if (nspace.Usings != null) {
						foreach (var us in nspace.Usings) {
							us.Accept(this);
						}
					}
					
					if (first) {
						first = false;
						AddAttributeSection(Unit, mc);
					}
					
					if (nspace.Containers != null) {
						foreach (var subContainer in nspace.Containers) {
							subContainer.Accept(this);
						}
					}
					if (nDecl != null) {
						AddAttributeSection (nDecl, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
						if (loc != null && loc.Count > 2)
							nDecl.AddChild (new CSharpTokenNode (Convert (loc [2])), Roles.RBrace);
						if (loc != null && loc.Count > 3)
							nDecl.AddChild (new CSharpTokenNode (Convert (loc [3])), Roles.Semicolon);
						
						namespaceStack.Pop ();
					} else {
						AddAttributeSection (unit, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
					}
				}
				AddAttributeSection (unit, mc.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
			}
开发者ID:head-thrash,项目名称:monodevelop,代码行数:55,代码来源:CSharpParser.cs

示例12: GenerateCode

		public static void GenerateCode (ModuleContainer module, ParserSession session, Report report)
		{
			GenerateDynamicPartialClasses(module, session, report);
			if (report.Errors > 0)
				return;

			GenerateEmbedClasses(module, session, report);
			if (report.Errors > 0)
				return;

		}
开发者ID:rlfqudxo,项目名称:playscript-mono,代码行数:11,代码来源:ps-codegen.cs

示例13: Visit

		public virtual void Visit (ModuleContainer mc)
		{/*
			if (mc.Delegates != null) {
				foreach (TypeContainer tc in mc.Delegates) {
					tc.Accept (this);
				}
			}*/
			if (mc.Types != null) {
				foreach (TypeContainer tc in mc.Types) {
					tc.Accept (this);
				}
			}
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:13,代码来源:visit.cs

示例14: Evaluator

		public Evaluator (CompilerSettings settings, Report report)
		{
			ctx = new CompilerContext (settings, report);

			module = new ModuleContainer (ctx);
			module.Evaluator = this;

			// FIXME: Importer needs this assembly for internalsvisibleto
			module.SetDeclaringAssembly (new AssemblyDefinitionDynamic (module, "evaluator"));
			importer = new ReflectionImporter (module, ctx.BuildinTypes);

			InteractiveBaseClass = typeof (InteractiveBase);
			fields = new Dictionary<string, Tuple<FieldSpec, FieldInfo>> ();
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:14,代码来源:eval.cs

示例15: Parse

		void Parse (ModuleContainer module)
		{
			Location.Initialize ();

			bool tokenize_only = ctx.Settings.TokenizeOnly;
			var cu = Location.SourceFiles;
			for (int i = 0; i < cu.Count; ++i) {
				if (tokenize_only) {
					tokenize_file (cu[i]);
				} else {
					Parse (cu[i], module);
				}
			}
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:14,代码来源:driver.cs


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