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


C# CSharp.LocalVariable类代码示例

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


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

示例1: Emitter

			protected Emitter (Expression expr, LocalVariable li)
				: base (expr)
			{
				vi = li;
			}
开发者ID:alisci01,项目名称:mono,代码行数:5,代码来源:statement.cs

示例2: CaptureLocalVariable

		public void CaptureLocalVariable (ResolveContext ec, LocalVariable localVariable)
		{
			if (this is StateMachine) {
				if (ec.CurrentBlock.ParametersBlock != localVariable.Block.ParametersBlock)
					ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			} else {
				ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			}

			var hoisted = localVariable.HoistedVariant;
			if (hoisted != null && hoisted.Storey != this && hoisted.Storey is StateMachine) {
				//
				// Variable is already hoisted but we need it in storey which can be shared
				//
				hoisted.Storey.hoisted_locals.Remove (hoisted);
				hoisted.Storey.Members.Remove (hoisted.Field);
				hoisted = null;
			}

			if (hoisted == null) {
				hoisted = new HoistedLocalVariable (this, localVariable, GetVariableMangledName (localVariable));
				localVariable.HoistedVariant = hoisted;

				if (hoisted_locals == null)
					hoisted_locals = new List<HoistedVariable> ();

				hoisted_locals.Add (hoisted);
			}

			if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoisted.Storey is StateMachine))
				hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);
		}
开发者ID:erik-kallen,项目名称:NRefactory,代码行数:32,代码来源:anonymous.cs

示例3: GetVariableMangledName

		protected virtual string GetVariableMangledName (LocalVariable local_info)
		{
			//
			// No need to mangle anonymous method hoisted variables cause they
			// are hoisted in their own scopes
			//
			return local_info.Name;
		}
开发者ID:rabink,项目名称:mono,代码行数:8,代码来源:anonymous.cs

示例4: case_873

void case_873()
#line 5818 "cs-parser.jay"
{
		var lt = (LocatedToken) yyVals[0+yyTop];
		var li = new LocalVariable (current_block, lt.Value, lt.Location);
		current_block.AddLocalName (li);
		current_variable = new BlockVariable ((FullNamedExpression) yyVals[-1+yyTop], li);
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:8,代码来源:cs-parser.cs

示例5: case_885

void case_885()
#line 5899 "cs-parser.jay"
{
		start_block (GetLocation (yyVals[-5+yyTop]));
		current_block.IsCompilerGenerated = true;
		
		var lt = (LocatedToken) yyVals[-3+yyTop];
		var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location);
		current_block.AddLocalName (li);
		yyVal = li;
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:11,代码来源:cs-parser.cs

示例6: CaptureLocalVariable

		public void CaptureLocalVariable (ResolveContext ec, LocalVariable local_info)
		{
			ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			if (ec.CurrentBlock.Explicit != local_info.Block.Explicit)
				AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);

			if (local_info.HoistedVariant != null)
				return;

			HoistedVariable var = new HoistedLocalVariable (this, local_info, GetVariableMangledName (local_info));
			local_info.HoistedVariant = var;

			if (hoisted_locals == null)
				hoisted_locals = new List<HoistedVariable> ();

			hoisted_locals.Add (var);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:17,代码来源:anonymous.cs

示例7: case_813

void case_813()
#line 5458 "cs-parser.jay"
{
		var lt = (LocatedToken) yyVals[0+yyTop];	  
		var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location);
		var d = new BlockVariableDeclarator (li, null);
		current_variable.AddDeclarator (d);
		current_block.AddLocalName (li);
	  	lbag.AddLocation (d, GetLocation (yyVals[-1+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:10,代码来源:cs-parser.cs

示例8: VariableDeclaration

			public VariableDeclaration (LocalVariable li, Location loc)
				: base (li)
			{
				this.loc = loc;
			}
开发者ID:alisci01,项目名称:mono,代码行数:5,代码来源:statement.cs

示例9: ResolveInitializer

			protected override Expression ResolveInitializer (BlockContext bc, LocalVariable li, Expression initializer)
			{
				Assign assign;
				if (li.Type == InternalType.Dynamic) {
					initializer = initializer.Resolve (bc);
					if (initializer == null)
						return null;

					initializer = Convert.ImplicitConversionRequired (bc, initializer, TypeManager.idisposable_type, loc);
					if (initializer == null)
						return null;

					var var = LocalVariable.CreateCompilerGenerated (TypeManager.idisposable_type, bc.CurrentBlock, loc);
					assign = new SimpleAssign (var.CreateReferenceExpression (bc, loc), initializer, loc);
					assign.ResolveStatement (bc);

					dispose_call = CreateDisposeCall (bc, var);
					dispose_call.Resolve (bc);

					return assign;
				}

				if (li == Variable) {
					CheckIDiposableConversion (bc, li, initializer);
					dispose_call = CreateDisposeCall (bc, li);
					dispose_call.Resolve (bc);
				}

				return base.ResolveInitializer (bc, li, initializer);
			}
开发者ID:alisci01,项目名称:mono,代码行数:30,代码来源:statement.cs

示例10: DoResolve

			protected override Expression DoResolve (ResolveContext rc)
			{
				pinned_string = new LocalVariable (vi.Block, "$pinned",
					LocalVariable.Flags.FixedVariable | LocalVariable.Flags.CompilerGenerated | LocalVariable.Flags.Used,
					vi.Location);

				pinned_string.Type = TypeManager.string_type;

				if (TypeManager.int_get_offset_to_string_data == null) {
					TypeManager.int_get_offset_to_string_data = TypeManager.GetPredefinedProperty (
						TypeManager.runtime_helpers_type, "OffsetToStringData", pinned_string.Location, TypeManager.int32_type);
				}

				eclass = ExprClass.Variable;
				type = TypeManager.int32_type;
				return this;
			}
开发者ID:alisci01,项目名称:mono,代码行数:17,代码来源:statement.cs

示例11: StringEmitter

			public StringEmitter (Expression expr, LocalVariable li, Location loc)
				: base (expr, li)
			{
			}
开发者ID:alisci01,项目名称:mono,代码行数:4,代码来源:statement.cs

示例12: ExpressionEmitter

			public ExpressionEmitter (Expression converted, LocalVariable li) :
				base (converted, li)
			{
			}
开发者ID:alisci01,项目名称:mono,代码行数:4,代码来源:statement.cs

示例13: CheckIDiposableConversion

			protected virtual void CheckIDiposableConversion (BlockContext bc, LocalVariable li, Expression initializer)
			{
				var type = li.Type;

				if (type != TypeManager.idisposable_type && !type.ImplementsInterface (TypeManager.idisposable_type, false)) {
					if (TypeManager.IsNullableType (type)) {
						// it's handled in CreateDisposeCall
						return;
					}

					bc.Report.SymbolRelatedToPreviousError (type);
					var loc = type_expr == null ? initializer.Location : type_expr.Location;
					bc.Report.Error (1674, loc, "`{0}': type used in a using statement must be implicitly convertible to `System.IDisposable'",
						type.GetSignatureForError ());

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

示例14: VariableInfo

		public VariableInfo (LocalVariable local_info, int offset)
			: this (local_info.Name, local_info.Type, offset)
		{
			this.IsParameter = false;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:5,代码来源:flowanalysis.cs

示例15: 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


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