public byte readSignedByte() throws IOException { int b = readUnsignedByte(); if (b > 127) { return (byte) (b - 256); } return (byte) b; }
public byte readSignedByte() throws IOException { int b = readUnsignedByte(); if (b > 127) { return (byte) (b - 256); } return (byte) b; }
public byte readSignedByte() throws IOException { int b = readUnsignedByte(); if (b > 127) { return (byte) (b - 256); } return (byte) b; }
public byte readSignedByte() throws IOException { int b = readUnsignedByte(); if (b > 127) { return (byte) (b - 256); } return (byte) b; }
public int unmarshalInt() throws IOException { int c = readSignedByte(); if (c == 0) { return 0; } else if (4 < c && c < 128) { return c - 5; } else if (-129 < c && c < -4) { return c + 5; } long result; if (c > 0) { result = 0; for (int i = 0; i < c; i++) { result |= (long) readUnsignedByte() << (8 * i); } } else { c = -c; result = -1; for (int i = 0; i < c; i++) { result &= ~((long) 0xff << (8 * i)); result |= (long) readUnsignedByte() << (8 * i); } } return (int) result; }
public int unmarshalInt() throws IOException { int c = readSignedByte(); if (c == 0) { return 0; } else if (4 < c && c < 128) { return c - 5; } else if (-129 < c && c < -4) { return c + 5; } long result; if (c > 0) { result = 0; for (int i = 0; i < c; i++) { result |= (long) readUnsignedByte() << (8 * i); } } else { c = -c; result = -1; for (int i = 0; i < c; i++) { result &= ~((long) 0xff << (8 * i)); result |= (long) readUnsignedByte() << (8 * i); } } return (int) result; }
public int unmarshalInt() throws IOException { int c = readSignedByte(); if (c == 0) { return 0; } else if (4 < c && c < 128) { return c - 5; } else if (-129 < c && c < -4) { return c + 5; } long result; if (c > 0) { result = 0; for (int i = 0; i < c; i++) { result |= (long) readUnsignedByte() << (8 * i); } } else { c = -c; result = -1; for (int i = 0; i < c; i++) { result &= ~((long) 0xff << (8 * i)); result |= (long) readUnsignedByte() << (8 * i); } } return (int) result; }
public int unmarshalInt() throws IOException { int c = readSignedByte(); if (c == 0) { return 0; } else if (4 < c && c < 128) { return c - 5; } else if (-129 < c && c < -4) { return c + 5; } long result; if (c > 0) { result = 0; for (int i = 0; i < c; i++) { result |= (long) readUnsignedByte() << (8 * i); } } else { c = -c; result = -1; for (int i = 0; i < c; i++) { result &= ~((long) 0xff << (8 * i)); result |= (long) readUnsignedByte() << (8 * i); } } return (int) result; }
public static RubyNumeric unmarshalFrom(UnmarshalStream input) throws IOException { boolean positive = input.readUnsignedByte() == '+'; int shortLength = input.unmarshalInt(); // BigInteger required a sign byte in incoming array byte[] digits = new byte[shortLength * 2 + 1]; for (int i = digits.length - 1; i >= 1; i--) { digits[i] = input.readSignedByte(); } BigInteger value = new BigInteger(digits); if (!positive) { value = value.negate(); } RubyNumeric result = bignorm(input.getRuntime(), value); input.registerLinkTarget(result); return result; } }
public static RubyNumeric unmarshalFrom(UnmarshalStream input) throws IOException { boolean positive = input.readUnsignedByte() == '+'; int shortLength = input.unmarshalInt(); // BigInteger required a sign byte in incoming array byte[] digits = new byte[shortLength * 2 + 1]; for (int i = digits.length - 1; i >= 1; i--) { digits[i] = input.readSignedByte(); } BigInteger value = new BigInteger(digits); if (!positive) { value = value.negate(); } RubyNumeric result = bignorm(input.getRuntime(), value); input.registerLinkTarget(result); return result; }
public static RubyNumeric unmarshalFrom(UnmarshalStream input) throws IOException { boolean positive = input.readUnsignedByte() == '+'; int shortLength = input.unmarshalInt(); // BigInteger required a sign byte in incoming array byte[] digits = new byte[shortLength * 2 + 1]; for (int i = digits.length - 1; i >= 1; i--) { digits[i] = input.readSignedByte(); } BigInteger value = new BigInteger(digits); if (!positive) { value = value.negate(); } RubyNumeric result = bignorm(input.getRuntime(), value); input.registerLinkTarget(result); return result; }
public static RubyNumeric unmarshalFrom(UnmarshalStream input) throws IOException { boolean positive = input.readUnsignedByte() == '+'; int shortLength = input.unmarshalInt(); // BigInteger required a sign byte in incoming array byte[] digits = new byte[shortLength * 2 + 1]; for (int i = digits.length - 1; i >= 1; i--) { digits[i] = input.readSignedByte(); } BigInteger value = new BigInteger(digits); if (!positive) { value = value.negate(); } RubyNumeric result = bignorm(input.getRuntime(), value); input.registerLinkTarget(result); return result; } }
private IRubyObject unmarshalObject(MarshalState state, boolean callProc) throws IOException { final int type = readUnsignedByte(); final IRubyObject result; if (cache.isLinkType(type)) { result = cache.readLink(this, type); if (callProc) return doCallProcForLink(result, type); } else { result = unmarshalObjectDirectly(type, state, callProc); } if (!( result instanceof RubyNumeric || result instanceof RubyEncoding )) { result.setTaint(taint); } return result; }
private IRubyObject unmarshalObject(MarshalState state, boolean callProc) throws IOException { final int type = readUnsignedByte(); final IRubyObject result; if (cache.isLinkType(type)) { result = cache.readLink(this, type); if (callProc) return doCallProcForLink(result, type); } else { result = unmarshalObjectDirectly(type, state, callProc); } if (!( result instanceof RubyNumeric || result instanceof RubyEncoding )) { result.setTaint(taint); } return result; }
public IRubyObject unmarshalObject(MarshalState state, boolean callProc) throws IOException { int type = readUnsignedByte(); IRubyObject result = null; if (cache.isLinkType(type)) { result = cache.readLink(this, type); if (callProc && runtime.is1_9()) return doCallProcForLink(result, type); } else { result = unmarshalObjectDirectly(type, state, callProc); } result.setTaint(taint); result.setUntrusted(untrust); return result; }
public IRubyObject unmarshalObject(MarshalState state, boolean callProc) throws IOException { int type = readUnsignedByte(); IRubyObject result = null; if (cache.isLinkType(type)) { result = cache.readLink(this, type); if (callProc && runtime.is1_9()) return doCallProcForLink(result, type); } else { result = unmarshalObjectDirectly(type, state, callProc); } result.setTaint(taint); result.setUntrusted(untrust); return result; }