Esempio n. 1
0
 @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");
   }
 }
Esempio n. 2
0
 public static boolean isValidUtf8(DynamicObject string) {
   assert RubyGuards.isRubyString(string);
   return StringOperations.isCodeRangeValid(string)
       && Layouts.STRING.getRope(string).getEncoding().isUTF8();
 }
Esempio n. 3
0
 public static boolean isBrokenCodeRange(DynamicObject string) {
   assert RubyGuards.isRubyString(string);
   return StringOperations.codeRange(string) == CodeRange.CR_BROKEN;
 }
Esempio n. 4
0
 public static boolean is7Bit(DynamicObject string) {
   assert RubyGuards.isRubyString(string);
   return StringOperations.codeRange(string) == CodeRange.CR_7BIT;
 }