//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 VBox Convert(VBox box, NumberType type) { VBox vBox = ValueOnStack.MakeVBox(type); vBox.Set(box); return(vBox); }