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


C# Ast.Module类代码示例

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


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

示例1: VisitCompilationUnit

		public object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
		{
			module = new B.Module();
			module.LexicalInfo = new B.LexicalInfo(fileName, 1, 1);
			compilationUnit.AcceptChildren(this, data);
			if (entryPointMethod != null) {
				bool allMembersAreStatic = true;
				foreach (B.TypeMember member in entryPointMethod.DeclaringType.Members) {
					allMembersAreStatic &= member.IsStatic;
				}
				if (allMembersAreStatic) {
					entryPointMethod.DeclaringType.Attributes.Add(MakeAttribute(("module")));
				} else {
					lastLexicalInfo = entryPointMethod.LexicalInfo;
					B.Expression expr = MakeReferenceExpression(entryPointMethod.DeclaringType.Name + ".Main");
					B.MethodInvocationExpression mie = new B.MethodInvocationExpression(lastLexicalInfo, expr);
					if (entryPointMethod.Parameters.Count > 0) {
						mie.Arguments.Add(MakeReferenceExpression("argv"));
					}
					B.SimpleTypeReference ret = entryPointMethod.ReturnType as B.SimpleTypeReference;
					if (ret.Name == "void" || ret.Name == "System.Void")
						module.Globals.Add(new B.ExpressionStatement(mie));
					else
						module.Globals.Add(new B.ReturnStatement(lastLexicalInfo, mie, null));
				}
			}
			B.Module tmp = module;
			module = null;
			return tmp;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:30,代码来源:ConvertVisitorGlobal.cs

示例2: CreateBooCode

        public static string CreateBooCode(CompilerErrorCollection errors,
                CompilerWarningCollection warnings,
                Module module,
                IList<ICSharpCode.NRefactory.ISpecial> specials)
        {
            using (StringWriter w = new StringWriter())
            {
                foreach (CompilerError error in errors)
                {
                    w.WriteLine("ERROR: " + error.ToString());
                }
                if (errors.Count > 0)
                    w.WriteLine();
                foreach (CompilerWarning warning in warnings)
                {
                    w.WriteLine("# WARNING: " + warning.ToString());
                }

                if (warnings.Count > 0)
                    w.WriteLine();

                BooPrinterVisitorWithComments printer = new BooPrinterVisitorWithComments(specials, w);
                printer.OnModule(module);
                printer.Finish();
                return w.ToString();
            }
        }
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:27,代码来源:BooHelpers.cs

示例3: OnModule

        /// <summary>
        /// Inspect a module to check if we need to add a namespace
        /// </summary>
        /// <param name="node">The node.</param>
        public override void OnModule(Module node)
        {
            if (node.Namespace != null)
                return;

            node.Namespace = new NamespaceDeclaration(node.FullName);
        }
开发者ID:f4i2u1,项目名称:rhino-etl,代码行数:11,代码来源:UseModuleNameAsNamespaceIfMissing.cs

示例4: OnModule

        public override void OnModule(Module module) {
            replacecount = 0;
            dowork = module["isduck"]==null|| module["isduck"].toBool();

                //NameResolutionService.Reset();
                Console.WriteLine("");
                Console.Write("[" + module.Members[0].Name.Replace("_0_","/") + "](" + (cnt++) + ")");
                base.OnModule(module);
                if(replacecount==0) {
                    
                    if (dowork) {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine();
                        Console.WriteLine(module.Members[0].Name.Replace("_0_", "/") + " can be NODUCK");
                    }else {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine();
                        Console.WriteLine(module.Members[0].Name.Replace("_0_", "/") + " is NODUCK");
                    }
                   
                }else {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine();
                    Console.WriteLine(module.Members[0].Name.Replace("_0_", "/") + " contains DUCKS");
                }

                Console.ResetColor();
            
        }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:29,代码来源:ReplaceUknownWithParameters.cs

示例5: OnModule

		override public void OnModule(Module module)
		{
			EnterNamespace(InternalModule.ScopeFor(module));
			VisitTypeDefinitionBody(module);
			Visit(module.AssemblyAttributes);
			LeaveNamespace();
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:7,代码来源:AbstractNamespaceSensitiveVisitorCompilerStep.cs

示例6: InternalModule

 public InternalModule(InternalTypeSystemProvider provider, Module module)
 {
     _provider = provider;
     _module = module;
     _namespace = SafeNamespace(module);
     _module.Imports.Changed += (sender, e) => _namespaceList = null;
     _module.Members.Changed += (sender, e) => _memberCache = null;
 }
开发者ID:boo-lang,项目名称:boo,代码行数:8,代码来源:InternalModule.cs

示例7: OnModule

 public override void OnModule(Module node){
     bmlelements = new List<MacroStatement>();
     exceptions = null;
     allowall = false;
     Visit(node.Members);
     Visit(node.Globals.Statements);
     collectTemplates();
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:8,代码来源:ExpandBmlStep.cs

示例8: OnModule

 /// <summary>
 /// Add the namespaces to the module
 /// </summary>
 public override void OnModule(Module node)
 {
     foreach (string ns in namespaces)
     {
         Import import = new Import(node.LexicalInfo, ns);
         node.Imports.Add(import);
     }
 }
开发者ID:JackWangCUMT,项目名称:rhino-dsl,代码行数:11,代码来源:AutoImportCompilerStep.cs

示例9: ModuleEntity

 public ModuleEntity(NameResolutionService nameResolutionService,
     TypeSystemServices typeSystemServices,
     Module module)
 {
     _nameResolutionService = nameResolutionService;
     _typeSystemServices = typeSystemServices;
     _module = module;
     _namespace = SafeNamespace(module);
 }
开发者ID:boo,项目名称:boo-lang,代码行数:9,代码来源:ModuleEntity.cs

示例10: Generate

 public string Generate(XElement xml) {
     var m = new Module {
                            Namespace = new NamespaceDeclaration(xml.Name.LocalName)
                        };
     foreach (var element in xml.Elements()) {
         generateElement(element, m.Globals);
     }
     return m.ToCodeString();
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:9,代码来源:BooxmlGenerator.cs

示例11: ReifyIntoShouldFailWithAlreadyConnectedMember

		public void ReifyIntoShouldFailWithAlreadyConnectedMember()
		{
			var module = new Module();
			RunCompilerStepAfterExpressionResolutionOn(new CompileUnit(module), new ActionStep(() =>
			{
				var klass = new ClassDefinition { Name = "Foo" };
				module.Members.Add(klass);
				Exceptions.Expecting<ArgumentException>(() => CodeReifier().ReifyInto(module, klass));
			}));
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:10,代码来源:CodeReifierTest.cs

示例12: OnModule

 public override void OnModule(Module node)
 {
     var imports = new[] { "UnityEngine", "System.Collections" };
     foreach (var importName in imports)
     {
         var targetImport = new Import(LexicalInfo.Empty, importName);
         if (node.Imports.Contains(targetImport))
             node.Imports.Add(targetImport);
     }
 }
开发者ID:paveltimofeev,项目名称:documentation,代码行数:10,代码来源:AddImports.cs

示例13: OnModule

		override public void OnModule(Module node)
		{	
			var existingModuleClass = FindModuleClass(node);
			var moduleClass = existingModuleClass ?? NewModuleClassFor(node);

			Method entryPoint = moduleClass.Members["Main"] as Method;
			
			int removed = 0;
			TypeMember[] members = node.Members.ToArray();
			for (int i=0; i<members.Length; ++i)
			{
				TypeMember member = members[i];
				if (member is TypeDefinition) continue;
				if (member.NodeType == NodeType.Method)
				{
					if (EntryPointMethodName == member.Name)
					{
						entryPoint = (Method)member;
					}
					member.Modifiers |= TypeMemberModifiers.Static;
				}
				node.Members.RemoveAt(i-removed);
				moduleClass.Members.Add(member);
				++removed;
			}
			
			if (!node.Globals.IsEmpty)
			{
				Method method = new Method();
				method.IsSynthetic = true;
				method.Parameters.Add(new ParameterDeclaration("argv", new ArrayTypeReference(new SimpleTypeReference("string"))));
				method.ReturnType = CodeBuilder.CreateTypeReference(TypeSystemServices.VoidType);
				method.Body = node.Globals;
				method.LexicalInfo = node.Globals.Statements[0].LexicalInfo;
				method.EndSourceLocation = node.EndSourceLocation;
				method.Name = EntryPointMethodName;
				method.Modifiers = TypeMemberModifiers.Static | TypeMemberModifiers.Private;
				moduleClass.Members.Add(method);
				
				node.Globals = null;
				entryPoint = method;
			}
			
			SetEntryPointIfNecessary(entryPoint);

			if (existingModuleClass != null || ForceModuleClass || (moduleClass.Members.Count > 0))
			{
				if (moduleClass != existingModuleClass)
				{
					moduleClass.Members.Add(AstUtil.CreateConstructor(node, TypeMemberModifiers.Private));
					node.Members.Add(moduleClass);
				}
				InitializeModuleClassEntity(node, moduleClass);
			}
		}
开发者ID:HaKDMoDz,项目名称:GNet,代码行数:55,代码来源:IntroduceModuleClasses.cs

示例14: ScriptDirectoryProperty

		// get the directory name where this script reside and create a property
		// that return this value.
		// this is used to calculate relative paths when loading subviews.
		private void ScriptDirectoryProperty(ClassDefinition macro, Module module)
		{
			Property p = new Property("ScriptDirectory");
			p.Modifiers = TypeMemberModifiers.Override;
			p.Getter = new Method("getScriptDirectory");
			p.Getter.Body.Add(
				new ReturnStatement(
					new StringLiteralExpression(
						Path.GetDirectoryName(module.LexicalInfo.FileName))));

			macro.Members.Add(p);
		}
开发者ID:candland,项目名称:Castle.MonoRail,代码行数:15,代码来源:TransformToBrailStep.cs

示例15: Parse

		private Module Parse()
		{
			var module = new Module();
			var globals = module.Globals;
			while (_position < _code.Length)
			{
				var expression = ParseNextExpression();
				if (expression == null)
					break;
				globals.Add(expression);
			}
			return module;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:13,代码来源:Parser.cs


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