本文整理汇总了C#中Constant.ToInt32方法的典型用法代码示例。如果您正苦于以下问题:C# Constant.ToInt32方法的具体用法?C# Constant.ToInt32怎么用?C# Constant.ToInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constant
的用法示例。
在下文中一共展示了Constant.ToInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
try
{
return BuildConstant(c1.DataType, c2.DataType, unchecked((int) (c1.ToUInt32() * c2.ToUInt32())));
}
catch //$HACK: sometimes we get -ive numbers here, at which point .NET casts fail; attempt to use signed integers instead.
{
return BuildConstant(c1.DataType, c2.DataType, c1.ToInt32() * c1.ToInt32());
}
}
示例2: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
if (!ValidArgs(c1, c2))
return Constant.Invalid;
return Constant.Bool(c1.ToInt32() >= c2.ToInt32());
}
示例3: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
return c1.ToInt32() != c2.ToInt32()
? Constant.True()
: Constant.False();
}
示例4: 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());
}
示例5: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
if (!ValidArgs(c1, c2))
return Constant.Invalid;
return c1.ToInt32() != c2.ToInt32()
? Constant.True()
: Constant.False();
}
示例6: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
if (!ValidArgs(c1, c2))
return Constant.Invalid;
uint v1 = (uint) c1.ToInt32();
uint v2 = (uint) c2.ToInt32();
return Constant.Bool(v1 <= v2);
}
示例7: Match
public bool Match(DepositBits dpb)
{
this.dpb = dpb;
cSrc = dpb.Source as Constant;
if (cSrc == null)
return false;
cBits = dpb.InsertedBits as Constant;
if (cBits != null)
return true;
return (cSrc.ToInt32() == 0 && dpb.BitPosition == 0);
}
示例8: FormatSignedValue
public static string FormatSignedValue(Constant c)
{
string s = "+";
int tmp = c.ToInt32();
if (tmp < 0)
{
s = "-";
tmp = -tmp;
}
return s + tmp.ToString(FormatString(c.DataType));
}
示例9: SetRegister
public override void SetRegister(RegisterStorage r, Constant v)
{
if (v != null && v.IsValid)
{
values[r.Number] = (uint) v.ToInt32();
isValid[r.Number] = true;
}
else
{
isValid[r.Number] = false;
}
}
示例10: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
return BuildConstant(c1.DataType, c2.DataType, c1.ToInt32() << c2.ToInt32());
}
示例11: ApplyConstant
public override Constant ApplyConstant(Constant c)
{
return Constant.Create(c.DataType, ~c.ToInt32());
}
示例12: HandleAddition
private RegisterStorage HandleAddition(
RegisterStorage regIdx,
RegisterStorage ropDst,
RegisterStorage ropSrc,
Constant immSrc,
bool add)
{
if (ropSrc != null && immSrc == null)
{
if (ropSrc == ropDst && add)
{
Operations.Add(new BackwalkOperation(BackwalkOperator.mul, 2));
Stride *= 2;
return ropSrc;
}
else
{
return null;
}
}
if (immSrc != null)
{
if (!add && UsedAsFlag == IndexExpression)
{
Operations.Add(
new BackwalkOperation(
BackwalkOperator.cmp,
immSrc.ToInt32()));
}
else
{
Operations.Add(new BackwalkOperation(
add ? BackwalkOperator.add : BackwalkOperator.sub,
immSrc.ToInt32()));
}
return regIdx;
}
else
return null;
}
示例13: EmitLeImmediate
public void EmitLeImmediate(Constant c, PrimitiveType dt)
{
switch (dt.Size)
{
case 1: EmitByte(c.ToInt32()); return;
case 2: EmitLeUInt16(c.ToInt32()); return;
case 4: EmitLeUInt32(c.ToUInt32()); return;
default: throw new NotSupportedException(string.Format("Unsupported type: {0}", dt));
}
}
示例14: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
return Constant.Bool(c1.ToInt32() < c2.ToInt32());
}
示例15: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
if (!ValidArgs(c1, c2))
return Constant.Invalid;
return BuildConstant(c1.DataType, c2.DataType, (int) (c1.ToUInt32() >> c2.ToInt32()));
}