Skip to content

Commit

Permalink
Wrap TruffleString to ByteString
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Apr 19, 2022
1 parent 641f199 commit 542cdc5
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.oracle.truffle.api.dsl.GenerateUncached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.strings.TruffleString;

import de.hpi.swa.trufflesqueak.model.ArrayObject;
import de.hpi.swa.trufflesqueak.model.NativeObject;
Expand Down Expand Up @@ -87,6 +88,13 @@ protected final NativeObject doString(final String value,
return getContext().asString(value, wideStringProfile);
}

@Specialization
protected final NativeObject doTruffleString(final TruffleString value,
@Cached final TruffleString.ToJavaStringNode toJavaString,
@Cached final ConditionProfile wideStringProfile) {
return doString(toJavaString.execute(value), wideStringProfile);
}

@Specialization
protected final NativeObject doChar(final char value) {
return getContext().asByteString(MiscUtils.stringValueOf(value));
Expand Down

0 comments on commit 542cdc5

Please sign in to comment.