Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(vscode): don't cache disasm for BoC #422

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions client/src/providers/BocDecompilerProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from "vscode"
import {AssemblyWriter, disassembleRoot, debugSymbols, Cell} from "@tact-lang/opcode"
import {AssemblyWriter, Cell, debugSymbols, disassembleRoot} from "@tact-lang/opcode"
import {readFileSync} from "node:fs"

export class BocDecompilerProvider implements vscode.TextDocumentContentProvider {
@@ -8,20 +8,11 @@ export class BocDecompilerProvider implements vscode.TextDocumentContentProvider

public static scheme: string = "boc-decompiled"

private readonly decompileCache: Map<string, string> = new Map()

public provideTextDocumentContent(uri: vscode.Uri): string {
const bocPath = this.getBocPath(uri)

try {
const cached = this.decompileCache.get(bocPath)
if (cached) {
return cached
}

const decompiled = this.decompileBoc(bocPath)
this.decompileCache.set(bocPath, decompiled)
return decompiled
return this.decompileBoc(bocPath)
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error)
return this.formatError(errorMessage)
@@ -78,6 +69,5 @@ export class BocDecompilerProvider implements vscode.TextDocumentContentProvider
// Метод для обновления содержимого
public update(uri: vscode.Uri): void {
this._onDidChange.fire(uri)
this.decompileCache.delete(this.getBocPath(uri))
}
}