return c;
}
+
+ public DecimalConstant ToDecimal (Location loc)
+ {
+ DecimalConstant c = ConvertToDecimal ();
+
+ if (c == null)
+ Convert.Error_CannotConvertType (loc, Type, TypeManager.decimal_type);
+
+ return c;
+ }
+
+ public virtual DecimalConstant ConvertToDecimal ()
+ {
+ return null;
+ }
public virtual DoubleConstant ConvertToDouble ()
{
return null;
}
+ public abstract bool IsNegative {
+ get;
+ }
+
//
// Returns true iff 1) the stack type of this is one of Object,
// int32, int64 and 2) this == 0 or this == null.
ec.ig.Emit (OpCodes.Ldc_I4_0);
}
+ public override bool IsNegative {
+ get {
+ return false;
+ }
+ }
+
public override bool IsZeroInteger {
get { return Value == false; }
}
return new IntConstant (Value);
}
+ public override bool IsNegative {
+ get {
+ return false;
+ }
+ }
+
public override bool IsZeroInteger {
get { return Value == 0; }
}
return new IntConstant (Value);
}
+ public override bool IsNegative {
+ get {
+ return false;
+ }
+ }
+
public override bool IsZeroInteger {
get { return Value == '\0'; }
}
return new IntConstant (Value);
}
+ public override bool IsNegative {
+ get {
+ return Value < 0;
+ }
+ }
+
public override bool IsZeroInteger {
get { return Value == 0; }
}
public override bool IsZeroInteger {
get { return Value == 0; }
}
+
+ public override bool IsNegative {
+ get {
+ return Value < 0;
+ }
+ }
}
public class UShortConstant : Constant {
return new IntConstant (Value);
}
+ public override bool IsNegative {
+ get {
+ return false;
+ }
+ }
+
public override bool IsZeroInteger {
get { return Value == 0; }
}
return Value;
}
+ public override DecimalConstant ConvertToDecimal()
+ {
+ return new DecimalConstant (Value);
+ }
+
public override DoubleConstant ConvertToDouble ()
{
return new DoubleConstant (Value);
return this;
}
+ public override bool IsNegative {
+ get {
+ return Value < 0;
+ }
+ }
+
public override bool IsZeroInteger {
get { return Value == 0; }
}
return null;
}
+ public override bool IsNegative {
+ get {
+ return false;
+ }
+ }
+
public override bool IsZeroInteger {
get { return Value == 0; }
}
return null;
}
+ public override bool IsNegative {
+ get {
+ return Value < 0;
+ }
+ }
+
public override bool IsZeroInteger {
get { return Value == 0; }
}
return null;
}
+ public override bool IsNegative {
+ get {
+ return false;
+ }
+ }
+
public override bool IsZeroInteger {
get { return Value == 0; }
}
{
return null;
}
+
+ public override bool IsNegative {
+ get {
+ return Value < 0;
+ }
+ }
}
public class DoubleConstant : Constant {
{
return null;
}
+
+ public override bool IsNegative {
+ get {
+ return Value < 0;
+ }
+ }
}
public class DecimalConstant : Constant {
public override void Emit (EmitContext ec)
{
+ ILGenerator ig = ec.ig;
+
int [] words = Decimal.GetBits (Value);
+ int power = (words [3] >> 16) & 0xff;
+
+ if (power == 0 && Value <= int.MaxValue && Value >= int.MinValue)
+ {
+ IntConstant.EmitInt (ig, (int)Value);
+ ig.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_int_arg);
+ return;
+ }
+
//
// FIXME: we could optimize this, and call a better
// constructor
//
- ILGenerator ig = ec.ig;
-
IntConstant.EmitInt (ig, words [0]);
IntConstant.EmitInt (ig, words [1]);
IntConstant.EmitInt (ig, words [2]);
IntConstant.EmitInt (ig, words [3] >> 31);
// power
- IntConstant.EmitInt (ig, (words [3] >> 16) & 0xff);
+ IntConstant.EmitInt (ig, power);
ig.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_five_args);
}
+
+ public override bool IsNegative {
+ get {
+ return Value < 0;
+ }
+ }
}
public class StringConstant : Constant {
else
ec.ig.Emit (OpCodes.Ldstr, Value);
}
+
+ public override bool IsNegative {
+ get {
+ return false;
+ }
+ }
}
}