private static byte[] getFixnumBytes(RubyFixnum arg, int base, boolean sign, boolean upper) { long val = arg.getLongValue(); // limit the length of negatives if possible (also faster) if (val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) { if (sign) { return ConvertBytes.intToByteArray((int)val,base,upper); } else { switch(base) { case 2: return ConvertBytes.intToBinaryBytes((int)val); case 8: return ConvertBytes.intToOctalBytes((int)val); case 10: default: return ConvertBytes.intToCharBytes((int)val); case 16: return ConvertBytes.intToHexBytes((int)val,upper); } } } else { if (sign) { return ConvertBytes.longToByteArray(val,base,upper); } else { switch(base) { case 2: return ConvertBytes.longToBinaryBytes(val); case 8: return ConvertBytes.longToOctalBytes(val); case 10: default: return ConvertBytes.longToCharBytes(val); case 16: return ConvertBytes.longToHexBytes(val,upper); } } } }
private static byte[] getFixnumBytes(RubyFixnum arg, int base, boolean sign, boolean upper) { long val = arg.getLongValue(); // limit the length of negatives if possible (also faster) if (val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) { if (sign) { return ConvertBytes.intToByteArray((int)val,base,upper); } else { switch(base) { case 2: return ConvertBytes.intToBinaryBytes((int)val); case 8: return ConvertBytes.intToOctalBytes((int)val); case 10: default: return ConvertBytes.intToCharBytes((int)val); case 16: return ConvertBytes.intToHexBytes((int)val,upper); } } } else { if (sign) { return ConvertBytes.longToByteArray(val,base,upper); } else { switch(base) { case 2: return ConvertBytes.longToBinaryBytes(val); case 8: return ConvertBytes.longToOctalBytes(val); case 10: default: return ConvertBytes.longToCharBytes(val); case 16: return ConvertBytes.longToHexBytes(val,upper); } } } }
private static byte[] getFixnumBytes(RubyFixnum arg, int base, boolean sign, boolean upper) { long val = arg.getLongValue(); // limit the length of negatives if possible (also faster) if (val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) { if (sign) { return ConvertBytes.intToByteArray((int)val,base,upper); } else { switch(base) { case 2: return ConvertBytes.intToBinaryBytes((int)val); case 8: return ConvertBytes.intToOctalBytes((int)val); case 10: default: return ConvertBytes.intToCharBytes((int)val); case 16: return ConvertBytes.intToHexBytes((int)val,upper); } } } else { if (sign) { return ConvertBytes.longToByteArray(val,base,upper); } else { switch(base) { case 2: return ConvertBytes.longToBinaryBytes(val); case 8: return ConvertBytes.longToOctalBytes(val); case 10: default: return ConvertBytes.longToCharBytes(val); case 16: return ConvertBytes.longToHexBytes(val,upper); } } } }
private static byte[] getFixnumBytes(RubyFixnum arg, int base, boolean sign, boolean upper) { long val = arg.getLongValue(); // limit the length of negatives if possible (also faster) if (val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) { if (sign) { return ConvertBytes.intToByteArray((int)val,base,upper); } else { switch(base) { case 2: return ConvertBytes.intToBinaryBytes((int)val); case 8: return ConvertBytes.intToOctalBytes((int)val); case 10: default: return ConvertBytes.intToCharBytes((int)val); case 16: return ConvertBytes.intToHexBytes((int)val,upper); } } } else { if (sign) { return ConvertBytes.longToByteArray(val,base,upper); } else { switch(base) { case 2: return ConvertBytes.longToBinaryBytes(val); case 8: return ConvertBytes.longToOctalBytes(val); case 10: default: return ConvertBytes.longToCharBytes(val); case 16: return ConvertBytes.longToHexBytes(val,upper); } } } }
public final IRubyObject hashyInspect() { final Ruby runtime = getRuntime(); ByteList name = types(runtime, getMetaClass().getRealClass()).getByteList(); RubyString part = RubyString.newStringLight(runtime, 2 + name.length() + 3 + 8 + 1); // #<Object:0x5a1c0542> encStrBufCat(runtime, part, INSPECT_POUND_LT); encStrBufCat(runtime, part, name); encStrBufCat(runtime, part, INSPECT_COLON_ZERO_X); encStrBufCat(runtime, part, ConvertBytes.longToHexBytes(inspectHashCode())); if (runtime.isInspecting(this)) { encStrBufCat(runtime, part, INSPECT_SPACE_DOT_DOT_DOT_GT); return part; } try { runtime.registerInspecting(this); return inspectObj(runtime, part); } finally { runtime.unregisterInspecting(this); } }
public final IRubyObject hashyInspect() { final Ruby runtime = getRuntime(); ByteList name = types(runtime, getMetaClass().getRealClass()).getByteList(); RubyString part = RubyString.newStringLight(runtime, 2 + name.length() + 3 + 8 + 1); // #<Object:0x5a1c0542> encStrBufCat(runtime, part, INSPECT_POUND_LT); encStrBufCat(runtime, part, name); encStrBufCat(runtime, part, INSPECT_COLON_ZERO_X); encStrBufCat(runtime, part, ConvertBytes.longToHexBytes(inspectHashCode())); if (runtime.isInspecting(this)) { encStrBufCat(runtime, part, INSPECT_SPACE_DOT_DOT_DOT_GT); return part; } try { runtime.registerInspecting(this); return inspectObj(runtime, part); } finally { runtime.unregisterInspecting(this); } }