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

C# Constant类代码示例

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

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



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

示例1: Constant_accepts_Visitor

        public void Constant_accepts_Visitor()
        {
            var constant = new Constant(typeof(string), "a");
            constant.AcceptVisitor(theVisitor);

            theVisitor.AssertWasCalled(x => x.Constant(constant));
        }
开发者ID:joelweiss,项目名称:structuremap,代码行数:7,代码来源:Dependency_Visiting_Tester.cs


示例2: ApplyConstants

		public override Constant ApplyConstants(Constant c1, Constant c2)
		{
			return c1.ToInt32() != c2.ToInt32()
				? Constant.True() 
				: Constant.False();

		}
开发者ID:gitter-badger,项目名称:reko,代码行数:7,代码来源:ConditionalOperator.cs


示例3: ApplyConstant

 public override Constant ApplyConstant(Constant c)
 {
     if (c.IsValid)
         return c.Negate();
     else
         return c;
 }
开发者ID:relaxar,项目名称:reko,代码行数:7,代码来源:FNegOperator.cs


示例4: FormatValue

 public static string FormatValue(Constant c)
 {
     if (((PrimitiveType)c.DataType).Domain == Domain.SignedInt)
         return FormatSignedValue(c);
     else
         return FormatUnsignedValue(c);
 }
开发者ID:gitter-badger,项目名称:reko,代码行数:7,代码来源:MachineOperand.cs


示例5: Constant_accepts_Visitor

        public void Constant_accepts_Visitor()
        {
            var constant = new Constant(typeof(string), "a");
            constant.AcceptVisitor(theVisitor);

            theVisitor.Received().Constant(constant);
        }
开发者ID:khellang,项目名称:structuremap,代码行数:7,代码来源:Dependency_Visiting_Tester.cs


示例6: defineConstant

 public Constant defineConstant(string name, Type type, object value)
 {
     if (null == name) name = ".C"+m_code.constants.Count;
     Constant c = new Constant(name, type, value);
     m_code.constants.Add(c);
     return c;
 }
开发者ID:JasonWilkins,项目名称:visitor-tk,代码行数:7,代码来源:FlatBuilder.cs


示例7: ConstantQuery

        //---------------------------------------------------------------------
        public static void ConstantQuery(OleDbConnection dbcon, CodeGenerator cg)
        {
            cg.ConstantList.Clear();
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM Constants ORDER BY Topic, ID", dbcon);
            OleDbDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Constant curConst = new Constant();
                curConst.Name = dr["Name"].ToString();
                curConst.Value = dr["Value"].ToString();
                Int32 nTopic = Convert.ToInt32(dr["Topic"].ToString());
                if (nTopic > 0)
                {
                    curConst.Topic = cg.TopicList[nTopic - 1].Name.ToString();
                }
                else
                {
                    curConst.Topic = "";
                }
                curConst.Description = dr["Description"].ToString();
                cg.ConstantList.Add(curConst);

                //curConst.Print();
            }

            dr.Close();
        }
开发者ID:kevinflueckiger,项目名称:Application-SDK,代码行数:29,代码来源:DBReader.cs


示例8: ApplyConstants

        public override Constant ApplyConstants(Constant c1, Constant c2)
        {
            if (!ValidArgs(c1, c2))
                return Constant.Invalid;

            return BuildConstant(c1.DataType, c2.DataType, (int) (c1.ToUInt64() - c2.ToUInt64()));
        }
开发者ID:relaxar,项目名称:reko,代码行数:7,代码来源:ISubOperator.cs


示例9: MatchMul

		public bool MatchMul(BinaryExpression b)
		{
			if (b.Operator == Operator.SMul || b.Operator == Operator.UMul || b.Operator == Operator.IMul)
			{
				Constant c = b.Left as Constant;
				Expression e = b.Right;
				if (c == null)
				{
					c = b.Right as Constant;
					e = b.Left;
				}
				if (c != null)
				{
					elemSize = c;
					Index = e;
					return true;
				}
			}
			if (b.Operator == Operator.Shl)
			{
				Constant c = b.Right as Constant;
				if (c != null)
				{
					elemSize = b.Operator.ApplyConstants(Constant.Create(b.Left.DataType, 1), c);
					Index = b.Left;
					return true;
				}
			}
			return false;
		}
开发者ID:killbug2004,项目名称:reko,代码行数:30,代码来源:ArrayExpressionMatcher.cs


示例10: ApplyConstants

		public override Constant ApplyConstants(Constant c1, Constant c2)
		{
            if (!ValidArgs(c1, c2))
                return Constant.Invalid;

            return Constant.Bool(c1.ToInt32() >= c2.ToInt32());
        }
开发者ID:relaxar,项目名称:reko,代码行数:7,代码来源:SignedIntOperators.cs


示例11: Initialize

    private void Initialize() {
      // create all symbols
      var sum = new Sum();
      var prog = new Prog();
      var frog = new Frog();
      var left = new Left();
      var forward = new Forward();
      var constant = new Constant();

      var allSymbols = new List<ISymbol>() { sum, prog, frog, left, forward, constant };

      // add all symbols to the grammar
      foreach (var s in allSymbols)
        AddSymbol(s);

      // define grammar rules
      foreach (var s in allSymbols) {
        AddAllowedChildSymbol(sum, s);
        AddAllowedChildSymbol(sum, s);
        AddAllowedChildSymbol(prog, s);
        AddAllowedChildSymbol(prog, s);
        AddAllowedChildSymbol(frog, s);
        AddAllowedChildSymbol(StartSymbol, s);
      }
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:25,代码来源:Grammar.cs


示例12: Match

		public bool Match(BinaryExpression exp)
		{
			if (exp.Operator != Operator.IAdd)
				return false;
			id = exp.Left as Identifier;
			
			bin = exp.Right as BinaryExpression;
			if ((id == null || bin == null) && exp.Operator  == Operator.IAdd)
			{
				id = exp.Right as Identifier;
				bin = exp.Left as BinaryExpression;
			}
			if (id == null || bin == null)
				return false;

			if (bin.Operator != Operator.SMul && bin.Operator != Operator.UMul && bin.Operator != Operator.IMul)
				return false;

			Identifier idInner = bin.Left as Identifier;
			cInner = bin.Right as Constant;
			if (idInner == null ||cInner == null)
				return false;

			if (idInner != id)
				return false;

			return true;
		}
开发者ID:killbug2004,项目名称:reko,代码行数:28,代码来源:Add_mul_id_c_id_Rule.cs


示例13: ConstantProjectedSlot

 /// <summary>
 /// Creates a slot with constant value being <paramref name="value"/>.
 /// </summary>
 internal ConstantProjectedSlot(Constant value, MemberPath memberPath)
 {
     Debug.Assert(value != null);
     Debug.Assert(value.IsNotNull() == false, "Cannot store NotNull in a slot - NotNull is only for conditions");
     m_constant = value;
     m_memberPath = memberPath;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:ConstantProjectedSlot.cs


示例14: Create

 internal static CilConstant Create(Constant constant, ref CilReaders readers)
 {
     CilConstant ilConstant = new CilConstant();
     ilConstant._constant = constant;
     ilConstant._readers = readers;
     ilConstant._isTypeInitialized = false;
     return ilConstant;
 }
开发者ID:TerabyteX,项目名称:corefxlab,代码行数:8,代码来源:CilConstant.cs


示例15: TextureReplacement

 public TextureReplacement(string fname, Constant fmt, int w, int h, float s)
 {
     filename = fname;
     format = (int)fmt;
     width = w;
     height = h;
     scale = s;
 }
开发者ID:RichardGale,项目名称:lwf,代码行数:8,代码来源:lwf_format.cs


示例16: Match

		public bool Match(Slice slice)
		{
            if (!(slice.DataType is PrimitiveType))//$TODO: remove this once varargs processing is complete.
                return false;
			this.slice = slice;
			this.c = slice.Expression as Constant;
            return c != null && c != Constant.Invalid;
		}
开发者ID:relaxar,项目名称:reko,代码行数:8,代码来源:SliceConstant_Rule.cs


示例17: ApplyConstants

		public override Constant ApplyConstants(Constant c1, Constant c2)
		{
            if (!ValidArgs(c1, c2))
                return Constant.Invalid;
            uint v1 = c1.ToUInt32();
			uint v2 = c2.ToUInt32();
            return Constant.Bool(v1 <= v2);
		}
开发者ID:relaxar,项目名称:reko,代码行数:8,代码来源:UnsignedIntOperators.cs


示例18: MemoryOperand

		public MemoryOperand(PrimitiveType width, RegisterStorage @base, RegisterStorage index, byte scale,  Constant off) : base(width)
		{
            SegOverride = RegisterStorage.None;
			Base = @base;
			Offset = off;
			Index = index;
			Scale = scale;
		}
开发者ID:relaxar,项目名称:reko,代码行数:8,代码来源:MemoryOperand.cs


示例19: ApplyConstants

		public override Constant ApplyConstants(Constant c1, Constant c2)
		{
            if (!ValidArgs(c1, c2))
                return Constant.Invalid;
            if (c2.IsIntegerZero)
                return Constant.Invalid;
			return BuildConstant(c1.DataType, c2.DataType, c1.ToInt32() % c2.ToInt32());
		}
开发者ID:relaxar,项目名称:reko,代码行数:8,代码来源:IModOperator.cs


示例20: Match

		public bool Match(Expression e)
		{
			elemSize = null;
			Index = null;
			ArrayPointer = null;

			BinaryExpression b = e as BinaryExpression;
			if (b == null)
				return false;
            if (MatchMul(b))
            {
                ArrayPointer = Constant.Zero(b.DataType);
                return true;
            }

			// (+ x y)
			if (b.Operator == Operator.IAdd)
			{
				BinaryExpression bInner = b.Left as BinaryExpression;
				if (bInner != null)
				{
					if (MatchMul(bInner))
					{
						// (+ (* i c) ptr)
						ArrayPointer = b.Right;
						return true;
					}
				}
				bInner = b.Right as BinaryExpression;
				if (bInner != null)
				{
					if (MatchMul(bInner))
					{
						// (+ ptr (* i c))
						ArrayPointer = b.Left;
						return true;
					}
					if (bInner.Operator == Operator.IAdd)
					{
						// (+ x (+ a b)) 
						var bbInner = bInner.Left as BinaryExpression;
                        if (bbInner != null && MatchMul(bbInner))
                        {
                            // (+ x (+ (* i c) y)) rearranges to become
                            // (+ (* i c) (+ x y))

                            this.ArrayPointer = new BinaryExpression(
                                Operator.IAdd,
                                PrimitiveType.Create(Domain.Pointer, b.Left.DataType.Size),
                                b.Left,
                                bInner.Right);
                            return true;
                        }
					}
				}
			}
			return false;
		}
开发者ID:relaxar,项目名称:reko,代码行数:58,代码来源:ArrayExpressionMatcher.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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