Skip to content

Commit

Permalink
Hopefully fix "make install" on the JVM backend
Browse files Browse the repository at this point in the history
For some reason, the JVM backend doesn't grok native str arrays in
the setting.  Spotted by bartolin++
  • Loading branch information
lizmat committed Jun 7, 2019
1 parent 89f8f60 commit e22aeaf
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/core/Rakudo/Internals/JSON.pm6
Expand Up @@ -69,75 +69,75 @@ my class Rakudo::Internals::JSON {
Bool :$sorted-keys = False,
) {

my str @out;
my $out := nqp::list_s; # cannot use str @out because of JVM
my str $spaces = ' ' x $spacing;
my str $comma = ",\n" ~ $spaces x $level;

#-- helper subs from here, with visibility to the above lexicals

sub pretty-positional(\positional --> Nil) {
$comma = nqp::concat($comma,$spaces);
nqp::push_s(@out,'[');
nqp::push_s(@out,nqp::substr($comma,1));
nqp::push_s($out,'[');
nqp::push_s($out,nqp::substr($comma,1));

for positional.list {
jsonify($_);
nqp::push_s(@out,$comma);
nqp::push_s($out,$comma);
}
nqp::pop_s(@out); # lose last comma
nqp::pop_s($out); # lose last comma

$comma = nqp::substr($comma,0,nqp::sub_i(nqp::chars($comma),$spacing));
nqp::push_s(@out,nqp::substr($comma,1));
nqp::push_s(@out,']');
nqp::push_s($out,nqp::substr($comma,1));
nqp::push_s($out,']');
}

sub pretty-associative(\associative --> Nil) {
$comma = nqp::concat($comma,$spaces);
nqp::push_s(@out,'{');
nqp::push_s(@out,nqp::substr($comma,1));
nqp::push_s($out,'{');
nqp::push_s($out,nqp::substr($comma,1));
my \pairs := $sorted-keys
?? associative.sort(*.key)
!! associative.list;

for pairs {
jsonify(.key);
nqp::push_s(@out,": ");
nqp::push_s($out,": ");
jsonify(.value);
nqp::push_s(@out,$comma);
nqp::push_s($out,$comma);
}
nqp::pop_s(@out); # lose last comma
nqp::pop_s($out); # lose last comma

$comma = nqp::substr($comma,0,nqp::sub_i(nqp::chars($comma),$spacing));
nqp::push_s(@out,nqp::substr($comma,1));
nqp::push_s(@out,'}');
nqp::push_s($out,nqp::substr($comma,1));
nqp::push_s($out,'}');
}

sub unpretty-positional(\positional --> Nil) {
nqp::push_s(@out,'[');
my int $before = nqp::elems(@out);
nqp::push_s($out,'[');
my int $before = nqp::elems($out);
for positional.list {
jsonify($_);
nqp::push_s(@out,",");
nqp::push_s($out,",");
}
nqp::pop_s(@out) if nqp::elems(@out) > $before; # lose last comma
nqp::push_s(@out,']');
nqp::pop_s($out) if nqp::elems($out) > $before; # lose last comma
nqp::push_s($out,']');
}

sub unpretty-associative(\associative --> Nil) {
nqp::push_s(@out,'{');
nqp::push_s($out,'{');
my \pairs := $sorted-keys
?? associative.sort(*.key)
!! associative.list;

my int $before = nqp::elems(@out);
my int $before = nqp::elems($out);
for pairs {
jsonify(.key);
nqp::push_s(@out,": ");
nqp::push_s($out,": ");
jsonify(.value);
nqp::push_s(@out,$comma);
nqp::push_s($out,$comma);
}
nqp::pop_s(@out) if nqp::elems(@out) > $before; # lose last comma
nqp::push_s(@out,'}');
nqp::pop_s($out) if nqp::elems($out) > $before; # lose last comma
nqp::push_s($out,'}');
}

sub jsonify(\obj --> Nil) {
Expand All @@ -146,7 +146,7 @@ my class Rakudo::Internals::JSON {

# basic ones
when Bool {
nqp::push_s(@out,obj ?? "true" !! "false");
nqp::push_s($out,obj ?? "true" !! "false");
}
when IntStr {
jsonify(.Int);
Expand All @@ -158,32 +158,32 @@ my class Rakudo::Internals::JSON {
jsonify(.Num);
}
when Str {
nqp::push_s(@out,'"');
nqp::push_s(@out,str-escape(obj));
nqp::push_s(@out,'"');
nqp::push_s($out,'"');
nqp::push_s($out,str-escape(obj));
nqp::push_s($out,'"');
}

# numeric ones
when Int {
nqp::push_s(@out,.Str);
nqp::push_s($out,.Str);
}
when Rat {
nqp::push_s(@out,.contains(".") ?? $_ !! "$_.0")
nqp::push_s($out,.contains(".") ?? $_ !! "$_.0")
given .Str;
}
when FatRat {
nqp::push_s(@out,.contains(".") ?? $_ !! "$_.0")
nqp::push_s($out,.contains(".") ?? $_ !! "$_.0")
given .Str;
}
when Num {
if nqp::isnanorinf($_) {
nqp::push_s(
@out,
$out,
$*JSON_NAN_INF_SUPPORT ?? obj.Str !! "null"
);
}
else {
nqp::push_s(@out,.contains("e") ?? $_ !! $_ ~ "e0")
nqp::push_s($out,.contains("e") ?? $_ !! $_ ~ "e0")
given .Str;
}
}
Expand All @@ -205,10 +205,10 @@ my class Rakudo::Internals::JSON {

# rarer ones
when Dateish {
nqp::push_s(@out,qq/"$_"/);
nqp::push_s($out,qq/"$_"/);
}
when Instant {
nqp::push_s(@out,qq/"{.DateTime}"/)
nqp::push_s($out,qq/"{.DateTime}"/)
}
when Version {
jsonify(.Str)
Expand Down Expand Up @@ -237,14 +237,14 @@ my class Rakudo::Internals::JSON {
}
}
else {
nqp::push_s(@out,'null');
nqp::push_s($out,'null');
}
}

#-- do the actual work

jsonify(obj);
nqp::join("",@out)
nqp::join("",$out)
}

my $ws := nqp::list_i;
Expand Down

1 comment on commit e22aeaf

@usev6
Copy link
Contributor

@usev6 usev6 commented on e22aeaf Jun 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this fixes the problem. \o/ Thanks!

Please sign in to comment.