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

C# OperatorDeclaration类代码示例

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

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



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

示例1: EmitOperatorDeclaration

        protected void EmitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
        {
            var typeDef = this.Emitter.GetTypeDefinition();
            var overloads = OverloadsCollection.Create(this.Emitter, operatorDeclaration);

            if (overloads.HasOverloads)
            {
                string name = overloads.GetOverloadName();
                this.Write(name);
            }
            else
            {
                this.Write(this.Emitter.GetEntityName(operatorDeclaration));
            }

            this.EmitMethodParameters(operatorDeclaration.Parameters, operatorDeclaration);

            this.WriteColon();

            var retType = BridgeTypes.ToJsName(operatorDeclaration.ReturnType, this.Emitter);
            retType = EmitBlock.HandleType(retType);
            this.Write(retType);

            this.WriteSemiColon();
            this.WriteNewLine();
        }
开发者ID:Oaz,项目名称:bridgedotnet_Builder,代码行数:26,代码来源:OperatorBlock.cs


示例2: VisitOperatorDeclaration

 public virtual void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
 {
     /*if (this.ThrowException)
     {
         throw (Exception)this.CreateException(operatorDeclaration);
     }*/
 }
开发者ID:txdv,项目名称:Builder,代码行数:7,代码来源:Visitor.Empty.cs


示例3: EmitOperatorDeclaration

        protected void EmitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
        {
            XmlToJsDoc.EmitComment(this, operatorDeclaration);
            var overloads = OverloadsCollection.Create(this.Emitter, operatorDeclaration);

            if (overloads.HasOverloads)
            {
                string name = overloads.GetOverloadName();
                this.Write(name);
            }
            else
            {
                this.Write(this.Emitter.GetEntityName(operatorDeclaration));
            }

            this.EmitMethodParameters(operatorDeclaration.Parameters, operatorDeclaration);

            this.WriteColon();

            var retType = BridgeTypes.ToTypeScriptName(operatorDeclaration.ReturnType, this.Emitter);
            this.Write(retType);

            this.WriteSemiColon();
            this.WriteNewLine();
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:25,代码来源:OperatorBlock.cs


示例4: VisitOperatorDeclaration

 public override void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
 {
     if (operatorDeclaration.OperatorType.IsComparisonOperator()) {
         // Ignore operator declaration; within them it's common to define one operator
         // by negating another.
         return;
     }
     base.VisitOperatorDeclaration(operatorDeclaration);
 }
开发者ID:artifexor,项目名称:NRefactory,代码行数:9,代码来源:NegativeRelationalExpressionIssue.cs


示例5: VisitOperatorDeclaration

        public override void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
        {
            FixAttributesAndDocComment(operatorDeclaration);

            ForceSpacesBefore(operatorDeclaration.LParToken, policy.SpaceBeforeMethodDeclarationParentheses);
            if (operatorDeclaration.Parameters.Any()) {
                ForceSpacesAfter(operatorDeclaration.LParToken, policy.SpaceWithinMethodDeclarationParentheses);
                FormatArguments(operatorDeclaration);
            } else {
                ForceSpacesAfter(operatorDeclaration.LParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses);
                ForceSpacesBefore(operatorDeclaration.RParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses);
            }

            if (!operatorDeclaration.Body.IsNull) {
                FixOpenBrace(policy.MethodBraceStyle, operatorDeclaration.Body.LBraceToken);
                VisitBlockWithoutFixingBraces(operatorDeclaration.Body, policy.IndentMethodBody);
                FixClosingBrace(policy.MethodBraceStyle, operatorDeclaration.Body.RBraceToken);
            }
        }
开发者ID:porcus,项目名称:NRefactory,代码行数:19,代码来源:FormattingVisitor_TypeMembers.cs


示例6: VisitOperatorDeclaration

        public override void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
        {
            var resolveResult = _resolver.Resolve(operatorDeclaration);
            if (!(resolveResult is MemberResolveResult)) {
                _errorReporter.Region = operatorDeclaration.GetRegion();
                _errorReporter.InternalError("Operator declaration " + OperatorDeclaration.GetName(operatorDeclaration.OperatorType) + " does not resolve to a member.");
                return;
            }
            var method = ((MemberResolveResult)resolveResult).Member as IMethod;
            if (method == null) {
                _errorReporter.Region = operatorDeclaration.GetRegion();
                _errorReporter.InternalError("Operator declaration " + OperatorDeclaration.GetName(operatorDeclaration.OperatorType) + " does not resolve to a method (resolves to " + resolveResult.ToString() + ")");
                return;
            }

            var jsClass = GetJsClass(method.DeclaringTypeDefinition);
            if (jsClass == null)
                return;

            MaybeCompileAndAddMethodToType(jsClass, operatorDeclaration, operatorDeclaration.Body, method, _metadataImporter.GetMethodSemantics(method));
        }
开发者ID:jack128,项目名称:SaltarelleCompiler,代码行数:21,代码来源:Compiler.cs


示例7: Visit

			public override void Visit (Operator o)
			{
				OperatorDeclaration newOperator = new OperatorDeclaration ();
				newOperator.OperatorType = (OperatorType)o.OperatorType;
				
				var location = LocationsBag.GetMemberLocation (o);
				
				AddModifiers (newOperator, location);
				
				newOperator.AddChild ((INode)o.TypeName.Accept (this), AbstractNode.Roles.ReturnType);
				
				if (o.OperatorType == Operator.OpType.Implicit) {
					if (location != null) {
						newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "implicit".Length), OperatorDeclaration.OperatorTypeRole);
						newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
					}
				} else if (o.OperatorType == Operator.OpType.Explicit) {
					if (location != null) {
						newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "explicit".Length), OperatorDeclaration.OperatorTypeRole);
						newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
					}
				} else {
					if (location != null)
						newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
					
					int opLength = 1;
					switch (newOperator.OperatorType) {
					case OperatorType.LeftShift:
					case OperatorType.RightShift:
					case OperatorType.LessThanOrEqual:
					case OperatorType.GreaterThanOrEqual:
					case OperatorType.Equality:
					case OperatorType.Inequality:
//					case OperatorType.LogicalAnd:
//					case OperatorType.LogicalOr:
						opLength = 2;
						break;
					case OperatorType.True:
						opLength = "true".Length;
						break;
					case OperatorType.False:
						opLength = "false".Length;
						break;
					}
					if (location != null)
						newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), opLength), OperatorDeclaration.OperatorTypeRole);
				}
				if (location != null)
					newOperator.AddChild (new CSharpTokenNode (Convert (location[2]), 1), OperatorDeclaration.Roles.LPar);
				AddParameter (newOperator, o.ParameterInfo);
				if (location != null)
					newOperator.AddChild (new CSharpTokenNode (Convert (location[3]), 1), OperatorDeclaration.Roles.RPar);
				
				if (o.Block != null)
					newOperator.AddChild ((INode)o.Block.Accept (this), OperatorDeclaration.Roles.Body);
				
				typeStack.Peek ().AddChild (newOperator, TypeDeclaration.Roles.Member);
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:58,代码来源:CSharpParser.cs


示例8: OverloadsCollection

 private OverloadsCollection(IEmitter emitter, OperatorDeclaration operatorDeclaration)
 {
     this.Emitter = emitter;
     this.Name = operatorDeclaration.Name;
     this.JsName = this.Emitter.GetEntityName(operatorDeclaration, false, true);
     this.Inherit = !operatorDeclaration.HasModifier(Modifiers.Static);
     this.Static = operatorDeclaration.HasModifier(Modifiers.Static);
     this.Member = this.FindMember(operatorDeclaration);
     this.TypeDefinition = this.Member.DeclaringTypeDefinition;
     this.Type = this.Member.DeclaringType;
     this.InitMembers();
     this.Emitter.OverloadsCache[operatorDeclaration.GetHashCode().ToString()] = this;
 }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:13,代码来源:OverloadsCollection.cs


示例9: case_271

void case_271()
#line 2240 "cs-parser.jay"
{
	  	Error_SyntaxError (yyToken);
		current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters;
	  	yyVal = new OperatorDeclaration (Operator.OpType.Explicit, null, GetLocation (yyVals[-1+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:7,代码来源:cs-parser.cs


示例10: case_242

void case_242()
#line 2116 "cs-parser.jay"
{
		valid_param_mod = 0;

		Location loc = GetLocation (yyVals[-5+yyTop]);
		Operator.OpType op = (Operator.OpType) yyVals[-4+yyTop];
		current_local_parameters = (ParametersCompiled)yyVals[-1+yyTop];
		
		int p_count = current_local_parameters.Count;
		if (p_count == 1) {
			if (op == Operator.OpType.Addition)
				op = Operator.OpType.UnaryPlus;
			else if (op == Operator.OpType.Subtraction)
				op = Operator.OpType.UnaryNegation;
		}
		
		if (IsUnaryOperator (op)) {
			if (p_count == 2) {
				report.Error (1020, loc, "Overloadable binary operator expected");
			} else if (p_count != 1) {
				report.Error (1535, loc, "Overloaded unary operator `{0}' takes one parameter",
					Operator.GetName (op));
			}
		} else {
			if (p_count == 1) {
				report.Error (1019, loc, "Overloadable unary operator expected");
			} else if (p_count != 2) {
				report.Error (1534, loc, "Overloaded binary operator `{0}' takes two parameters",
					Operator.GetName (op));
			}
		}
		
		if (doc_support) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.NotAllowed;
		}

		yyVal = new OperatorDeclaration (op, (FullNamedExpression) yyVals[-6+yyTop], loc);
		lbag.AddLocation (yyVal, GetLocation (yyVals[-5+yyTop]), savedOperatorLocation, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:41,代码来源:cs-parser.cs


示例11: yyparse


//.........这里部分代码省略.........
  {
		Report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants");
	  }
  break;
case 236:
#line 1928 "cs-parser.jay"
  {
	  	Report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators");
	  }
  break;
case 237:
#line 1932 "cs-parser.jay"
  {
	  	Report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors");
	  }
  break;
case 238:
#line 1936 "cs-parser.jay"
  {
	  	Report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations");
	  }
  break;
case 239:
#line 1943 "cs-parser.jay"
  {
	  }
  break;
case 240:
#line 1946 "cs-parser.jay"
  {
		if (yyVals[-2+yyTop] == null)
			break;

		OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop];
		Operator op = new Operator (
			current_class, decl.optype, decl.ret_type, (Modifiers) yyVals[-3+yyTop], 
			current_local_parameters,
			(ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location);

		if (RootContext.Documentation != null) {
			op.DocComment = tmpComment;
			Lexer.doc_state = XmlCommentState.Allowed;
		}

		/* Note again, checking is done in semantic analysis*/
		current_container.AddOperator (op);

		current_local_parameters = null;
	  }
  break;
case 242:
#line 1970 "cs-parser.jay"
  { yyVal = null; }
  break;
case 244:
#line 1976 "cs-parser.jay"
  {
		Report.Error (590, GetLocation (yyVals[0+yyTop]), "User-defined operators cannot return void");
		yyVal = TypeManager.system_void_expr;		
	  }
  break;
case 245:
#line 1984 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.DefaultValue;
	  }
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs


示例12: VisitOperatorDeclaration

        public void VisitOperatorDeclaration(OperatorDeclaration declaration)
        {
            Formatter.StartNode(declaration);

            if (declaration.CustomAttributeSections.Count > 0)
            {
                WriteNodes(declaration.CustomAttributeSections, true);
                Formatter.WriteLine();
            }

            if (declaration.ModifierElements.Count > 0)
            {
                WriteSpaceSeparatedNodes(declaration.ModifierElements);
                Formatter.WriteSpace();
            }

            if (declaration.OperatorType == OperatorDeclarationType.Explicit
                || declaration.OperatorType == OperatorDeclarationType.Implicit)
            {
                Formatter.WriteToken(CSharpLanguage.OperatorToString(declaration.OperatorType));
                Formatter.WriteSpace();
                Formatter.WriteKeyword("operator");
                Formatter.WriteSpace();
                declaration.ReturnType.AcceptVisitor(this);
            }
            else
            {
                declaration.ReturnType.AcceptVisitor(this);
                Formatter.WriteSpace();
                Formatter.WriteKeyword("operator");
                Formatter.WriteSpace();
                Formatter.WriteToken(CSharpLanguage.OperatorToString(declaration.OperatorType));
            }

            Formatter.WriteToken("(");
            WriteCommaSeparatedNodes(declaration.Parameters);
            Formatter.WriteToken(")");

            if (declaration.HasBody)
                declaration.Body.AcceptVisitor(this);
            else
                WriteSemicolon();

            Formatter.WriteLine();

            Formatter.EndNode();
        }
开发者ID:JerreS,项目名称:AbstractCode,代码行数:47,代码来源:CSharpAstWriter.cs


示例13: EmitOperatorDeclaration

        protected void EmitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
        {
            foreach (var attrSection in operatorDeclaration.Attributes)
            {
                foreach (var attr in attrSection.Attributes)
                {
                    var rr = this.Emitter.Resolver.ResolveNode(attr.Type, this.Emitter);
                    if (rr.Type.FullName == "Bridge.ExternalAttribute" || rr.Type.FullName == "Bridge.IgnoreAttribute")
                    {
                        return;
                    }
                }
            }

            XmlToJsDoc.EmitComment(this, operatorDeclaration);
            this.EnsureComma();
            this.ResetLocals();
            var prevMap = this.BuildLocalsMap();
            var prevNamesMap = this.BuildLocalsNamesMap();
            this.AddLocals(operatorDeclaration.Parameters, operatorDeclaration.Body);

            var typeDef = this.Emitter.GetTypeDefinition();
            var overloads = OverloadsCollection.Create(this.Emitter, operatorDeclaration);

            if (overloads.HasOverloads)
            {
                string name = overloads.GetOverloadName();
                this.Write(name);
            }
            else
            {
                this.Write(this.Emitter.GetEntityName(operatorDeclaration));
            }

            this.WriteColon();

            this.WriteFunction();

            this.EmitMethodParameters(operatorDeclaration.Parameters, operatorDeclaration);

            this.WriteSpace();

            var script = this.Emitter.GetScript(operatorDeclaration);

            if (script == null)
            {
                operatorDeclaration.Body.AcceptVisitor(this.Emitter);
            }
            else
            {
                this.BeginBlock();

                foreach (var line in script)
                {
                    this.Write(line);
                    this.WriteNewLine();
                }

                this.EndBlock();
            }

            this.ClearLocalsMap(prevMap);
            this.ClearLocalsNamesMap(prevNamesMap);
            this.Emitter.Comma = true;
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:65,代码来源:OperatorBlock.cs


示例14: VisitOperatorDeclaration

 public override void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
 {
     new OperatorBlock(this, operatorDeclaration).Emit();
 }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:4,代码来源:Emitter.Visitor.cs


示例15: ConvertOperator

		AstNode ConvertOperator(IMethod op)
		{
			OperatorType? opType = OperatorDeclaration.GetOperatorType(op.Name);
			if (opType == null)
				return ConvertMethod(op);
			
			OperatorDeclaration decl = new OperatorDeclaration();
			decl.Modifiers = GetMemberModifiers(op);
			decl.OperatorType = opType.Value;
			decl.ReturnType = ConvertTypeReference(op.ReturnType);
			foreach (IParameter p in op.Parameters) {
				decl.Parameters.Add(ConvertParameter(p));
			}
			return decl;
		}
开发者ID:jiguixin,项目名称:ILSpy,代码行数:15,代码来源:TypeSystemAstBuilder.cs


示例16: Create

        public static OverloadsCollection Create(IEmitter emitter, OperatorDeclaration operatorDeclaration)
        {
            string key = operatorDeclaration.GetHashCode().ToString();
            if (emitter.OverloadsCache.ContainsKey(key))
            {
                return emitter.OverloadsCache[key];
            }

            return new OverloadsCollection(emitter, operatorDeclaration);
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:10,代码来源:OverloadsCollection.cs


示例17: ConvertOperator

        EntityDeclaration ConvertOperator(IMethod op)
        {
            OperatorType? opType = OperatorDeclaration.GetOperatorType(op.Name);
            if (opType == null)
                return ConvertMethod(op);

            OperatorDeclaration decl = new OperatorDeclaration();
            decl.Modifiers = GetMemberModifiers(op);
            decl.OperatorType = opType.Value;
            decl.ReturnType = ConvertType(op.ReturnType);
            foreach (IParameter p in op.Parameters) {
                decl.Parameters.Add(ConvertParameter(p));
            }
            decl.Body = GenerateBodyBlock();
            return decl;
        }
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:16,代码来源:TypeSystemAstBuilder.cs


示例18: VisitOperatorDeclaration

			public override void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
			{
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:3,代码来源:CS0127ReturnMustNotBeFollowedByAnyExpression.cs


示例19: OperatorBlock

 public OperatorBlock(IEmitter emitter, OperatorDeclaration operatorDeclaration)
     : base(emitter, operatorDeclaration)
 {
     this.Emitter = emitter;
     this.OperatorDeclaration = operatorDeclaration;
 }
开发者ID:Oaz,项目名称:bridgedotnet_Builder,代码行数:6,代码来源:OperatorBlock.cs


示例20: case_269

void case_269()
#line 2215 "cs-parser.jay"
{
		valid_param_mod = 0;
		
		Location loc = GetLocation (yyVals[-5+yyTop]);
		current_local_parameters = (ParametersCompiled)yyVals[-1+yyTop];  

		if (current_local_parameters.Count != 1) {
			report.Error (1535, loc, "Overloaded unary operator `explicit' takes one parameter");
		}

		if (doc_support) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.NotAllowed;
		}

		yyVal = new OperatorDeclaration (Operator.OpType.Explicit, (FullNamedExpression) yyVals[-4+yyTop], loc);
		lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:20,代码来源:cs-parser.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# OperatorType类代码示例发布时间:2022-05-24
下一篇:
C# Operator类代码示例发布时间: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