當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。