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


C# RunSharp.Operand类代码示例

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


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

示例1: Assign

		public void Assign(Operand target, Operand value, bool allowExplicitConversion)
		{
			if ((object)target == null)
				throw new ArgumentNullException("target");

			BeforeStatement();

			target.Assign(value, allowExplicitConversion).Emit(this);
		}
开发者ID:amithasan,项目名称:Framework-Class-Library-Extension,代码行数:9,代码来源:CodeGen.Statements.cs

示例2: AssignDivide

		public void AssignDivide(Operand target, Operand value)
		{
			if ((object)target == null)
				throw new ArgumentNullException("target");

			BeforeStatement();

			target.AssignDivide(value).Emit(this);
		}
开发者ID:amithasan,项目名称:Framework-Class-Library-Extension,代码行数:9,代码来源:CodeGen.Statements.cs

示例3: SetLeakedState

 internal static void SetLeakedState(Operand[] operands, bool state)
 {
     if (operands != null)
     {
         for (int i = 0; i < operands.Length; i++)
         {
             OperandExtensions.SetLeakedState(operands[i], state);
         }
     }
 }
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:10,代码来源:OperandExtensions.cs

示例4: EmitArgs

		public void EmitArgs(CodeGen g, Operand[] args)
		{
			if (args.Length != appliedSignature.Length)
				throw new InvalidOperationException();

			if (IsExpanded)
			{
				int fixedCount = methodSignature.Length - 1;
				Type expType = methodSignature[fixedCount].GetElementType();

				for (int i = 0; i < fixedCount; i++)
					EmitArg(g, i, args[i]);

				int arrayLen = args.Length - methodSignature.Length - 1;
				g.EmitI4Helper(arrayLen);
				g.IL.Emit(OpCodes.Newarr, expType);
				OpCode stelemCode = CodeGen.GetStelemOpCode(expType);
				for (int i = 0; i < arrayLen; i++)
				{
					g.IL.Emit(OpCodes.Dup);
					g.EmitI4Helper(i);
					if (stelemCode == OpCodes.Stobj)
						g.IL.Emit(OpCodes.Ldelema, expType);
					EmitArg(g, fixedCount + i, args[fixedCount + i]);
					if (stelemCode == OpCodes.Stobj)
						g.IL.Emit(OpCodes.Stobj, expType);
					else
						g.IL.Emit(stelemCode);
				}
			}
			else
			{
				for (int i = 0; i < args.Length; i++)
					EmitArg(g, i, args[i]);
			}
		}
开发者ID:amithasan,项目名称:Framework-Class-Library-Extension,代码行数:36,代码来源:OverloadResolver.cs

示例5: GetExplicit

		public static Conversion GetExplicit(Operand op, Type to, bool onlyStandard, ITypeMapper typeMapper)
		{
			// try implicit
			Conversion conv = GetImplicit(op, to, onlyStandard, typeMapper);
			if (conv.IsValid)
				return conv;

			Type from = Operand.GetType(op, typeMapper);

		    Type fromUnderlying = Helpers.GetNullableUnderlyingType(@from);
		    if (fromUnderlying == to)
                return new UnwrapNullable(typeMapper);


            Type toUnderlying = Helpers.GetNullableUnderlyingType(to);
            if (toUnderlying != null && fromUnderlying != null)
            {
                var c = GetExplicit(new FakeTypedOperand(fromUnderlying), toUnderlying, onlyStandard, typeMapper);
                if (c.IsValid) return new ConvertNullable(typeMapper, c);
            }


		    // section 6.3.2 - Standard explicit conversions
            if (onlyStandard)
			{
				if (from == null || !GetImplicit(to, @from, true, typeMapper).IsValid)
					return new Invalid(typeMapper);
			}

			TypeCode tcFrom = Type.GetTypeCode(from);
			TypeCode tcTo = Type.GetTypeCode(to);
			byte ct = _convTable[(int)tcFrom][(int)tcTo];

			// section 6.2.1 - Explicit numeric conversions, 6.2.2 - Explicit enumeration conversions
			if ((from.IsPrimitive || from.IsEnum || Helpers.AreTypesEqual(from, typeof(decimal), typeMapper)) && (to.IsPrimitive || to.IsEnum || Helpers.AreTypesEqual(to, typeof(decimal), typeMapper)))
			{
				if (ct == D)
					return new Direct(typeMapper);	// this can happen for conversions involving enum-s

				if (ct <= E)
				{
				    if (Helpers.AreTypesEqual(from, typeof(decimal), typeMapper) || Helpers.AreTypesEqual(to, typeof(decimal), typeMapper))
						// decimal is handled as user-defined conversion, but as it is a standard one, always enable UDC processing
						onlyStandard = false;
					else
                        return new Primitive(typeMapper);
				}
			}

			// section 6.2.5 - User-defined explicit conversions (details in section 6.4.4)
		    if (!(onlyStandard || Helpers.AreTypesEqual(from, typeof(object), typeMapper) || Helpers.AreTypesEqual(to, typeof(object), typeMapper) || from.IsInterface || to.IsInterface ||
				to.IsSubclassOf(from) || from.IsSubclassOf(to)))
			{
				List<UserDefined> candidates = null;
				FindCandidates(ref candidates, FindExplicitMethods(from, to, typeMapper), op, to, GetExplicit, typeMapper);

				if (candidates != null)
				{
					if (candidates.Count == 1)
						return candidates[0];

					return UserDefined.FindExplicit(candidates, @from, to, typeMapper);
				}
			}

			// section 6.2.3 - Explicit reference conversions, 6.2.4 - Unboxing conversions
			// TODO: not really according to spec, but mostly works
			if (!from.IsValueType && from.IsAssignableFrom(to))
			{
				if (to.IsValueType)
					return new Unboxing(typeMapper);
				else
					return new Cast(typeMapper);
			}

			return new Invalid(typeMapper);
		}
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:77,代码来源:Conversion.cs

示例6: GetImplicit

        // the sections mentioned in comments of this method are from C# specification v1.2
		public static Conversion GetImplicit(Operand op, Type to, bool onlyStandard, ITypeMapper typeMapper)
		{
			Type from = Operand.GetType(op, typeMapper);

            Type toUnderlying = Helpers.GetNullableUnderlyingType(to);
		    if (to.Equals(from))
		        return new Direct(typeMapper);

            Type fromUnderlying = Helpers.GetNullableUnderlyingType(@from);
		    if (toUnderlying != null)
		    {
		        if (fromUnderlying != null)
		        {
		            Conversion c = GetImplicit(new FakeTypedOperand(fromUnderlying), toUnderlying, onlyStandard, typeMapper);
		            if (c.IsValid) return new ConvertNullable(typeMapper, c);
		        }
		        else
		        {
                    Conversion c = GetImplicit(op, toUnderlying, onlyStandard, typeMapper);
                    if (c.IsValid) return new WrapNullable(typeMapper, c);
                }
		    }
            
		    // required for arrays created from TypeBuilder-s
			if (from != null && to.IsArray && from.IsArray)
			{
				if (to.GetArrayRank() == from.GetArrayRank())
				{
					if (to.GetElementType().Equals(from.GetElementType()))
						return new Direct(typeMapper);
				}
			}

			TypeCode tcFrom = Type.GetTypeCode(from);
			TypeCode tcTo = Type.GetTypeCode(to);
			byte ct = _convTable[(int)tcFrom][(int)tcTo];

			// section 6.1.2 - Implicit numeric conversions
			if (from != null && (from.IsPrimitive || Helpers.AreTypesEqual(from, typeof(decimal), typeMapper)) && (to.IsPrimitive || Helpers.AreTypesEqual(to, typeof(decimal), typeMapper)))
			{
				if (ct <= I)
				{
				    if (Helpers.AreTypesEqual(from, typeof(decimal), typeMapper) || Helpers.AreTypesEqual(to, typeof(decimal), typeMapper))
						// decimal is handled as user-defined conversion, but as it is a standard one, always enable UDC processing
						onlyStandard = false;
					else
						return new Primitive(typeMapper);
				}
			}

			IntLiteral intLit = op as IntLiteral;

			// section 6.1.3 - Implicit enumeration conversions
			if (!onlyStandard && to.IsEnum && (object)intLit != null && intLit.Value == 0)
				return new Primitive(typeMapper);

			// section 6.1.4 - Implicit reference conversions
			if ((from == null || !from.IsValueType) && !to.IsValueType)
			{
				if (from == null) // from the null type to any reference type
					return new Direct(typeMapper);

				if (to.IsAssignableFrom(from))	// the rest
					return new Direct(typeMapper);
			}

			if (from == null)	// no other conversion from null type is possible
				return new Invalid(typeMapper);

			// section 6.1.5 - Boxing conversions
			if (from.IsValueType)
			{
				if (to.IsAssignableFrom(from))
					return new Boxing(typeMapper);
			}

			// section 6.1.6 - Implicit constant expression conversions
			if ((object)intLit != null && Helpers.AreTypesEqual(from, typeof(int), typeMapper) && to.IsPrimitive)
			{
				int val = intLit.Value;

				switch (tcTo)
				{
					case TypeCode.SByte:
						if (val >= sbyte.MinValue && val <= sbyte.MaxValue)
							return new Direct(typeMapper);
						break;
					case TypeCode.Byte:
						if (val >= byte.MinValue && val <= byte.MaxValue)
                            return new Direct(typeMapper);
                        break;
					case TypeCode.Int16:
						if (val >= short.MinValue && val <= short.MaxValue)
                            return new Direct(typeMapper);
                        break;
					case TypeCode.UInt16:
						if (val >= ushort.MinValue && val <= ushort.MaxValue)
                            return new Direct(typeMapper);
                        break;
//.........这里部分代码省略.........
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:101,代码来源:Conversion.cs

示例7: GetImplicit

		// the sections mentioned in comments of this method are from C# specification v1.2
		public static Conversion GetImplicit(Operand op, Type to, bool onlyStandard)
		{
			Type from = Operand.GetType(op);

			if (to.Equals(from))
				return Direct.Instance;

			// required for arrays created from TypeBuilder-s
			if (from != null && to.IsArray && from.IsArray)
			{
				if (to.GetArrayRank() == from.GetArrayRank())
				{
					if (to.GetElementType().Equals(from.GetElementType()))
						return Direct.Instance;
				}
			}

			TypeCode tcFrom = Type.GetTypeCode(from);
			TypeCode tcTo = Type.GetTypeCode(to);
			byte ct = convTable[(int)tcFrom][(int)tcTo];

			// section 6.1.2 - Implicit numeric conversions
			if ((from != null && (from.IsPrimitive || from == typeof(decimal))) && (to.IsPrimitive || to == typeof(decimal)))
			{
				if (ct <= I)
				{
					if (from == typeof(decimal) || to == typeof(decimal))
						// decimal is handled as user-defined conversion, but as it is a standard one, always enable UDC processing
						onlyStandard = false;
					else
						return Primitive.Instance;
				}
			}

			IntLiteral intLit = op as IntLiteral;

			// section 6.1.3 - Implicit enumeration conversions
			if (!onlyStandard && to.IsEnum && (object)intLit != null && intLit.Value == 0)
				return Primitive.Instance;

			// section 6.1.4 - Implicit reference conversions
			if ((from == null || !from.IsValueType) && !to.IsValueType)
			{
				if (from == null) // from the null type to any reference type
					return Direct.Instance;

				if (to.IsAssignableFrom(from))	// the rest
					return Direct.Instance;
			}

			if (from == null)	// no other conversion from null type is possible
				return Invalid.Instance;

			// section 6.1.5 - Boxing conversions
			if (from.IsValueType)
			{
				if (to.IsAssignableFrom(from))
					return Boxing.Instance;
			}

			// section 6.1.6 - Implicit constant expression conversions
			if ((object)intLit != null && from == typeof(int) && to.IsPrimitive)
			{
				int val = intLit.Value;

				switch (tcTo)
				{
					case TypeCode.SByte:
						if (val >= sbyte.MinValue && val <= sbyte.MaxValue)
							return Direct.Instance;
						break;
					case TypeCode.Byte:
						if (val >= byte.MinValue && val <= byte.MaxValue)
							return Direct.Instance;
						break;
					case TypeCode.Int16:
						if (val >= short.MinValue && val <= short.MaxValue)
							return Direct.Instance;
						break;
					case TypeCode.UInt16:
						if (val >= ushort.MinValue && val <= ushort.MaxValue)
							return Direct.Instance;
						break;
					case TypeCode.UInt32:
						if (val >= 0)
							return Direct.Instance;
						break;
					case TypeCode.UInt64:
						if (val >= 0)
							return Primitive.Instance;
						break;
				}
			}
			if (from == typeof(long))
			{
				LongLiteral longLit = op as LongLiteral;
				if ((object)longLit != null && longLit.Value > 0)
					return Direct.Instance;
			}
//.........这里部分代码省略.........
开发者ID:amithasan,项目名称:Framework-Class-Library-Extension,代码行数:101,代码来源:Conversion.cs

示例8: EmitSet

        protected internal virtual void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
		{
			throw new InvalidOperationException(string.Format(null, Properties.Messages.ErrOperandNotWritable, GetType()));
		}
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:4,代码来源:Operand.cs

示例9: GetType

        protected internal static Type GetType(Operand op, ITypeMapper typeMapper)
		{
			if ((object)op == null)
				return null;

			return op.GetReturnType(typeMapper);
		}
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:7,代码来源:Operand.cs

示例10: EmitGetHelper

	    protected void EmitGetHelper(CodeGen g, Operand op, Type desiredType, bool allowExplicitConversion)
	    {
            g.EmitGetHelper(op, desiredType,allowExplicitConversion);
	    }
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:4,代码来源:Operand.cs

示例11: Ne

		public Operand Ne(Operand value)
		{
			return new OverloadableOperation(Operator.Inequality, this, value);
		}
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:4,代码来源:Operand.cs

示例12: InvokeEquals

	    public ContextualOperand InvokeEquals(Operand right, ITypeMapper typeMapper)
	    {
            Operand left = this;
            var args = new Operand[] { left, right };
            return OperandExtensions.SetLeakedState(new ContextualOperand(new Invocation(typeMapper.TypeInfo.FindMethod(typeMapper.MapType(typeof(object)), "Equals", args, true), null, args), typeMapper), true);
        }
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:6,代码来源:Operand.cs

示例13: AssignRightShift

		public IStatement AssignRightShift(Operand value)
		{
			return Assign(RightShift(value));
		}
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:4,代码来源:Operand.cs

示例14: AssignLeftShift

		public IStatement AssignLeftShift(Operand value)
		{
			return Assign(LeftShift(value));
		}
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:4,代码来源:Operand.cs

示例15: AssignXor

		public IStatement AssignXor(Operand value)
		{
			return Assign(Xor(value));
		}
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:4,代码来源:Operand.cs


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