diff --git a/src/beam/beamFile.ts b/src/beam/beamFile.ts index 7ad08db..d3f4f3a 100644 --- a/src/beam/beamFile.ts +++ b/src/beam/beamFile.ts @@ -64,6 +64,7 @@ export default class BeamFile implements beamdasm.IBeamFile { } readBeamFile(filePath: string) { + let buffer: Buffer = fs.readFileSync(filePath); let for1 = buffer.toString('utf8', 0, 4).toLowerCase(); diff --git a/src/beam/beamdasmFormatter.ts b/src/beam/beamdasmFormatter.ts index 369ffc1..5aca1be 100644 --- a/src/beam/beamdasmFormatter.ts +++ b/src/beam/beamdasmFormatter.ts @@ -150,16 +150,53 @@ export class BeamdasmFormatter implements beamdasm.BeamBytecodeFormatter { return str; } - formatatu8(beamFile: beamdasm.IBeamFile): string { - let str = 'Atoms: '; - let offset = str.length; + // formatatu8(beamFile: beamdasm.IBeamFile): string { + // let str = 'Atoms: '; + // let offset = str.length; + + // for (let i = 0; i < beamFile.atoms.length; i++) { + // str += (i !== 0) ? ' '.repeat(offset) : ''; + // str += `${i}\t${beamFile.atoms[i]}\n`; + // } + // str += '\n'; + + // return str; + // } + + formatatu8(beamFile: beamdasm.IBeamFile):string { + let str = ` + + + + + + ${this.insertAtoms(beamFile)} +
IndexAtom
`; - for (let i = 0; i < beamFile.atoms.length; i++) { - str += (i !== 0) ? ' '.repeat(offset) : ''; - str += `${i}\t${beamFile.atoms[i]}\n`; - } - str += '\n'; + return str; + } + insertAtoms(beamFile: beamdasm.IBeamFile):string { + let str = ''; + for(let i = 0; i< beamFile.atoms.length; i++){ + str+=`${i}${beamFile.atoms[i]}`; + } return str; } diff --git a/src/beam/opcodes.ts b/src/beam/opcodes.ts index 40efac0..4219e2a 100644 --- a/src/beam/opcodes.ts +++ b/src/beam/opcodes.ts @@ -23,7 +23,7 @@ export const opcodes: any = { 2: { ar: 3, nm: 'func_info', - doc: '**func_info** *M* *F* *A*\nDefine a function M:F/A' + doc: '**func_info** *Module* *Function* *Arity*\nDefine a function *Module*:*Function*/*Arity*' }, 3: { ar: 0, diff --git a/src/beam/terms/list.ts b/src/beam/terms/list.ts index 02dd021..46c0f56 100644 --- a/src/beam/terms/list.ts +++ b/src/beam/terms/list.ts @@ -16,25 +16,25 @@ export default class List { - _elements: any[] = []; + items: any[] = []; add(obj: any) { - this._elements.push(obj); + this.items.push(obj); } toString(): string { let str = '['; - for (let i = 0; i < this._elements.length; i++) { + for (let i = 0; i < this.items.length; i++) { str += i !== 0 ? ', ' : ''; - str += `${this._elements[i]}`; + str += `${this.items[i]}`; } str += ']'; return str; } get(index: number): any | undefined { - if (index >= 0 && index < this._elements.length) { - return this._elements[index]; + if (index >= 0 && index < this.items.length) { + return this.items[index]; } return; } diff --git a/src/beam/terms/tuple.ts b/src/beam/terms/tuple.ts index 6d15d3a..11de227 100644 --- a/src/beam/terms/tuple.ts +++ b/src/beam/terms/tuple.ts @@ -15,18 +15,18 @@ 'use strict'; export default class Tuple { - _elements: any[] = []; + items: any[] = []; add(obj: any) { - this._elements.push(obj); + this.items.push(obj); } toString(): string { let str = '{'; - for (let i = 0; i < this._elements.length; i++) { + for (let i = 0; i < this.items.length; i++) { str += i !== 0 ? ', ' : ''; - str += `${this._elements[i]}`; + str += `${this.items[i]}`; } str += '}'; diff --git a/src/beamTreeDataProvider.ts b/src/beamTreeDataProvider.ts index 8a3c865..d2ed86a 100644 --- a/src/beamTreeDataProvider.ts +++ b/src/beamTreeDataProvider.ts @@ -207,6 +207,7 @@ class BeamChunkItem extends vscode.TreeItem { let sectionDocument = vscode.Uri.file(filePath.replace(".beam", `.beam_${chunk}`)); this.command = { command: chunk === 'code' ? 'vscode.open' : 'vscode.previewHtml', + //command: 'vscode.open', arguments: [sectionDocument.with({ scheme: `beam${chunk.toLowerCase()}` })], title: `View ${chunk}` };