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


C# EmitContext.HasSet方法代码示例

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


在下文中一共展示了EmitContext.HasSet方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmitPredefined

		public void EmitPredefined (EmitContext ec, MethodSpec method, Arguments Arguments, bool statement = false, Location? loc = null)
		{
			Expression instance_copy = null;

			if (!HasAwaitArguments && ec.HasSet (BuilderContext.Options.AsyncBody)) {
				HasAwaitArguments = Arguments != null && Arguments.ContainsEmitWithAwait ();
				if (HasAwaitArguments && InstanceExpressionOnStack) {
					throw new NotSupportedException ();
				}
			}

			OpCode call_op;
			LocalTemporary lt = null;

			if (method.IsStatic) {
				call_op = OpCodes.Call;
			} else {
				call_op = IsVirtualCallRequired (InstanceExpression, method) ? OpCodes.Callvirt : OpCodes.Call;

				if (HasAwaitArguments) {
					instance_copy = InstanceExpression.EmitToField (ec);
					var ie = new InstanceEmitter (instance_copy, IsAddressCall (instance_copy, call_op, method.DeclaringType));

					if (Arguments == null) {
						ie.EmitLoad (ec, true);
					}
				} else if (!InstanceExpressionOnStack) {
					var ie = new InstanceEmitter (InstanceExpression, IsAddressCall (InstanceExpression, call_op, method.DeclaringType));
					ie.Emit (ec, ConditionalAccess);

					if (DuplicateArguments) {
						ec.Emit (OpCodes.Dup);
						if (Arguments != null && Arguments.Count != 0) {
							lt = new LocalTemporary (ie.GetStackType (ec));
							lt.Store (ec);
							instance_copy = lt;
						}
					}
				}
			}

			if (Arguments != null && !InstanceExpressionOnStack) {
				EmittedArguments = Arguments.Emit (ec, DuplicateArguments, HasAwaitArguments);
				if (EmittedArguments != null) {
					if (instance_copy != null) {
						var ie = new InstanceEmitter (instance_copy, IsAddressCall (instance_copy, call_op, method.DeclaringType));
						ie.Emit (ec, ConditionalAccess);

						if (lt != null)
							lt.Release (ec);
					}

					EmittedArguments.Emit (ec);
				}
			}

			if (call_op == OpCodes.Callvirt && (InstanceExpression.Type.IsGenericParameter || InstanceExpression.Type.IsStructOrEnum)) {
				ec.Emit (OpCodes.Constrained, InstanceExpression.Type);
			}

			if (loc != null) {
				//
				// Emit explicit sequence point for expressions like Foo.Bar () to help debugger to
				// break at right place when LHS expression can be stepped-into
				//
				ec.MarkCallEntry (loc.Value);
			}

			//
			// Set instance expression to actual result expression. When it contains await it can be
			// picked up by caller
			//
			InstanceExpression = instance_copy;

			if (method.Parameters.HasArglist) {
				var varargs_types = GetVarargsTypes (method, Arguments);
				ec.Emit (call_op, method, varargs_types);
			} else {
				//
				// If you have:
				// this.DoFoo ();
				// and DoFoo is not virtual, you can omit the callvirt,
				// because you don't need the null checking behavior.
				//
				ec.Emit (call_op, method);
			}

			// 
			// Pop the return value if there is one and stack should be empty
			//
			if (statement && method.ReturnType.Kind != MemberKind.Void)
				ec.Emit (OpCodes.Pop);
		}
开发者ID:blinds52,项目名称:mono,代码行数:93,代码来源:codegen.cs

示例2: EmitStatement

		public override void EmitStatement (EmitContext ec)
		{
			if (resolved == null)
				return;

			//
			// Emit sequence symbol info even if we are in compiler generated
			// block to allow debugging field initializers when constructor is
			// compiler generated
			//
			if (ec.HasSet (BuilderContext.Options.OmitDebugInfo) && ec.HasMethodSymbolBuilder) {
				using (ec.With (BuilderContext.Options.OmitDebugInfo, false)) {
					ec.Mark (loc);
				}
			}

			if (resolved != this)
				resolved.EmitStatement (ec);
			else
				base.EmitStatement (ec);
		}
开发者ID:dyxu,项目名称:vimrc,代码行数:21,代码来源:assign.cs

示例3: Emit

        public override void Emit(EmitContext ec)
        {
            base.Emit (ec);

            if (ec.HasSet (EmitContext.Options.CheckedScope)) {
                switch (mode){
                case Mode.I1_U1: ec.Emit (OpCodes.Conv_Ovf_U1); break;
                case Mode.I1_U2: ec.Emit (OpCodes.Conv_Ovf_U2); break;
                case Mode.I1_U4: ec.Emit (OpCodes.Conv_Ovf_U4); break;
                case Mode.I1_U8: ec.Emit (OpCodes.Conv_Ovf_U8); break;
                case Mode.I1_CH: ec.Emit (OpCodes.Conv_Ovf_U2); break;

                case Mode.U1_I1: ec.Emit (OpCodes.Conv_Ovf_I1_Un); break;
                case Mode.U1_CH: /* nothing */ break;

                case Mode.I2_I1: ec.Emit (OpCodes.Conv_Ovf_I1); break;
                case Mode.I2_U1: ec.Emit (OpCodes.Conv_Ovf_U1); break;
                case Mode.I2_U2: ec.Emit (OpCodes.Conv_Ovf_U2); break;
                case Mode.I2_U4: ec.Emit (OpCodes.Conv_Ovf_U4); break;
                case Mode.I2_U8: ec.Emit (OpCodes.Conv_Ovf_U8); break;
                case Mode.I2_CH: ec.Emit (OpCodes.Conv_Ovf_U2); break;

                case Mode.U2_I1: ec.Emit (OpCodes.Conv_Ovf_I1_Un); break;
                case Mode.U2_U1: ec.Emit (OpCodes.Conv_Ovf_U1_Un); break;
                case Mode.U2_I2: ec.Emit (OpCodes.Conv_Ovf_I2_Un); break;
                case Mode.U2_CH: /* nothing */ break;

                case Mode.I4_I1: ec.Emit (OpCodes.Conv_Ovf_I1); break;
                case Mode.I4_U1: ec.Emit (OpCodes.Conv_Ovf_U1); break;
                case Mode.I4_I2: ec.Emit (OpCodes.Conv_Ovf_I2); break;
                case Mode.I4_U4: ec.Emit (OpCodes.Conv_Ovf_U4); break;
                case Mode.I4_U2: ec.Emit (OpCodes.Conv_Ovf_U2); break;
                case Mode.I4_U8: ec.Emit (OpCodes.Conv_Ovf_U8); break;
                case Mode.I4_CH: ec.Emit (OpCodes.Conv_Ovf_U2); break;

                case Mode.U4_I1: ec.Emit (OpCodes.Conv_Ovf_I1_Un); break;
                case Mode.U4_U1: ec.Emit (OpCodes.Conv_Ovf_U1_Un); break;
                case Mode.U4_I2: ec.Emit (OpCodes.Conv_Ovf_I2_Un); break;
                case Mode.U4_U2: ec.Emit (OpCodes.Conv_Ovf_U2_Un); break;
                case Mode.U4_I4: ec.Emit (OpCodes.Conv_Ovf_I4_Un); break;
                case Mode.U4_CH: ec.Emit (OpCodes.Conv_Ovf_U2_Un); break;

                case Mode.I8_I1: ec.Emit (OpCodes.Conv_Ovf_I1); break;
                case Mode.I8_U1: ec.Emit (OpCodes.Conv_Ovf_U1); break;
                case Mode.I8_I2: ec.Emit (OpCodes.Conv_Ovf_I2); break;
                case Mode.I8_U2: ec.Emit (OpCodes.Conv_Ovf_U2); break;
                case Mode.I8_I4: ec.Emit (OpCodes.Conv_Ovf_I4); break;
                case Mode.I8_U4: ec.Emit (OpCodes.Conv_Ovf_U4); break;
                case Mode.I8_U8: ec.Emit (OpCodes.Conv_Ovf_U8); break;
                case Mode.I8_CH: ec.Emit (OpCodes.Conv_Ovf_U2); break;
                case Mode.I8_I: ec.Emit (OpCodes.Conv_Ovf_U); break;

                case Mode.U8_I1: ec.Emit (OpCodes.Conv_Ovf_I1_Un); break;
                case Mode.U8_U1: ec.Emit (OpCodes.Conv_Ovf_U1_Un); break;
                case Mode.U8_I2: ec.Emit (OpCodes.Conv_Ovf_I2_Un); break;
                case Mode.U8_U2: ec.Emit (OpCodes.Conv_Ovf_U2_Un); break;
                case Mode.U8_I4: ec.Emit (OpCodes.Conv_Ovf_I4_Un); break;
                case Mode.U8_U4: ec.Emit (OpCodes.Conv_Ovf_U4_Un); break;
                case Mode.U8_I8: ec.Emit (OpCodes.Conv_Ovf_I8_Un); break;
                case Mode.U8_CH: ec.Emit (OpCodes.Conv_Ovf_U2_Un); break;
                case Mode.U8_I: ec.Emit (OpCodes.Conv_Ovf_U_Un); break;

                case Mode.CH_I1: ec.Emit (OpCodes.Conv_Ovf_I1_Un); break;
                case Mode.CH_U1: ec.Emit (OpCodes.Conv_Ovf_U1_Un); break;
                case Mode.CH_I2: ec.Emit (OpCodes.Conv_Ovf_I2_Un); break;

                case Mode.R4_I1: ec.Emit (OpCodes.Conv_Ovf_I1); break;
                case Mode.R4_U1: ec.Emit (OpCodes.Conv_Ovf_U1); break;
                case Mode.R4_I2: ec.Emit (OpCodes.Conv_Ovf_I2); break;
                case Mode.R4_U2: ec.Emit (OpCodes.Conv_Ovf_U2); break;
                case Mode.R4_I4: ec.Emit (OpCodes.Conv_Ovf_I4); break;
                case Mode.R4_U4: ec.Emit (OpCodes.Conv_Ovf_U4); break;
                case Mode.R4_I8: ec.Emit (OpCodes.Conv_Ovf_I8); break;
                case Mode.R4_U8: ec.Emit (OpCodes.Conv_Ovf_U8); break;
                case Mode.R4_CH: ec.Emit (OpCodes.Conv_Ovf_U2); break;

                case Mode.R8_I1: ec.Emit (OpCodes.Conv_Ovf_I1); break;
                case Mode.R8_U1: ec.Emit (OpCodes.Conv_Ovf_U1); break;
                case Mode.R8_I2: ec.Emit (OpCodes.Conv_Ovf_I2); break;
                case Mode.R8_U2: ec.Emit (OpCodes.Conv_Ovf_U2); break;
                case Mode.R8_I4: ec.Emit (OpCodes.Conv_Ovf_I4); break;
                case Mode.R8_U4: ec.Emit (OpCodes.Conv_Ovf_U4); break;
                case Mode.R8_I8: ec.Emit (OpCodes.Conv_Ovf_I8); break;
                case Mode.R8_U8: ec.Emit (OpCodes.Conv_Ovf_U8); break;
                case Mode.R8_CH: ec.Emit (OpCodes.Conv_Ovf_U2); break;
                case Mode.R8_R4: ec.Emit (OpCodes.Conv_R4); break;

                case Mode.I_I8: ec.Emit (OpCodes.Conv_Ovf_I8_Un); break;
                }
            } else {
                switch (mode){
                case Mode.I1_U1: ec.Emit (OpCodes.Conv_U1); break;
                case Mode.I1_U2: ec.Emit (OpCodes.Conv_U2); break;
                case Mode.I1_U4: ec.Emit (OpCodes.Conv_U4); break;
                case Mode.I1_U8: ec.Emit (OpCodes.Conv_I8); break;
                case Mode.I1_CH: ec.Emit (OpCodes.Conv_U2); break;

                case Mode.U1_I1: ec.Emit (OpCodes.Conv_I1); break;
                case Mode.U1_CH: ec.Emit (OpCodes.Conv_U2); break;

//.........这里部分代码省略.........
开发者ID:speier,项目名称:shake,代码行数:101,代码来源:ecore.cs

示例4: EmitPredefined

		public void EmitPredefined (EmitContext ec, MethodSpec method, Arguments Arguments)
		{
			Expression instance_copy = null;

			if (!HasAwaitArguments && ec.HasSet (BuilderContext.Options.AsyncBody)) {
				HasAwaitArguments = Arguments != null && Arguments.ContainsEmitWithAwait ();
				if (HasAwaitArguments && InstanceExpressionOnStack) {
					throw new NotSupportedException ();
				}
			}

			OpCode call_op;
			LocalTemporary lt = null;

			if (method.IsStatic) {
				call_op = OpCodes.Call;
			} else {
				if (IsVirtualCallRequired (InstanceExpression, method)) {
					call_op = OpCodes.Callvirt;
				} else {
					call_op = OpCodes.Call;
				}

				if (HasAwaitArguments) {
					instance_copy = InstanceExpression.EmitToField (ec);
					if (Arguments == null)
						EmitCallInstance (ec, instance_copy, method.DeclaringType, call_op);
				} else if (!InstanceExpressionOnStack) {
					var instance_on_stack_type = EmitCallInstance (ec, InstanceExpression, method.DeclaringType, call_op);

					if (DuplicateArguments) {
						ec.Emit (OpCodes.Dup);
						if (Arguments != null && Arguments.Count != 0) {
							lt = new LocalTemporary (instance_on_stack_type);
							lt.Store (ec);
							instance_copy = lt;
						}
					}
				}
			}

			if (Arguments != null && !InstanceExpressionOnStack) {
				EmittedArguments = Arguments.Emit (ec, DuplicateArguments, HasAwaitArguments);
				if (EmittedArguments != null) {
					if (instance_copy != null) {
						EmitCallInstance (ec, instance_copy, method.DeclaringType, call_op);

						if (lt != null)
							lt.Release (ec);
					}

					EmittedArguments.Emit (ec);
				}
			}

			if (call_op == OpCodes.Callvirt && (InstanceExpression.Type.IsGenericParameter || InstanceExpression.Type.IsStruct)) {
				ec.Emit (OpCodes.Constrained, InstanceExpression.Type);
			}

			//
			// Set instance expression to actual result expression. When it contains await it can be
			// picked up by caller
			//
			InstanceExpression = instance_copy;

			if (method.Parameters.HasArglist) {
				var varargs_types = GetVarargsTypes (method, Arguments);
				ec.Emit (call_op, method, varargs_types);
				return;
			}

			//
			// If you have:
			// this.DoFoo ();
			// and DoFoo is not virtual, you can omit the callvirt,
			// because you don't need the null checking behavior.
			//
			ec.Emit (call_op, method);
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:79,代码来源:codegen.cs

示例5: EmitPredefined

		public void EmitPredefined (EmitContext ec, MethodSpec method, Arguments Arguments, Location? loc = null)
		{
			Expression instance_copy = null;

			if (!HasAwaitArguments && ec.HasSet (BuilderContext.Options.AsyncBody)) {
				HasAwaitArguments = Arguments != null && Arguments.ContainsEmitWithAwait ();
				if (HasAwaitArguments && InstanceExpressionOnStack) {
					throw new NotSupportedException ();
				}
			}

			OpCode call_op;
			LocalTemporary lt = null;

			if (method.IsStatic) {
				call_op = OpCodes.Call;
			} else {
				if (IsVirtualCallRequired (InstanceExpression, method)) {
					call_op = OpCodes.Callvirt;
				} else {
					call_op = OpCodes.Call;
				}

				if (HasAwaitArguments) {
					instance_copy = InstanceExpression.EmitToField (ec);
					if (Arguments == null)
						EmitCallInstance (ec, instance_copy, method.DeclaringType, call_op);
				} else if (!InstanceExpressionOnStack) {
					var instance_on_stack_type = EmitCallInstance (ec, InstanceExpression, method.DeclaringType, call_op);

					if (DuplicateArguments) {
						ec.Emit (OpCodes.Dup);
						if (Arguments != null && Arguments.Count != 0) {
							lt = new LocalTemporary (instance_on_stack_type);
							lt.Store (ec);
							instance_copy = lt;
						}
					}
				}
			}

			if (Arguments != null && !InstanceExpressionOnStack) {
				EmittedArguments = Arguments.Emit (ec, DuplicateArguments, HasAwaitArguments);
				if (EmittedArguments != null) {
					if (instance_copy != null) {
						EmitCallInstance (ec, instance_copy, method.DeclaringType, call_op);

						if (lt != null)
							lt.Release (ec);
					}

					EmittedArguments.Emit (ec);
				}
			}

			if (call_op == OpCodes.Callvirt && (InstanceExpression.Type.IsGenericParameter || InstanceExpression.Type.IsStruct)) {
				ec.Emit (OpCodes.Constrained, InstanceExpression.Type);
			}

			if (loc != null) {
				//
				// Emit explicit sequence point for expressions like Foo.Bar () to help debugger to
				// break at right place when LHS expression can be stepped-into
				//
				// TODO: The list is probably not comprehensive, need to do more testing
				//
				if (InstanceExpression is PropertyExpr || InstanceExpression is Invocation || InstanceExpression is IndexerExpr ||
					InstanceExpression is New || InstanceExpression is DelegateInvocation)
					ec.Mark (loc.Value);
			}

			//
			// Set instance expression to actual result expression. When it contains await it can be
			// picked up by caller
			//
			InstanceExpression = instance_copy;

			if (method.Parameters.HasArglist) {
				var varargs_types = GetVarargsTypes (method, Arguments);
				ec.Emit (call_op, method, varargs_types);
				return;
			}

			//
			// If you have:
			// this.DoFoo ();
			// and DoFoo is not virtual, you can omit the callvirt,
			// because you don't need the null checking behavior.
			//
			ec.Emit (call_op, method);
		}
开发者ID:bbqchickenrobot,项目名称:playscript-mono,代码行数:91,代码来源:codegen.cs

示例6: AddressOf

        public void AddressOf(EmitContext ec, AddressOp mode)
        {
            if ((mode & AddressOp.Store) != 0)
                spec.MemberDefinition.SetIsAssigned ();
            if ((mode & AddressOp.Load) != 0)
                spec.MemberDefinition.SetIsUsed ();

            //
            // Handle initonly fields specially: make a copy and then
            // get the address of the copy.
            //
            bool need_copy;
            if (spec.IsReadOnly){
                need_copy = true;
                if (ec.HasSet (EmitContext.Options.ConstructorScope)){
                    if (IsStatic){
                        if (ec.IsStatic)
                            need_copy = false;
                    } else
                        need_copy = false;
                }
            } else
                need_copy = false;

            if (need_copy){
                LocalBuilder local;
                Emit (ec);
                local = ec.DeclareLocal (type, false);
                ec.Emit (OpCodes.Stloc, local);
                ec.Emit (OpCodes.Ldloca, local);
                return;
            }

            if (IsStatic){
                ec.Emit (OpCodes.Ldsflda, spec);
            } else {
                if (!prepared)
                    EmitInstance (ec, false);
                ec.Emit (OpCodes.Ldflda, spec);
            }
        }
开发者ID:speier,项目名称:shake,代码行数:41,代码来源:ecore.cs

示例7: EmitOperator

		protected void EmitOperator (EmitContext ec, Type type)
		{
			ILGenerator ig = ec.ig;

			switch (Oper) {
			case Operator.UnaryPlus:
				Expr.Emit (ec);
				break;
				
			case Operator.UnaryNegation:
				if (ec.HasSet (EmitContext.Options.CheckedScope) && !IsFloat (type)) {
					ig.Emit (OpCodes.Ldc_I4_0);
					if (type == TypeManager.int64_type)
						ig.Emit (OpCodes.Conv_U8);
					Expr.Emit (ec);
					ig.Emit (OpCodes.Sub_Ovf);
				} else {
					Expr.Emit (ec);
					ig.Emit (OpCodes.Neg);
				}
				
				break;
				
			case Operator.LogicalNot:
				Expr.Emit (ec);
				ig.Emit (OpCodes.Ldc_I4_0);
				ig.Emit (OpCodes.Ceq);
				break;
				
			case Operator.OnesComplement:
				Expr.Emit (ec);
				ig.Emit (OpCodes.Not);
				break;
				
			case Operator.AddressOf:
				((IMemoryLocation)Expr).AddressOf (ec, AddressOp.LoadStore);
				break;
				
			default:
				throw new Exception ("This should not happen: Operator = "
						     + Oper.ToString ());
			}

			//
			// Same trick as in Binary expression
			//
			if (enum_conversion != null)
				enum_conversion.Emit (ec);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:49,代码来源:expression.cs

示例8: EmitSideEffect

		public override void EmitSideEffect (EmitContext ec)
		{
			if ((oper & Operator.LogicalMask) != 0 ||
				(ec.HasSet (EmitContext.Options.CheckedScope) && (oper == Operator.Multiply || oper == Operator.Addition || oper == Operator.Subtraction))) {
				base.EmitSideEffect (ec);
			} else {
				left.EmitSideEffect (ec);
				right.EmitSideEffect (ec);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:10,代码来源:expression.cs

示例9: EmitOperatorOpcode

		public static void EmitOperatorOpcode (EmitContext ec, Operator oper, Type l)
		{
			OpCode opcode;
			ILGenerator ig = ec.ig;

			switch (oper){
			case Operator.Multiply:
				if (ec.HasSet (EmitContext.Options.CheckedScope)) {
					if (l == TypeManager.int32_type || l == TypeManager.int64_type)
						opcode = OpCodes.Mul_Ovf;
					else if (!IsFloat (l))
						opcode = OpCodes.Mul_Ovf_Un;
					else
						opcode = OpCodes.Mul;
				} else
					opcode = OpCodes.Mul;
				
				break;
				
			case Operator.Division:
				if (IsUnsigned (l))
					opcode = OpCodes.Div_Un;
				else
					opcode = OpCodes.Div;
				break;
				
			case Operator.Modulus:
				if (IsUnsigned (l))
					opcode = OpCodes.Rem_Un;
				else
					opcode = OpCodes.Rem;
				break;

			case Operator.Addition:
				if (ec.HasSet (EmitContext.Options.CheckedScope)) {
					if (l == TypeManager.int32_type || l == TypeManager.int64_type)
						opcode = OpCodes.Add_Ovf;
					else if (!IsFloat (l))
						opcode = OpCodes.Add_Ovf_Un;
					else
						opcode = OpCodes.Add;
				} else
					opcode = OpCodes.Add;
				break;

			case Operator.Subtraction:
				if (ec.HasSet (EmitContext.Options.CheckedScope)) {
					if (l == TypeManager.int32_type || l == TypeManager.int64_type)
						opcode = OpCodes.Sub_Ovf;
					else if (!IsFloat (l))
						opcode = OpCodes.Sub_Ovf_Un;
					else
						opcode = OpCodes.Sub;
				} else
					opcode = OpCodes.Sub;
				break;

			case Operator.RightShift:
				if (IsUnsigned (l))
					opcode = OpCodes.Shr_Un;
				else
					opcode = OpCodes.Shr;
				break;
				
			case Operator.LeftShift:
				opcode = OpCodes.Shl;
				break;

			case Operator.Equality:
				opcode = OpCodes.Ceq;
				break;

			case Operator.Inequality:
				ig.Emit (OpCodes.Ceq);
				ig.Emit (OpCodes.Ldc_I4_0);
				
				opcode = OpCodes.Ceq;
				break;

			case Operator.LessThan:
				if (IsUnsigned (l))
					opcode = OpCodes.Clt_Un;
				else
					opcode = OpCodes.Clt;
				break;

			case Operator.GreaterThan:
				if (IsUnsigned (l))
					opcode = OpCodes.Cgt_Un;
				else
					opcode = OpCodes.Cgt;
				break;

			case Operator.LessThanOrEqual:
				if (IsUnsigned (l) || IsFloat (l))
					ig.Emit (OpCodes.Cgt_Un);
				else
					ig.Emit (OpCodes.Cgt);
				ig.Emit (OpCodes.Ldc_I4_0);
				
//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:expression.cs

示例10: LoadOneAndEmitOp

		//
		// Loads the proper "1" into the stack based on the type, then it emits the
		// opcode for the operation requested
		//
		void LoadOneAndEmitOp (EmitContext ec, Type t)
		{
			//
			// Measure if getting the typecode and using that is more/less efficient
			// that comparing types.  t.GetTypeCode() is an internal call.
			//
			ILGenerator ig = ec.ig;
						     
			if (t == TypeManager.uint64_type || t == TypeManager.int64_type)
				LongConstant.EmitLong (ig, 1);
			else if (t == TypeManager.double_type)
				ig.Emit (OpCodes.Ldc_R8, 1.0);
			else if (t == TypeManager.float_type)
				ig.Emit (OpCodes.Ldc_R4, 1.0F);
			else if (t.IsPointer){
				Type et = TypeManager.GetElementType (t);
				int n = GetTypeSize (et);
				
				if (n == 0)
					ig.Emit (OpCodes.Sizeof, et);
				else {
					IntConstant.EmitInt (ig, n);
					ig.Emit (OpCodes.Conv_I);
				}
			} else 
				ig.Emit (OpCodes.Ldc_I4_1);

			//
			// Now emit the operation
			//

			Binary.Operator op = (mode & Mode.IsDecrement) != 0 ? Binary.Operator.Subtraction : Binary.Operator.Addition;
			Binary.EmitOperatorOpcode (ec, op, t);

			if (t == TypeManager.sbyte_type){
				if (ec.HasSet (EmitContext.Options.CheckedScope))
					ig.Emit (OpCodes.Conv_Ovf_I1);
				else
					ig.Emit (OpCodes.Conv_I1);
			} else if (t == TypeManager.byte_type){
				if (ec.HasSet (EmitContext.Options.CheckedScope))
					ig.Emit (OpCodes.Conv_Ovf_U1);
				else
					ig.Emit (OpCodes.Conv_U1);
			} else if (t == TypeManager.short_type){
				if (ec.HasSet (EmitContext.Options.CheckedScope))
					ig.Emit (OpCodes.Conv_Ovf_I2);
				else
					ig.Emit (OpCodes.Conv_I2);
			} else if (t == TypeManager.ushort_type || t == TypeManager.char_type){
				if (ec.HasSet (EmitContext.Options.CheckedScope))
					ig.Emit (OpCodes.Conv_Ovf_U2);
				else
					ig.Emit (OpCodes.Conv_U2);
			}
			
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:61,代码来源:expression.cs

示例11: AddressOf

		public void AddressOf (EmitContext ec, AddressOp mode)
		{
			ILGenerator ig = ec.ig;

			FieldBase f = TypeManager.GetField (FieldInfo);
			if (f != null){				
				if ((mode & AddressOp.Store) != 0)
					f.SetAssigned ();
				if ((mode & AddressOp.Load) != 0)
					f.SetMemberIsUsed ();
			}

			//
			// Handle initonly fields specially: make a copy and then
			// get the address of the copy.
			//
			bool need_copy;
			if (FieldInfo.IsInitOnly){
				need_copy = true;
				if (ec.HasSet (EmitContext.Options.ConstructorScope)){
					if (FieldInfo.IsStatic){
						if (ec.IsStatic)
							need_copy = false;
					} else
						need_copy = false;
				}
			} else
				need_copy = false;
			
			if (need_copy){
				LocalBuilder local;
				Emit (ec);
				local = ig.DeclareLocal (type);
				ig.Emit (OpCodes.Stloc, local);
				ig.Emit (OpCodes.Ldloca, local);
				return;
			}


			if (FieldInfo.IsStatic){
				ig.Emit (OpCodes.Ldsflda, GetConstructedFieldInfo ());
			} else {
				if (!prepared)
					EmitInstance (ec, false);
				ig.Emit (OpCodes.Ldflda, GetConstructedFieldInfo ());
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:47,代码来源:ecore.cs


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