Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
i582 committed Feb 16, 2025
1 parent e928049 commit 37e738f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
12 changes: 12 additions & 0 deletions src/decompiler/disasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ import {getDisplayNumber, hasHint} from "../spec/helpers"
import {LayoutError, OperandError, UnknownOperandTypeError} from "./errors"

export interface DisassembleParams {
/**
* The cell to disassemble.
*/
readonly source: Cell
/**
* The offset in the cell to start disassembling from.
*/
readonly offset?: {bits: number; refs: number}
/**
* The limit in the cell to stop disassembling at.
*/
readonly limit?: {bits: number; refs: number}
}

Expand Down Expand Up @@ -370,6 +379,9 @@ function checkLayout(opcodes: DecompiledInstruction[]): void {
export function disassembleRoot(
cell: Cell,
options: {
/**
* Whether to deduplicate refs into separate functions. True, by default.
*/
computeRefs: boolean
},
): ProgramNode {
Expand Down
6 changes: 3 additions & 3 deletions src/fift/fiftCompile.ts → src/fift/compileFift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ interface CompilationOk {
readonly warnings: string
}

export type CompileResult = CompilationError | CompilationOk
type CompileResult = CompilationError | CompilationOk

export async function fiftCompile(args: {content: string}): Promise<FiftCompilationResult> {
export async function compileFift(content: string): Promise<FiftCompilationResult> {
const allocatedPointers: Pointer[] = []
const allocatedFunctions: Pointer[] = []

Expand Down Expand Up @@ -85,7 +85,7 @@ export async function fiftCompile(args: {content: string}): Promise<FiftCompilat
}, "viiii"),
)

const contentCString = trackPointer(writeToCString(mod, args.content))
const contentCString = trackPointer(writeToCString(mod, content))
const resultPointer = trackPointer(mod._func_compile(contentCString, callbackPtr))
const retJson = readFromCString(mod, resultPointer)
const result = JSON.parse(retJson) as CompileResult
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ export {AssemblyWriter} from "./printer/assembly-writer"

export {debugSymbols} from "./utils/known-methods"
export {Cell} from "@ton/core"

export type {
FiftCompilationResult,
FiftCompilationResultOk,
FiftCompilationResultError,
} from "./fift/compileFift"
export {compileFift} from "./fift/compileFift"
6 changes: 2 additions & 4 deletions src/test/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {disassembleRawRoot, disassembleRoot} from "../../index"
import {AssemblyWriter} from "../../printer/assembly-writer"
import {debugSymbols} from "../../utils/known-methods"
import {fail} from "node:assert"
import {fiftCompile} from "../../fift/fiftCompile"
import {compileFift} from "../../fift/compileFift"

export function decompileAll(
src: Buffer,
Expand Down Expand Up @@ -37,9 +37,7 @@ export async function compileFiftBackAndCompare(
before: Buffer,
raw: boolean = false,
): Promise<void> {
const result = await fiftCompile({
content: content,
})
const result = await compileFift(content)
if (!result.ok) {
fail(`cannot compile boc:\n${result.log}`)
return
Expand Down

0 comments on commit 37e738f

Please sign in to comment.