Skip to content

Commit

Permalink
more bug squashing
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Dec 23, 2024
1 parent e3b3065 commit 322e830
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public Void visitReal(IReal o) throws IOException {
@Override
public Void visitRational(IRational o) throws IOException {
out.beginArray();
out.value(o.numerator().getStringRepresentation());
out.value(o.denominator().getStringRepresentation());
out.value(o.numerator().longValue());
out.value(o.denominator().longValue());
out.endArray();

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import IO;
import util::Math;
import Type;
import DateTime;
import List;

loc targetFile = |memory://test-tmp/test-<"<uuidi()>">.json|;

Expand Down Expand Up @@ -88,23 +89,26 @@ default value numNormalizer(value x) = x;
@synopsis{Normalizer used to replace unrecoverable types with their default representatives}
value toDefaultRec(value readBack) = visit(readBack) {
value toDefaultRec(value readBack) = visit(readBack) {
case value x => toDefaultValue(x)
};
value toDefaultValue(rat r) = ["<numerator(r)>", "<denominator(r)>"];
value toDefaultValue(set[value] x) = [*x];
// this list order depends on the hashcodes of the children
// as the writer is top-down and this rewrite is bottom-up
// we end up with different lists sometimes (if the elements have been rewritten).
value toDefaultValue(set[value] x) = [*x];
value toDefaultValue(map[void,void] _) = "object"();
value toDefaultValue(<>) = [];
value toDefaultValue(<x>) = [x];
value toDefaultValue(<x,y>) = [x,y];
value toDefaultValue(<x,y,z>) = [x,y,z];
value toDefaultValue(<x,y,z,a>) = [x,y,z,a];
value toDefaultValue(<x,y,z,a,b>) = [x,y,z,a,b];
value toDefaultValue(<x,y,z,a,b,c>) = [x,y,z,a,b,c];
value toDefaultValue(<x,y,z,a,b,c,d>) = [x,y,z,a,b,c,d];
value toDefaultValue(<x,y,z,a,b,c,d,e>) = [x,y,z,a,b,c,d,e];
value toDefaultValue(<x,y,z,a,b,c,d,e,f>) = [x,y,z,a,b,c,d,e,f];
value toDefaultValue(<value x>) = [x];
value toDefaultValue(<value x,value y>) = [x,y];
value toDefaultValue(<value x,value y,value z>) = [x,y,z];
value toDefaultValue(<value x,value y,value z,value a>) = [x,y,z,a];
value toDefaultValue(<value x,value y,value z,value a,value b>) = [x,y,z,a,b];
value toDefaultValue(<value x,value y,value z,value a,value b,value c>) = [x,y,z,a,b,c];
value toDefaultValue(<value x,value y,value z,value a,value b,value c,value d>) = [x,y,z,a,b,c,d];
value toDefaultValue(<value x,value y,value z,value a,value b,value c,value d,value e>) = [x,y,z,a,b,c,d,e];
value toDefaultValue(<value x,value y,value z,value a,value b,value c,value d,value e,value f>) = [x,y,z,a,b,c,d,e,f];
value toDefaultValue(loc l) {
// this simulates the simplications the writer applies
if (!(l.offset?)) {
Expand All @@ -120,6 +124,7 @@ value toDefaultValue(loc l) {
}
}
value toDefaultValue(rat r) = [numerator(r), denominator(r)];
value toDefaultValue(datetime t) = printDateTime(t, "yyyy-MM-dd\'T\'HH:mm:ssZ");
value toDefaultValue(real r) = round(r) when r - round(r) == 0;
default value toDefaultValue(value x) = x;
Expand Down

0 comments on commit 322e830

Please sign in to comment.