Skip to content

Commit

Permalink
fix: both members of IFunctionBodyOffset are mandatory numbers
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the `start` and `end` fields of `IFunctionBodyOffset`
were optional members before.
  • Loading branch information
bmeurer committed Nov 3, 2020
1 parent ecfe5f0 commit 7383b87
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/WasmDis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ export enum LabelMode {

// The breakable range is [start, end).
export interface IFunctionBodyOffset {
start?: number;
end?: number;
start: number;
end: number;
}

export interface IDisassemblerResult {
Expand Down Expand Up @@ -449,7 +449,7 @@ export class WasmDisassembler {
private _exportMetadata: IExportMetadata = null;
private _labelMode: LabelMode;
private _functionBodyOffsets: Array<IFunctionBodyOffset>;
private _currentFunctionBodyOffset: IFunctionBodyOffset;
private _currentFunctionBodyOffset: number;
private _currentSectionId: SectionCode;
private _logFirstInstruction: boolean;
constructor() {
Expand All @@ -464,7 +464,7 @@ export class WasmDisassembler {
this._nameResolver = new DefaultNameResolver();
this._labelMode = LabelMode.WhenUsed;
this._functionBodyOffsets = [];
this._currentFunctionBodyOffset = null;
this._currentFunctionBodyOffset = 0;
this._currentSectionId = SectionCode.Unknown;
this._logFirstInstruction = false;

Expand Down Expand Up @@ -533,16 +533,15 @@ export class WasmDisassembler {
}
private logStartOfFunctionBodyOffset() {
if (this.addOffsets) {
this._currentFunctionBodyOffset = {
start: this._currentPosition,
};
this._currentFunctionBodyOffset = this._currentPosition;
}
}
private logEndOfFunctionBodyOffset() {
if (this.addOffsets && this._currentFunctionBodyOffset) {
this._currentFunctionBodyOffset.end = this._currentPosition;
this._functionBodyOffsets.push(this._currentFunctionBodyOffset);
this._currentFunctionBodyOffset = null;
if (this.addOffsets) {
this._functionBodyOffsets.push({
start: this._currentFunctionBodyOffset,
end: this._currentPosition,
});
}
}
private printFuncType(typeIndex: number): void {
Expand Down

0 comments on commit 7383b87

Please sign in to comment.