Skip to content

Commit

Permalink
fix: print opcodes in errors in hexadecimal form
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeurer committed Oct 23, 2020
1 parent b74c900 commit 687ba47
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/WasmParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,9 @@ export class BinaryReader {
segmentIndex = this.readVarUint32() >>> 0;
break;
default:
this.error = new Error(`Unknown operator: ${code}`);
this.error = new Error(
`Unknown operator: 0x${code.toString(16).padStart(4, "0")}`
);
this.state = BinaryReaderState.ERROR;
return true;
}
Expand Down Expand Up @@ -2339,7 +2341,9 @@ export class BinaryReader {
case OperatorCode.f32x4_convert_i32x4_u:
break;
default:
this.error = new Error(`Unknown operator: ${code}`);
this.error = new Error(
`Unknown operator: 0x${code.toString(16).padStart(4, "0")}`
);
this.state = BinaryReaderState.ERROR;
return true;
}
Expand Down Expand Up @@ -2452,7 +2456,9 @@ export class BinaryReader {
break;
}
default:
this.error = new Error(`Unknown operator: ${code}`);
this.error = new Error(
`Unknown operator: 0x${code.toString(16).padStart(4, "0")}`
);
this.state = BinaryReaderState.ERROR;
return true;
}
Expand Down Expand Up @@ -2764,7 +2770,9 @@ export class BinaryReader {
case OperatorCode.ref_is_null:
break;
default:
this.error = new Error(`Unknown operator: ${code}`);
this.error = new Error(
`Unknown operator: 0x${code.toString(16).padStart(2, "0")}`
);
this.state = BinaryReaderState.ERROR;
return true;
}
Expand Down

0 comments on commit 687ba47

Please sign in to comment.