Skip to content

Commit

Permalink
[Truffle] Added the default internal encoding to the encoding map.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Mar 25, 2015
1 parent 7879048 commit 15d32a0
Showing 1 changed file with 16 additions and 2 deletions.
Expand Up @@ -553,24 +553,38 @@ public Object encodingMap(VirtualFrame frame) {
lookupTableWriteNode.call(frame, ret, "[]=", null, key, value);
}

final Encoding defaultInternalEncoding = getContext().getRuntime().getDefaultInternalEncoding();
final Object internalTuple = newTupleNode.call(
frame,
getContext().getCoreLibrary().getTupleClass(),
"create",
null,
getContext().makeString("internal"),
defaultInternalEncoding == null ? nil() : defaultInternalEncoding.getIndex()
);

lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("INTERNAL"), internalTuple);

final Encoding defaultExternalEncoding = getContext().getRuntime().getDefaultExternalEncoding();
final Object externalTuple = newTupleNode.call(
frame,
getContext().getCoreLibrary().getTupleClass(),
"create",
null,
getContext().makeString("external"),
getContext().getRuntime().getDefaultExternalEncoding().getIndex()
defaultExternalEncoding == null ? nil() : defaultExternalEncoding.getIndex()
);

lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("EXTERNAL"), externalTuple);

final Encoding localeEncoding = getContext().getRuntime().getEncodingService().getLocaleEncoding();
final Object localeTuple = newTupleNode.call(
frame,
getContext().getCoreLibrary().getTupleClass(),
"create",
null,
getContext().makeString("locale"),
getContext().getRuntime().getEncodingService().getLocaleEncoding().getIndex()
localeEncoding == null ? nil() : localeEncoding.getIndex()
);

lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("LOCALE"), localeTuple);
Expand Down

0 comments on commit 15d32a0

Please sign in to comment.