Skip to content

Commit

Permalink
Runtime: default case come last
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo authored and smorimoto committed Sep 28, 2024
1 parent 6226949 commit bd764f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
3 changes: 1 addition & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
"noDoubleEquals": "off",
"noFallthroughSwitchClause": "off",
"noRedeclare": "off",
"noSelfCompare": "off",
"useDefaultSwitchClauseLast": "off"
"noSelfCompare": "off"
}
}
},
Expand Down
28 changes: 14 additions & 14 deletions runtime/mlBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ function jsoo_is_ascii(s) {
//Provides: caml_bytes_unsafe_get mutable
function caml_bytes_unsafe_get(s, i) {
switch (s.t & 6) {
default: /* PARTIAL */
if (i >= s.c.length) return 0;
case 0 /* BYTES */:
return s.c.charCodeAt(i);
case 2 /* PARTIAL */:
if (i >= s.c.length) return 0;
return s.c.charCodeAt(i);
case 4 /* ARRAY */:
return s.c[i];
}
Expand Down Expand Up @@ -442,17 +443,16 @@ function MlBytes(tag, contents, length) {
}
MlBytes.prototype.toString = function () {
switch (this.t) {
case 9 /*BYTES | ASCII*/:
case 9: /*BYTES | ASCII*/
case 8 /*BYTES | NOT_ASCII*/:
return this.c;
default:
case 4: /* ARRAY */
case 2 /* PARTIAL */:
caml_convert_string_to_bytes(this);
//fallthrough
case 0 /*BYTES | UNKOWN*/:
if (jsoo_is_ascii(this.c)) {
this.t = 9; /*BYTES | ASCII*/
return this.c;
}
this.t = 8; /*BYTES | NOT_ASCII*/
case 8 /*BYTES | NOT_ASCII*/:
if (jsoo_is_ascii(this.c)) this.t = 9; /*BYTES | ASCII*/
else this.t = 8; /*BYTES | NOT_ASCII*/
return this.c;
}
};
Expand Down Expand Up @@ -894,13 +894,13 @@ function caml_is_ml_bytes(s) {

//Provides: caml_ml_bytes_content
//Requires: MlBytes, caml_convert_string_to_bytes
//Returns a (full) string of bytes or an array
function caml_ml_bytes_content(s) {
switch (s.t & 6) {
default: /* PARTIAL */
case 2 /* PARTIAL */:
caml_convert_string_to_bytes(s);
case 0 /* BYTES */:
return s.c;
case 4:
// fallthrough
default: /* BYTES or ARRAY */
return s.c;
}
}
Expand Down

0 comments on commit bd764f9

Please sign in to comment.