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

C# CSharp.If类代码示例

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

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



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

示例1: EmitCall


//.........这里部分代码省略.........
				}
			} else {
				d = null;
			}

			var site_type_decl = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec, new TypeArguments (del_type), loc);
			var field = site_container.CreateCallSiteField (site_type_decl, loc);
			if (field == null)
				return;

			if (del_type_instance_access == null) {
				var dt = d.CurrentType.DeclaringType.MakeGenericType (module, context_mvars.Types);
				del_type_instance_access = new TypeExpression (MemberCache.GetMember (dt, d.CurrentType), loc);
			}

			var instanceAccessExprType = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec,
				new TypeArguments (del_type_instance_access), loc);

			if (instanceAccessExprType.ResolveAsType (ec.MemberContext) == null)
				return;

			bool inflate_using_mvar = context_mvars != null && ec.IsAnonymousStoreyMutateRequired;

			TypeSpec gt;
			if (inflate_using_mvar || context_mvars == null) {
				gt = site_container.CurrentType;
			} else {
				gt = site_container.CurrentType.MakeGenericType (module, context_mvars.Types);
			}

			// When site container already exists the inflated version has to be
			// updated manually to contain newly created field
			if (gt is InflatedTypeSpec && site_container.AnonymousMethodsCounter > 1) {
				var tparams = gt.MemberDefinition.TypeParametersCount > 0 ? gt.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes;
				var inflator = new TypeParameterInflator (module, gt, tparams, gt.TypeArguments);
				gt.MemberCache.AddMember (field.InflateMember (inflator));
			}

			FieldExpr site_field_expr = new FieldExpr (MemberCache.GetMember (gt, field), loc);

			BlockContext bc = new BlockContext (ec.MemberContext, null, ec.BuiltinTypes.Void);

			Arguments args = new Arguments (1);
			args.Add (new Argument (binder));
			StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (instanceAccessExprType, "Create"), args)));

			using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {

				var conditionalAccessReceiver = IsConditionalAccessReceiver;
				var ca = ec.ConditionalAccess;

				if (conditionalAccessReceiver) {
					ec.ConditionalAccess = new ConditionalAccessContext (type, ec.DefineLabel ()) {
						Statement = isStatement
					};

					//
					// Emit conditional access expressions before dynamic call
					// is initialized. It pushes site_field_expr on stack before
					// the actual instance argument is emited which would cause
					// jump from non-empty stack.
					//
					EmitConditionalAccess (ec);
				}

				if (s.Resolve (bc)) {
					Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc);
					init.Emit (ec);
				}

				args = new Arguments (1 + dyn_args_count);
				args.Add (new Argument (site_field_expr));
				if (arguments != null) {
					int arg_pos = 1;
					foreach (Argument a in arguments) {
						if (a is NamedArgument) {
							// Name is not valid in this context
							args.Add (new Argument (a.Expr, a.ArgType));
						} else {
							args.Add (a);
						}

						if (inflate_using_mvar && a.Type != targs[arg_pos].Type)
							a.Expr.Type = targs[arg_pos].Type;

						++arg_pos;
					}
				}

				var target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, false, loc).Resolve (bc);
				if (target != null) {
					target.Emit (ec);
				}

				if (conditionalAccessReceiver) {
					ec.CloseConditionalAccess (!isStatement && type.IsNullableType ? type : null);
					ec.ConditionalAccess = ca;
				}
			}
		}
开发者ID:caomw,项目名称:mono,代码行数:101,代码来源:dynamic.cs


示例2: case_836

void case_836()
#line 5595 "cs-parser.jay"
{
		yyVal = new If ((BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
		
		if (yyVals[-2+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[-2+yyTop]));
		if (yyVals[0+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:11,代码来源:cs-parser.cs


示例3: case_837

void case_837()
#line 5605 "cs-parser.jay"
{
		Error_SyntaxError (yyToken);
		
		yyVal = new If ((BooleanExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-3+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:8,代码来源:cs-parser.cs


示例4: Visit

		public virtual object Visit (If ifStatement)
		{
			return null;
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs


示例5: EmitStatement

		public override void EmitStatement (EmitContext ec)
		{
			Statement cond = new If (
				new Binary (Binary.Operator.Equality, this, new BoolLiteral (true, loc)),
				new StatementExpression (invoke),
				new StatementExpression (assignment),
				loc);
			cond.Emit (ec);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:9,代码来源:dynamic.cs


示例6: EmitCall

        protected void EmitCall(EmitContext ec, Expression binder, Arguments arguments, bool isStatement)
        {
            int dyn_args_count = arguments == null ? 0 : arguments.Count;
            TypeExpr site_type = CreateSiteType (RootContext.ToplevelTypes.Compiler, arguments, dyn_args_count, isStatement);
            FieldExpr site_field_expr = new FieldExpr (CreateSiteField (site_type), loc);

            SymbolWriter.OpenCompilerGeneratedBlock (ec);

            Arguments args = new Arguments (1);
            args.Add (new Argument (binder));
            StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (site_type, "Create"), args)));

            BlockContext bc = new BlockContext (ec.MemberContext, null, TypeManager.void_type);
            if (s.Resolve (bc)) {
                Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc), loc), s, loc);
                init.Emit (ec);
            }

            args = new Arguments (1 + dyn_args_count);
            args.Add (new Argument (site_field_expr));
            if (arguments != null) {
                foreach (Argument a in arguments) {
                    if (a is NamedArgument) {
                        // Name is not valid in this context
                        args.Add (new Argument (a.Expr, a.ArgType));
                        continue;
                    }

                    args.Add (a);
                }
            }

            Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc);
            if (target != null)
                target.Emit (ec);

            SymbolWriter.CloseCompilerGeneratedBlock (ec);
        }
开发者ID:speier,项目名称:shake,代码行数:38,代码来源:dynamic.cs


示例7: yyparse


//.........这里部分代码省略.........
  {
		ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement;
		if (s == null) { 
			Expression.Error_InvalidExpressionStatement (report, GetLocation (yyVals[0+yyTop]));
			yyVal = new StatementExpression (EmptyExpressionStatement.Instance);
		} else {
			yyVal = new StatementExpression (s);
		}
	  }
  break;
case 799:
#line 5370 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		Expression expr = (Expression) yyVals[0+yyTop];
		ExpressionStatement s;

	        s = new OptionalAssign (new SimpleName ("$retval", lexer.Location), expr, lexer.Location);
		yyVal = new StatementExpression (s);
	  }
  break;
case 800:
#line 5378 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		Error_SyntaxError (yyToken);
		yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 803:
#line 5392 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  { 
		if (yyVals[0+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
		
		yyVal = new If ((BooleanExpression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 804:
#line 5401 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = new If ((BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
		
		if (yyVals[-2+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[-2+yyTop]));
		if (yyVals[0+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 805:
#line 5414 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		start_block (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 806:
#line 5418 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = new Switch ((Expression) yyVals[-5+yyTop], (ExplicitBlock) current_block.Explicit, (List<SwitchSection>) yyVals[-1+yyTop], GetLocation (yyVals[-7+yyTop]));	
		end_block (GetLocation (yyVals[0+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 807:
#line 5427 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
开发者ID:runefs,项目名称:Marvin,代码行数:67,代码来源:cs-parser.cs


示例8: DoResolve

				protected override bool DoResolve (BlockContext ec)
				{
					if (TypeManager.void_dispose_void == null) {
						TypeManager.void_dispose_void = TypeManager.GetPredefinedMethod (
							TypeManager.idisposable_type, "Dispose", loc, TypeSpec.EmptyTypes);
					}

					Expression dispose_var = (Expression) dispose ?? local_copy;

					var dispose_mg = MethodGroupExpr.CreatePredefined (TypeManager.void_dispose_void, TypeManager.idisposable_type, loc);
					dispose_mg.InstanceExpression = dispose_var;

					dispose_call = new StatementExpression (new Invocation (dispose_mg, null));

					if (!dispose_var.Type.IsStruct)
						dispose_call = new If (new Binary (Binary.Operator.Inequality, dispose_var, new NullLiteral (loc), loc), dispose_call, loc);

					return dispose_call.Resolve (ec);
				}
开发者ID:tgiphil,项目名称:mono,代码行数:19,代码来源:statement.cs


示例9: GenerateNumberMatcher

			Method GenerateNumberMatcher ()
			{
				var loc = Location;
				var parameters = ParametersCompiled.CreateFullyResolved (
					new [] {
						new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc),
						new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "value", 0, null, loc),
						new Parameter (new TypeExpression (Compiler.BuiltinTypes.Bool, loc), "enumType", 0, null, loc),
					},
					new [] {
						Compiler.BuiltinTypes.Object,
						Compiler.BuiltinTypes.Object,
						Compiler.BuiltinTypes.Bool
					});

				var m = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
					Modifiers.PUBLIC | Modifiers.STATIC | Modifiers.DEBUGGER_HIDDEN, new MemberName ("NumberMatcher", loc),
					parameters, null);

				parameters [0].Resolve (m, 0);
				parameters [1].Resolve (m, 1);
				parameters [2].Resolve (m, 2);

				ToplevelBlock top_block = new ToplevelBlock (Compiler, parameters, loc);
				m.Block = top_block;

				//
				// if (enumType)
				//		return Equals (obj, value);
				//
				var equals_args = new Arguments (2);
				equals_args.Add (new Argument (top_block.GetParameterReference (0, loc)));
				equals_args.Add (new Argument (top_block.GetParameterReference (1, loc)));

				var if_type = new If (
					              top_block.GetParameterReference (2, loc),
					              new Return (new Invocation (new SimpleName ("Equals", loc), equals_args), loc),
					              loc);

				top_block.AddStatement (if_type);

				//
				// if (obj is Enum || obj == null)
				//		return false;
				//

				var if_enum = new If (
					              new Binary (Binary.Operator.LogicalOr,
						              new Is (top_block.GetParameterReference (0, loc), new TypeExpression (Compiler.BuiltinTypes.Enum, loc), loc),
						              new Binary (Binary.Operator.Equality, top_block.GetParameterReference (0, loc), new NullLiteral (loc))),
					              new Return (new BoolLiteral (Compiler.BuiltinTypes, false, loc), loc),
					              loc);

				top_block.AddStatement (if_enum);


				var system_convert = new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Convert", loc);
				var expl_block = new ExplicitBlock (top_block, loc, loc);

				//
				// var converted = System.Convert.ChangeType (obj, System.Convert.GetTypeCode (value));
				//
				var lv_converted = LocalVariable.CreateCompilerGenerated (Compiler.BuiltinTypes.Object, top_block, loc);

				var arguments_gettypecode = new Arguments (1);
				arguments_gettypecode.Add (new Argument (top_block.GetParameterReference (1, loc)));

				var gettypecode = new Invocation (new MemberAccess (system_convert, "GetTypeCode", loc), arguments_gettypecode);

				var arguments_changetype = new Arguments (1);
				arguments_changetype.Add (new Argument (top_block.GetParameterReference (0, loc)));
				arguments_changetype.Add (new Argument (gettypecode));

				var changetype = new Invocation (new MemberAccess (system_convert, "ChangeType", loc), arguments_changetype);

				expl_block.AddStatement (new StatementExpression (new SimpleAssign (new LocalVariableReference (lv_converted, loc), changetype, loc)));


				//
				// return converted.Equals (value)
				//
				var equals_arguments = new Arguments (1);
				equals_arguments.Add (new Argument (top_block.GetParameterReference (1, loc)));
				var equals_invocation = new Invocation (new MemberAccess (new LocalVariableReference (lv_converted, loc), "Equals"), equals_arguments);
				expl_block.AddStatement (new Return (equals_invocation, loc));

				var catch_block = new ExplicitBlock (top_block, loc, loc);
				catch_block.AddStatement (new Return (new BoolLiteral (Compiler.BuiltinTypes, false, loc), loc));
				top_block.AddStatement (new TryCatch (expl_block, new List<Catch> () {
					new Catch (catch_block, loc)
				}, loc, false));

				m.Define ();
				m.PrepareEmit ();
				AddMember (m);

				return m;
			}
开发者ID:nobled,项目名称:mono,代码行数:98,代码来源:module.cs


示例10: EmitCallWithInvoke

		protected void EmitCallWithInvoke (EmitContext ec, Expression binder, Arguments arguments, bool isStatement)
		{
			var module = ec.Module;

			var site_container = ec.CreateDynamicSite ();

			BlockContext bc = new BlockContext (ec.MemberContext, null, ec.BuiltinTypes.Void);

			FieldExpr site_field_expr = null;
			StatementExpression s = null;

			// create call site
			var call_site = binder;
			if (call_site != null) {
				// resolve call site
				call_site = call_site.Resolve(bc);

				// create field for call site
				var site_type_decl = call_site.Type;  
				var field = site_container.CreateCallSiteField (new TypeExpression(site_type_decl, loc), loc);
				if (field == null) {
					throw new InvalidOperationException("Could not create call site field");
				}

				// ???
				bool inflate_using_mvar = context_mvars != null && ec.IsAnonymousStoreyMutateRequired;

				// ???
				TypeSpec gt;
				if (inflate_using_mvar || context_mvars == null) {
					gt = site_container.CurrentType;
				} else {
					gt = site_container.CurrentType.MakeGenericType (module, context_mvars.Types);
				}

				// When site container already exists the inflated version has to be
				// updated manually to contain newly created field
				if (gt is InflatedTypeSpec && site_container.AnonymousMethodsCounter > 1) {
					var tparams = gt.MemberDefinition.TypeParametersCount > 0 ? gt.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes;
					var inflator = new TypeParameterInflator (module, gt, tparams, gt.TypeArguments);
					gt.MemberCache.AddMember (field.InflateMember (inflator));
				}

				site_field_expr = new FieldExpr (MemberCache.GetMember (gt, field), loc);

				s = new StatementExpression (new SimpleAssign (site_field_expr, call_site));
			}



			using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
				if (s!= null && s.Resolve (bc)) {
					Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc);
					init.Emit (ec);
				}

				// remove dynamics from argument list
				arguments.CastDynamicArgs(bc);

				IDynamicCallSite dynamicCallSite = (IDynamicCallSite)this.binder;
				Expression target = dynamicCallSite.InvokeCallSite(bc, site_field_expr, arguments, type, isStatement);
				if (target != null) 
					target = target.Resolve(bc);

				if (target != null)
				{
					var statement = target as ExpressionStatement;
					if (isStatement && statement != null)
					{
						statement.EmitStatement(ec);
					}
					else
					{
						if (!isStatement && (target.Type != type)) {
							// PlayScript: If doing an invoke, we have to cast the return type to the type expected by the expression..
							target = new Cast(new TypeExpression(type, loc), target, loc).Resolve (bc);
						} 

						target.Emit(ec);
					}
				}
			}

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


示例11: yyparse


//.........这里部分代码省略.........

		yyVal = new StatementExpression (s);
	  }
  break;
case 716:
#line 4512 "cs-parser.jay"
  {
		Error_SyntaxError (yyToken);
		yyVal = null;
	  }
  break;
case 717:
#line 4520 "cs-parser.jay"
  {
		Expression expr = (Expression) yyVals[0+yyTop];
		ExpressionStatement s;

	        s = new OptionalAssign (new SimpleName ("$retval", lexer.Location), expr, lexer.Location);
		yyVal = new StatementExpression (s);
	  }
  break;
case 718:
#line 4528 "cs-parser.jay"
  {
		Error_SyntaxError (yyToken);
		yyVal = null;
	  }
  break;
case 721:
#line 4542 "cs-parser.jay"
  { 
		Location l = (Location) yyVals[-4+yyTop];

		yyVal = new If ((Expression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], l);

		/* FIXME: location for warning should be loc property of $5.*/
		if (yyVals[0+yyTop] == EmptyStatement.Value)
			Report.Warning (642, 3, l, "Possible mistaken empty statement");

	  }
  break;
case 722:
#line 4554 "cs-parser.jay"
  {
		Location l = (Location) yyVals[-6+yyTop];

		yyVal = new If ((Expression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], l);

		/* FIXME: location for warning should be loc property of $5 and $7.*/
		if (yyVals[-2+yyTop] == EmptyStatement.Value)
			Report.Warning (642, 3, l, "Possible mistaken empty statement");
		if (yyVals[0+yyTop] == EmptyStatement.Value)
			Report.Warning (642, 3, l, "Possible mistaken empty statement");
	  }
  break;
case 723:
#line 4569 "cs-parser.jay"
  { 
		if (switch_stack == null)
			switch_stack = new Stack (2);
		switch_stack.Push (current_block);
	  }
  break;
case 724:
#line 4576 "cs-parser.jay"
  {
开发者ID:lewurm,项目名称:benchmarker,代码行数:67,代码来源:cs-parser.cs


示例12: case_785

void case_785()
{
		Error_SyntaxError (yyToken);
		
		yyVal = new If ((BooleanExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-3+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:7,代码来源:cs-parser.cs


示例13: case_784

void case_784()
{
		yyVal = new If ((BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
		
		if (yyVals[-2+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[-2+yyTop]));
		if (yyVals[0+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  }
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:10,代码来源:cs-parser.cs


示例14: case_776

void case_776()
#line 5155 "cs-parser.jay"
{
		var eloc = GetLocation (yyVals[-1+yyTop]);
		report.Error (1026, eloc, "Expected a ')'");
		yyVal = new If ((BooleanExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-3+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
开发者ID:N3X15,项目名称:ILSpy,代码行数:8,代码来源:cs-parser.cs


示例15: EmitStatement

		public override void EmitStatement (EmitContext ec)
		{
			var stmt = new If (condition, new StatementExpression (invoke), new StatementExpression (assign), loc);
			using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
				stmt.Emit (ec);
			}
		}
开发者ID:caomw,项目名称:mono,代码行数:7,代码来源:dynamic.cs


示例16: EmitStatement

 public override void EmitStatement(EmitContext ec)
 {
     var stmt = new If (condition, new StatementExpression (invoke), new StatementExpression (assign), loc);
     stmt.Emit (ec);
 }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:5,代码来源:dynamic.cs


示例17: Visit

			public override object Visit(If ifStatement)
			{
				var result = new IfElseStatement();
				
				var location = LocationsBag.GetLocations(ifStatement);
				
				result.AddChild(new CSharpTokenNode(Convert(ifStatement.loc), IfElseStatement.IfKeywordRole), IfElseStatement.IfKeywordRole);
				if (location != null)
					result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
				if (ifStatement.Expr != null)
					result.AddChild((Expression)ifStatement.Expr.Accept(this), Roles.Condition);
				if (location != null && location.Count > 1)
					result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
				
				if (ifStatement.TrueStatement != null)
					result.AddChild((Statement)ifStatement.TrueStatement.Accept(this), IfElseStatement.TrueRole);
				
				if (ifStatement.FalseStatement != null) {
					if (location != null && location.Count > 2)
						result.AddChild(new CSharpTokenNode(Convert(location [2]), IfElseStatement.ElseKeywordRole), IfElseStatement.ElseKeywordRole);
					result.AddChild((Statement)ifStatement.FalseStatement.Accept(this), IfElseStatement.FalseRole);
				}
				
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:25,代码来源:CSharpParser.cs


示例18: CreateDisposeCall

			protected virtual Statement CreateDisposeCall (BlockContext bc, LocalVariable lv)
			{
				var lvr = lv.CreateReferenceExpression (bc, lv.Location);
				var type = lv.Type;
				var loc = lv.Location;

				if (TypeManager.void_dispose_void == null) {
					TypeManager.void_dispose_void = TypeManager.GetPredefinedMethod (
						TypeManager.idisposable_type, "Dispose", loc, TypeSpec.EmptyTypes);
				}

				var dispose_mg = MethodGroupExpr.CreatePredefined (TypeManager.void_dispose_void, TypeManager.idisposable_type, loc);
				dispose_mg.InstanceExpression = TypeManager.IsNullableType (type) ?
					new Cast (new TypeExpression (TypeManager.idisposable_type, loc), lvr, loc).Resolve (bc) :
					lvr;

				Statement dispose = new StatementExpression (new Invocation (dispose_mg, null));

				// Add conditional call when disposing possible null variable
				if (!type.IsStruct || TypeManager.IsNullableType (type))
					dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc), loc), dispose, loc);

				return dispose;
			}
开发者ID:alisci01,项目名称:mono,代码行数:24,代码来源:statement.cs


示例19: Visit

			public override object Visit (If ifStatement)
			{
				var result = new IfElseStatement ();
				
				var location = LocationsBag.GetLocations (ifStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (ifStatement.loc), "if".Length), IfElseStatement.IfKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), IfElseStatement.Roles.LPar);
				result.AddChild ((INode)ifStatement.Expr.Accept (this), IfElseStatement.Roles.Condition);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IfElseStatement.Roles.RPar);
				
				result.AddChild ((INode)ifStatement.TrueStatement.Accept (this), IfElseStatement.TrueEmbeddedStatementRole);
				
				if (ifStatement.FalseStatement != null) {
					if (location != null)
						result.AddChild (new CSharpTokenNode (Convert (location[2]), "else".Length), IfElseStatement.ElseKeywordRole);
					result.AddChild ((INode)ifStatement.FalseStatement.Accept (this), IfElseStatement.FalseEmbeddedStatementRole);
				}
				
				return result;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:23,代码来源:CSharpParser.cs


示例20: case_774

void case_774()
#line 4919 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
		yyVal = new If ((BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
		
		if (yyVals[-2+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[-2+yyTop]));
		if (yyVals[0+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:11,代码来源:cs-parser.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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