public void Add(VBox right) { switch (typeStack) { case NumberOnStack.Int32: v32 += right.v32; break; case NumberOnStack.Int64: v64 += right.v64; break; case NumberOnStack.Double: vDF += right.vDF; break; } }
public void And(VBox right) { switch (typeStack) { case NumberOnStack.Int32: v32 &= right.v32; break; case NumberOnStack.Int64: v64 &= right.v64; break; } }
//public static IBox Convert(IBox box, NumberType type) //{ // switch (type) // { // case NumberType.BOOL: // case NumberType.SBYTE: // case NumberType.BYTE: // case NumberType.CHAR: // case NumberType.INT16: // case NumberType.UINT16: // case NumberType.INT32: // case NumberType.UINT32: // { // if (box is BoxInt32) return box; // BoxInt32 v32 = ValueOnStack.Make(type) as BoxInt32; // BoxInt64 b64 = box as BoxInt64; // BoxDouble bdb = box as BoxDouble; // if (b64 != null) // v32.value = (int)b64.value; // else // v32.value = (int)bdb.value; // return v32; // } // case NumberType.INT64: // case NumberType.UINT64: // { // if (box is BoxInt64) return box; // BoxInt64 v64 = ValueOnStack.Make(type) as BoxInt64; // BoxInt32 b32 = box as BoxInt32; // BoxDouble bdb = box as BoxDouble; // if (b32 != null) // v64.value = b32.value; // else // v64.value = (Int64)bdb.value; // return v64; // } // case NumberType.FLOAT: // case NumberType.DOUBLE: // { // if (box is BoxDouble) return box; // BoxDouble vdb = new BoxDouble(type); // BoxInt32 b32 = box as BoxInt32; // BoxInt64 b64 = box as BoxInt64; // if (b32 != null) // vdb.value = b32.value; // else // vdb.value = b64.value; // return vdb; // } // default: // return null; // } //} public static VBox Convert(VBox box, NumberType type) { VBox b = MakeVBox(type); b.Set(box); return b; }
public static void UnUse(VBox box) { box.refcount = 0; unusedVBox.Enqueue(box); }
//似乎Clone可以替代New系列 public VBox Mod_New(VBox right) { VBox newbox = ValueOnStack.MakeVBox(type); switch (typeStack) { case NumberOnStack.Int32: newbox.v32 = v32 % right.v32; break; case NumberOnStack.Int64: newbox.v64 = v64 % right.v64; break; case NumberOnStack.Double: newbox.vDF = vDF % right.vDF; break; } return newbox; }
public void Set(VBox value) { switch (typeStack) { case NumberOnStack.Int32: if (value.typeStack == typeStack) v32 = value.v32; else v32 = value.ToInt(); break; case NumberOnStack.Int64: if (value.typeStack == typeStack) v64 = value.v64; else v64 = value.ToInt64(); break; case NumberOnStack.Double: if (value.typeStack == typeStack) vDF = value.vDF; else vDF = value.ToDouble(); break; } }
//< public bool logic_lt(VBox right) { switch (typeStack) { case NumberOnStack.Int32: return v32 < right.v32; case NumberOnStack.Int64: return v64 < right.v64; case NumberOnStack.Double: return vDF < right.vDF; default: return false; } }
//!= public bool logic_ne_Un(VBox right) { switch (typeStack) { case NumberOnStack.Int32: return (uint)v32 != (uint)right.v32; case NumberOnStack.Int64: return (UInt64)v64 != (UInt64)right.v64; case NumberOnStack.Double: return vDF != right.vDF; default: return false; } }
public static void UnUse(VBox box) { if (box == null) return; if (box.unuse) return; box.unuse = true; if (unusedVBox == null) unusedVBox = new Queue<VBox>(); //box.refcount = 0; unusedVBox.Enqueue(box); }
public bool logic_lt_Un(VBox right)//< { switch (typeStack) { case NumberOnStack.Int32: return (uint)v32 < (uint)right.v32; case NumberOnStack.Int64: return (UInt64)v64 < (UInt64)right.v64; case NumberOnStack.Double: return vDF < right.vDF; default: return false; } }
public bool logic_ge(VBox right)//>= { switch (typeStack) { case NumberOnStack.Int32: return v32 >= right.v32; case NumberOnStack.Int64: return v64 >= right.v64; case NumberOnStack.Double: return vDF >= right.vDF; default: return false; } }
public static void UnUse(VBox box) { if (unusedVBox == null) unusedVBox = new Queue<VBox>(); box.refcount = 0; unusedVBox.Enqueue(box); }