Skip to content

Commit aa73e78

Browse files
committed
Abstract out transcode handling.
What's going on here assumes encoded strings, and probably wants a revisit at some point. This can be a no-op on JVM, I guess...
1 parent 1c2690e commit aa73e78

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/HLL/Compiler.pm

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
class HLL::Backend::Parrot {
33
our %parrot_config := pir::getinterp__P()[pir::const::IGLOBALS_CONFIG_HASH];
44

5+
method apply_transcodings($s, $transcode) {
6+
for nqp::split(' ', $transcode) {
7+
try {
8+
$s := pir::trans_encoding__Ssi($s,
9+
pir::find_encoding__Is($_));
10+
}
11+
}
12+
return $s;
13+
}
14+
515
method config() {
616
%parrot_config
717
}
@@ -443,12 +453,7 @@ class HLL::Compiler does HLL::Backend::Default {
443453
method parse($source, *%adverbs) {
444454
my $s := $source;
445455
if %adverbs<transcode> {
446-
for nqp::split(' ', %adverbs<transcode>) {
447-
try {
448-
$s := pir::trans_encoding__Ssi($s,
449-
pir::find_encoding__Is($_));
450-
}
451-
}
456+
$s := $!backend.apply_transcodings($s, %adverbs<transcode>);
452457
}
453458
my $grammar := self.parsegrammar;
454459
my $actions;

0 commit comments

Comments
 (0)