Class TruffleString.FromByteArrayWithCompactionUTF32Node
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.strings.TruffleString.FromByteArrayWithCompactionUTF32Node
- All Implemented Interfaces:
NodeInterface, Cloneable
- Enclosing class:
TruffleString
Node to create a new
TruffleString from a byte array. See execute(byte[], int, int, TruffleString.CompactionLevel, boolean) for
details.- Since:
- 25.1
-
Nested Class Summary
Nested classes/interfaces inherited from class Node
Node.Child, Node.Children -
Method Summary
Modifier and TypeMethodDescriptioncreate()Create a newTruffleString.FromByteArrayWithCompactionUTF32Node.abstract TruffleStringexecute(byte[] array, int byteOffset, int byteLength, TruffleString.CompactionLevel compactionLevel, boolean copy) UTF-32-specific version ofTruffleString.FromByteArrayNodethat accepts compacted buffers.Get the uncached version ofTruffleString.FromByteArrayWithCompactionUTF32Node.Methods inherited from class Node
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, reportReplace, toString
-
Method Details
-
execute
public abstract TruffleString execute(byte[] array, int byteOffset, int byteLength, TruffleString.CompactionLevel compactionLevel, boolean copy) UTF-32-specific version ofTruffleString.FromByteArrayNodethat accepts compacted buffers. PassingTruffleString.CompactionLevel.S1means that the string is compacted to single bytes, i.e. it is equivalent to aTruffleString.Encoding.ISO_8859_1string. Analogously, passingTruffleString.CompactionLevel.S2means that the buffer is equivalent to aUCS-2string.Examples:
byte[] array = {'a', 'b', 'c'}; TruffleString str = fromByteArrayWithCompactionUTF32Node.execute(array, 0, array.length, CompactionLevel.S1, false); // returns a UTF-32 string "abc", re-using the byte array without copybyte[] array = {0x34, 0x12, 0x78, 0x56}; TruffleString str = fromByteArrayWithCompactionUTF32Node.execute(array, 0, array.length, CompactionLevel.S2, false); // returns a UTF-32 string "ሴ噸", re-using the byte array without copybyte[] array = {0x45, 0x23, 0x01, 0x00}; TruffleString str = fromByteArrayWithCompactionUTF32Node.execute(array, 0, array.length, CompactionLevel.S4, false); // returns a UTF-32 string containing the single codepoint 0x12345, re-using the byte array // without copyNote that this node may further compact (and therefore copy) the array if possible, or inflate if it contains illegal codepoints (i.e. surrogate values):
byte[] array = {'a', 0x00, 'b', 0x00}; TruffleString str = fromByteArrayWithCompactionUTF32Node.execute(array, 0, array.length, CompactionLevel.S2, false); // returns a UTF-32 string "ab", copying and further compacting the given array despite // copy=false- Parameters:
compactionLevel- describes the given string's compaction level.TruffleString.CompactionLevel.S1means one byte per codepoint,TruffleString.CompactionLevel.S2means two bytes per codepoint, andTruffleString.CompactionLevel.S4corresponds to four bytes per codepoint. Not strictly required to bepartial evaluation constant, but still recommended, since this parameter being constant avoids two branches and associated stub calls.copy- analogous to thecopyparameter ofTruffleString.FromByteArrayNode. Must bepartial evaluation constant.- Since:
- 25.1
-
create
Create a newTruffleString.FromByteArrayWithCompactionUTF32Node.- Since:
- 25.1
-
getUncached
Get the uncached version ofTruffleString.FromByteArrayWithCompactionUTF32Node.- Since:
- 25.1
-