@Override public Object execute(VirtualFrame frame) { if (RubyGuards.isRubyString(ForeignAccess.getReceiver(frame))) { final DynamicObject string = (DynamicObject) ForeignAccess.getReceiver(frame); final int index = (int) ForeignAccess.getArguments(frame).get(labelIndex); if (index >= Layouts.STRING.getRope(string).byteLength()) { return 0; } else { return (byte) StringOperations.getByteListReadOnly(string).get(index); } } else { CompilerDirectives.transferToInterpreter(); throw new IllegalStateException("Not implemented"); } }
public static boolean isValidUtf8(DynamicObject string) { assert RubyGuards.isRubyString(string); return StringOperations.isCodeRangeValid(string) && Layouts.STRING.getRope(string).getEncoding().isUTF8(); }
public static boolean isBrokenCodeRange(DynamicObject string) { assert RubyGuards.isRubyString(string); return StringOperations.codeRange(string) == CodeRange.CR_BROKEN; }
public static boolean is7Bit(DynamicObject string) { assert RubyGuards.isRubyString(string); return StringOperations.codeRange(string) == CodeRange.CR_7BIT; }