Package com.oracle.truffle.api.strings
Class TruffleString.AsNativeNode
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.strings.TruffleString.AsNativeNode
- All Implemented Interfaces:
NodeInterface
,Cloneable
- Enclosing class:
TruffleString
- Since:
- 23.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.oracle.truffle.api.nodes.Node
Node.Child, Node.Children
-
Method Summary
Modifier and TypeMethodDescriptionstatic TruffleString.AsNativeNode
create()
Create a newTruffleString.AsNativeNode
.abstract TruffleString
execute
(TruffleString a, NativeAllocator allocator, TruffleString.Encoding expectedEncoding, boolean useCompaction, boolean cacheResult) static TruffleString.AsNativeNode
Get the uncached version ofTruffleString.AsNativeNode
.Methods inherited from class com.oracle.truffle.api.nodes.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, toString
-
Method Details
-
execute
public abstract TruffleString execute(TruffleString a, NativeAllocator allocator, TruffleString.Encoding expectedEncoding, boolean useCompaction, boolean cacheResult) Convert a potentiallymanaged
TruffleString
to anative
string. If the given string isnative
already, it is returned. Otherwise, a new string with a backing native buffer allocated viaallocator
is created and stored in the given managed string's internal transcoding cache, such that subsequent calls on the same string will return the same native string. This operation requires native access permissions (TruffleLanguage.Env#isNativeAccessAllowed()
).- Parameters:
allocator
- a function implementingNativeAllocator
. This parameter is expected to bepartial evaluation constant
.useCompaction
- if set totrue
,TruffleString.Encoding.UTF_32
andTruffleString.Encoding.UTF_16
- encoded strings may be compacted also in the native representation. Otherwise, no string compaction is applied to the native string. This parameter is expected to bepartial evaluation constant
.cacheResult
- if set totrue
, the newly created native string will be cached in the given managed string's internal transcoding cache ring, guaranteeing that subsequent calls on the managed string return the same native string. Note that this ties the lifetime of the native string to that of the managed string. This parameter is expected to bepartial evaluation constant
.- Since:
- 23.0
-
create
Create a newTruffleString.AsNativeNode
.- Since:
- 23.0
-
getUncached
Get the uncached version ofTruffleString.AsNativeNode
.- Since:
- 23.0
-