/** Return atom as a string literal */ @Pure public synchronized String toUnicodeString() throws java.io.UTFDataFormatException { if (unicodeStringOrJTOCoffset == null) { String s = UTF8Convert.fromUTF8(val); if (VM.runningVM) { s = InternedStrings.internUnfoundString(s); unicodeStringOrJTOCoffset = s; } else if (!VM.writingImage) { s = s.intern(); int offset = Statics.findOrCreateObjectLiteral(s); unicodeStringOrJTOCoffset = offset; } return s; } else if (unicodeStringOrJTOCoffset instanceof String) { return (String) unicodeStringOrJTOCoffset; } else { if (VM.runningVM) { return (String) Statics.getSlotContentsAsObject( Offset.fromIntSignExtend((Integer) unicodeStringOrJTOCoffset)); } else { return UTF8Convert.fromUTF8(val).intern(); } } }
/** * Offset of an atom's string in the JTOC, for string literals * * @return Offset of string literal in JTOC * @throws java.io.UTFDataFormatException */ public synchronized int getStringLiteralOffset() throws java.io.UTFDataFormatException { if (unicodeStringOrJTOCoffset == null) { String s = UTF8Convert.fromUTF8(val); if (VM.runningVM) { s = InternedStrings.internUnfoundString(s); } else { s = s.intern(); } int offset = Statics.findOrCreateObjectLiteral(s); unicodeStringOrJTOCoffset = offset; return offset; } else if (unicodeStringOrJTOCoffset instanceof String) { int offset = Statics.findOrCreateObjectLiteral(unicodeStringOrJTOCoffset); unicodeStringOrJTOCoffset = offset; return offset; } else { return (Integer) unicodeStringOrJTOCoffset; } }
/** Atom as string literal or null if atom hasn't been converted */ private synchronized String toUnicodeStringInternal() { if (unicodeStringOrJTOCoffset == null) { return null; } else if (unicodeStringOrJTOCoffset instanceof String) { return (String) unicodeStringOrJTOCoffset; } else { if (VM.runningVM) { Object result = Statics.getSlotContentsAsObject( Offset.fromIntSignExtend((Integer) unicodeStringOrJTOCoffset)); return (String) result; } else { try { return UTF8Convert.fromUTF8(val).intern(); } catch (UTFDataFormatException e) { throw new Error("Error in UTF data encoding: ", e); } } } }