• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Ast.Method类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Run

			public override void Run()
			{
				var klass = new ClassDefinition { Name = "Foo" };
				var baseType = new SimpleTypeReference("object");
				klass.BaseTypes.Add(baseType);

				var method = new Method { Name = "Bar" };
				method.Body.Add(
					new ReturnStatement(
						new IntegerLiteralExpression(42)));
				klass.Members.Add(method);

				var module = CompileUnit.Modules[0];
				Assert.AreEqual(0, module.Members.Count);

				My<CodeReifier>.Instance.ReifyInto(module, klass);

				Assert.AreEqual(1, module.Members.Count);
				Assert.AreSame(klass, module.Members[0]);

				var klassEntity = (IType) klass.Entity;
				Assert.IsTrue(klassEntity.IsClass);
				Assert.AreSame(TypeSystemServices.ObjectType, klassEntity.BaseType);

				var methodEntity = (IMethod)method.Entity;
				Assert.AreEqual(method.Name, methodEntity.Name);
				Assert.AreSame(TypeSystemServices.IntType, methodEntity.ReturnType);
			}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:28,代码来源:CodeReifierTest.cs


示例2: LeaveMethod

 public override void LeaveMethod(Method node)
 {
     if (node.Body.IsEmpty)
     {
         RemoveCurrentNode();
     }
 }
开发者ID:paveltimofeev,项目名称:documentation,代码行数:7,代码来源:RemoveEmptyMethods.cs


示例3: DoExpand

        /// <summary>
        /// Perform the actual expansion of the macro
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        protected override Statement DoExpand(MacroStatement macro)
        {
            if (macro.Arguments.Count != 0)
            {
                Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo,"No arguments allowed for action statement"));
                return null;
            }

            Method mergeRowsMethod = new Method("MergeRows");
            mergeRowsMethod.Modifiers = TypeMemberModifiers.Override;
            mergeRowsMethod.Parameters.Add(new ParameterDeclaration("left", new SimpleTypeReference(typeof(Row).FullName)));
            mergeRowsMethod.Parameters.Add(new ParameterDeclaration("right", new SimpleTypeReference(typeof(Row).FullName)));
            CodeBuilder.DeclareLocal(mergeRowsMethod, "row", TypeSystemServices.Map(typeof(Row)));
            mergeRowsMethod.Body.Add(
                new BinaryExpression(BinaryOperatorType.Assign,
                                     new ReferenceExpression("row"),
                                     new MethodInvocationExpression(
                                         AstUtil.CreateReferenceExpression(typeof(Row).FullName))
                    )
                );
            mergeRowsMethod.Body.Add(macro.Body);
            mergeRowsMethod.Body.Add(new ReturnStatement(new ReferenceExpression("row")));

            ParentMethods.Add(mergeRowsMethod);
            return null;
        }
开发者ID:f4i2u1,项目名称:rhino-etl,代码行数:31,代码来源:ActionMacro.cs


示例4: OnMethod

 public override void OnMethod(Method node)
 {
     if (LookingFor(node))
     {
         Found(node.ReturnType);
     }
 }
开发者ID:paveltimofeev,项目名称:documentation,代码行数:7,代码来源:MethodReturnTypeFinder.cs


示例5: NormalizeGetter

 public void NormalizeGetter(Method getter)
 {
     if ((getter != null) && (getter.get_Parameters().get_Count() != 0))
     {
         this.ReportError(UnityScriptCompilerErrors.InvalidPropertyGetter(getter.get_LexicalInfo()));
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:Parse.cs


示例6: CheckSetterReturnType

 public void CheckSetterReturnType(Method setter)
 {
     if (setter.get_ReturnType() != null)
     {
         this.ReportError(UnityScriptCompilerErrors.SetterCanNotDeclareReturnType(setter.get_ReturnType().get_LexicalInfo()));
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:Parse.cs


示例7: CreateGetter

		Method CreateGetter(Field f)
		{
			Method m = new Method();
			m.Name = "get";

			// value = ViewState["<f.Name>"]
			m.Body.Statements.Add(
				new ExpressionStatement(
					new BinaryExpression(
						BinaryOperatorType.Assign,
						new ReferenceExpression("value"),
						CreateViewStateSlice(f)
						)
					)
				);

			if (null != _default)
			{
				// return <_default> unless value
				ReturnStatement rs = new ReturnStatement(_default);
				rs.Modifier = new StatementModifier(StatementModifierType.Unless, new ReferenceExpression("value"));
				m.Body.Statements.Add(rs);
			}

			// return value
			m.Body.Statements.Add(
				new ReturnStatement(
					new ReferenceExpression("value")
					)
				);

			return m;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:33,代码来源:ViewStateAttribute.cs


示例8: OnMethod

		public override void OnMethod(Method node)
		{
			var old = _currentMethod;
			_currentMethod = (IMethod) node.Entity;
			base.OnMethod(node);
			_currentMethod = old;
		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:7,代码来源:DetectInnerGenerics.cs


示例9: VisitMethodDeclaration

		public object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
		{
			B.Method m = new B.Method(GetLexicalInfo(methodDeclaration));
			m.Name = methodDeclaration.Name;
			m.Modifiers = ConvertModifier(methodDeclaration, B.TypeMemberModifiers.Private);
			ConvertAttributes(methodDeclaration.Attributes, m.Attributes);
			if (currentType != null) currentType.Members.Add(m);
			if (methodDeclaration.HandlesClause.Count > 0) {
				// TODO: Convert handles clauses to [Handles] attribute
				AddError(methodDeclaration, "Handles-clause is not supported.");
			}
			m.ExplicitInfo = ConvertInterfaceImplementations(methodDeclaration.InterfaceImplementations, methodDeclaration, m);
			if (methodDeclaration.Templates.Count > 0) {
				AddError(methodDeclaration, "Declaring generic methods is not supported.");
			}
			ConvertParameters(methodDeclaration.Parameters, m.Parameters);
			m.EndSourceLocation = GetEndLocation((INode)methodDeclaration.Body ?? methodDeclaration);
			m.ReturnType = ConvertTypeReference(methodDeclaration.TypeReference);
			m.Body = ConvertMethodBlock(methodDeclaration.Body);
			if (m.Name == "Main" && m.IsStatic && m.Parameters.Count <= 1 &&
			    (methodDeclaration.TypeReference.Type == "System.Void" || methodDeclaration.TypeReference.Type == "System.Int32"))
			{
				entryPointMethod = m;
			}
			return m;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:26,代码来源:ConvertVisitorTypeMembers.cs


示例10: CheckEntryPoint

 public void CheckEntryPoint(Method node)
 {
     if ((node.get_IsStatic() && node.get_IsPublic()) && ((node.get_Name() == "Main") && (this.GetType(node.get_ReturnType()) == this.get_TypeSystemServices().VoidType)))
     {
         ContextAnnotations.SetEntryPoint(base._context, node);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:ProcessUnityScriptMethods.cs


示例11: NormalizeSetter

 public void NormalizeSetter(Method setter)
 {
     if (setter != null)
     {
         this.NormalizeSetterParameters(setter);
         this.CheckSetterReturnType(setter);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:8,代码来源:Parse.cs


示例12: ExpandGeneratorImpl

 protected override IEnumerable<Node> ExpandGeneratorImpl(MacroStatement macro){
     var method = new Method("_key"){
                                        ReturnType = new SimpleTypeReference("string"),
                                        Modifiers = TypeMemberModifiers.Public | TypeMemberModifiers.Override,
                                        Body = macro.extractMethodBody()
                                    };
     yield return method;
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:8,代码来源:CachekeyMacro.cs


示例13: LeaveMethod

        public override void LeaveMethod(Method method)
        {
            InternalMethod entity = (InternalMethod)method.Entity;
            if (!entity.IsGenerator) return;

            GeneratorMethodProcessor processor = new GeneratorMethodProcessor(Context, entity);
            processor.Run();
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:8,代码来源:ProcessGenerators.cs


示例14: LeaveMethod

		override public void LeaveMethod(Method node)
		{
			MakeStaticIfNeeded(node);
			CantBeMarkedTransient(node);
			CantBeMarkedPartial(node);
			CheckExplicitImpl(node);
			CheckModifierCombination(node);
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:8,代码来源:PreErrorChecking.cs


示例15: BooMethodBuilder

		public BooMethodBuilder(BooCodeBuilder codeBuilder, Method method)
		{
			if (null == codeBuilder)
				throw new ArgumentNullException("codeBuilder");
			if (null == method)
				throw new ArgumentNullException("method");
			_codeBuilder = codeBuilder;
			_method = method;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:9,代码来源:BooMethodBuilder.cs


示例16: CheckExtensionSemantics

 void CheckExtensionSemantics(Method node)
 {
     if (!((IMethod)node.Entity).IsExtension)
         return;
     if (NodeType.Method == node.NodeType
         && (node.IsStatic || node.DeclaringType is Module)
         && node.Parameters.Count != 0)
         return;
     Errors.Add(CompilerErrorFactory.InvalidExtensionDefinition(node));
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:10,代码来源:VerifyExtensionMethods.cs


示例17: CheckForEmptyCoroutine

 public void CheckForEmptyCoroutine(Method node)
 {
     if (this.IsEmptyCoroutine(node))
     {
         ReturnStatement statement;
         ReturnStatement statement1 = statement = new ReturnStatement(LexicalInfo.Empty);
         statement.set_Expression(Expression.Lift(this.EmptyEnumeratorReference));
         node.get_Body().Add(statement);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:10,代码来源:ProcessUnityScriptMethods.cs


示例18: CreateGeneratorSkeleton

		GeneratorSkeleton CreateGeneratorSkeleton(Node sourceNode, Method enclosingMethod, IType generatorItemType)
		{
			// create the class skeleton for type inference to work
			var builder = SetUpEnumerableClassBuilder(sourceNode, enclosingMethod, generatorItemType);
			var getEnumeratorBuilder = SetUpGetEnumeratorMethodBuilder(sourceNode, builder, generatorItemType);

			enclosingMethod.DeclaringType.Members.Add(builder.ClassDefinition);

			return new GeneratorSkeleton(builder, getEnumeratorBuilder, generatorItemType);
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:10,代码来源:GeneratorSkeletonBuilder.cs


示例19: OnMethod

 public override void OnMethod(Method node)
 {
     if (!node.get_IsPrivate())
     {
         this.SetPublicByDefault(node);
         if (!node.get_IsFinal() && !node.get_IsStatic())
         {
             node.set_Modifiers(node.get_Modifiers() | 0x80);
         }
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:11,代码来源:ApplyDefaultVisibility.cs


示例20: InternalGenericParameter

        public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration)
        {
            _tss = tss;
            _declaration = declaration;

            // Determine and remember declaring type and declaring method (if applicable)
            _declaringMethod = declaration.ParentNode as Method;
            _declaringType = (
                _declaringMethod == null ?
                declaration.ParentNode as TypeDefinition : _declaringMethod.DeclaringType);
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:11,代码来源:InternalGenericParameter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ast.MethodInvocationExpression类代码示例发布时间:2022-05-24
下一篇:
C# Ast.MemberReferenceExpression类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap