本文整理汇总了C#中Constant类的典型用法代码示例。如果您正苦于以下问题:C# Constant类的具体用法?C# Constant怎么用?C# Constant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constant类属于命名空间,在下文中一共展示了Constant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例2: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
return c1.ToInt32() != c2.ToInt32()
? Constant.True()
: Constant.False();
}
示例3: ApplyConstant
public override Constant ApplyConstant(Constant c)
{
if (c.IsValid)
return c.Negate();
else
return c;
}
示例4: FormatValue
public static string FormatValue(Constant c)
{
if (((PrimitiveType)c.DataType).Domain == Domain.SignedInt)
return FormatSignedValue(c);
else
return FormatUnsignedValue(c);
}
示例5: Constant_accepts_Visitor
public void Constant_accepts_Visitor()
{
var constant = new Constant(typeof(string), "a");
constant.AcceptVisitor(theVisitor);
theVisitor.Received().Constant(constant);
}
示例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;
}
示例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();
}
示例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()));
}
示例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;
}
示例10: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
if (!ValidArgs(c1, c2))
return Constant.Invalid;
return Constant.Bool(c1.ToInt32() >= c2.ToInt32());
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}