import { Primitive, PrimitiveInt, PrimitiveInt16U, PrimitiveFloat, PrimitiveString, PrimitiveStringP8N } from '@sage-js/core'; import { OSI, StringP8NTable, FunctionDefinition, IClassDefinitionTableEntry, MapClassDefinitionTableEntryExtends, ClassDefinitionProperty, ClassDefinitionMethod, ISubroutineTableEntry, Instruction } from '@sage-js/res-osi'; import { MapSubroutineOffsetToId, MapFunctionOffsetToDefinitions, MapClassMethodOffsetToDefinitions, MapClassStructuresToNames, MapSourceRange } from '../../types'; import { ASTNodeFile } from '../../ast/node/file'; import { ASTNodeComment } from '../../ast/node/comment'; import { ASTNodeArgument } from '../../ast/node/argument/class'; import { ASTNodeArgumentNumber } from '../../ast/node/argument/number'; import { ASTNodeArgumentString } from '../../ast/node/argument/string'; import { ASTNodeStatement } from '../../ast/node/statement/class'; import { ASTNodeStatementInstruction } from '../../ast/node/statement/instruction'; import { ASTNodeStatementBlock } from '../../ast/node/statement/block'; import { ASTNodeStatementLine } from '../../ast/node/statement/line'; import { Assembly } from '../class'; /** * AssemblyDisassembler constructor. */ export declare class AssemblyDisassembler extends Assembly { /** * Disable transforming class property and method symbols to strings. */ disableTransformSymbols: boolean; /** * Include comments for the index different things appear. */ enableIndexComments: boolean; constructor(); /** * Reset any stateful properties. */ reset(): void; /** * Disassemble OSI to AST. * * @param osi OSI instance. * @returns AST file. */ disassemble(osi: OSI): ASTNodeFile; /** * Encode OSI AST metadata. * * @param osi OSI instance. * @returns AST statements. */ disassembleMetadata(osi: OSI): ASTNodeStatement[]; /** * Encode OSI AST strings. * * @param osi OSI instance. * @returns AST statements. */ disassembleStrings(osi: OSI): ASTNodeStatement[]; /** * Encode OSI AST globals. * * @param osi OSI instance. * @returns AST statements. */ disassembleGlobals(osi: OSI): ASTNodeStatement[]; /** * Encode OSI AST symbols. * * @param osi OSI instance. * @returns AST statements. */ disassembleSymbols(osi: OSI): ASTNodeStatement[]; /** * Encode OSI AST sources. * * @param osi OSI instance. * @returns AST statements. */ disassembleSources(osi: OSI): ASTNodeStatement[]; /** * Encode OSI AST PrimitiveStringP8NTable. * * @param table Table to be encoded. * @param name Block name. * @param instruction Instruction names. * @returns AST statements. */ disassembleStringP8NTable(table: StringP8NTable, name: string, instruction: string): ASTNodeStatement[]; /** * Encode OSI AST functions. * * @param osi OSI instance. * @param subroutineOffsetToId Map of subroutine offsets to IDs. * @returns AST statements. */ disassembleFunctions(osi: OSI, subroutineOffsetToId: MapSubroutineOffsetToId): ASTNodeStatement[]; /** * Encode OSI AST function. * * @param osi OSI instance. * @param functionDefinition Function definition. * @param index Table index. * @param subroutineOffsetToId Map of subroutine offsets to IDs. * @returns AST statements. */ disassembleFunction(osi: OSI, functionDefinition: FunctionDefinition, index: number, subroutineOffsetToId: MapSubroutineOffsetToId): ASTNodeStatement[]; /** * Encode OSI AST classes. * * @param osi OSI instance. * @param subroutineOffsetToId Map of subroutine offsets to IDs. * @param parents Parent mappings. * @returns AST statements. */ disassembleClasses(osi: OSI, subroutineOffsetToId: MapSubroutineOffsetToId, parents?: MapClassDefinitionTableEntryExtends | null): ASTNodeStatement[]; /** * Encode OSI AST class. * * @param osi OSI instance. * @param classDefinition Class definition. * @param index Table index. * @param subroutineOffsetToId Map of subroutine offsets to IDs. * @param parentName Parent name or null. * @returns AST statements. */ disassembleClass(osi: OSI, classDefinition: IClassDefinitionTableEntry, index: number, subroutineOffsetToId: MapSubroutineOffsetToId, parentName?: PrimitiveStringP8N | null): ASTNodeStatement[]; /** * Encode OSI AST class property. * * @param osi OSI instance. * @param property Class property. * @returns AST statements. */ disassembleClassProperty(osi: OSI, property: ClassDefinitionProperty): ASTNodeStatement[]; /** * Encode OSI AST class property. * * @param osi OSI instance. * @param method Class method. * @param subroutineOffsetToId Map offsets to ID. * @returns AST statements. */ disassembleClassMethod(osi: OSI, method: ClassDefinitionMethod, subroutineOffsetToId: MapSubroutineOffsetToId): ASTNodeStatement[]; /** * Subroutine block from OSI. * * @param osi OSI instance. * @param subroutineEntry Subroutine entry. * @param subroutineOffsetToId Map offsets to ID. * @param functionsByOffset Map function offset to function info. * @param classMethodByOffset Map class offset to method info. * @param classMethodImplementByOffset Map class offset to implement info. * @returns AST statements. */ disassembleSubroutine(osi: OSI, subroutineEntry: ISubroutineTableEntry, subroutineOffsetToId: MapSubroutineOffsetToId, functionsByOffset: MapFunctionOffsetToDefinitions, classMethodByOffset: MapClassMethodOffsetToDefinitions, classMethodImplementByOffset: MapClassMethodOffsetToDefinitions): ASTNodeStatement[]; /** * Subroutine block from OSI. * * @param osi OSI instance. * @param instruction Subroutine instruction. * @param subroutineEntry Subroutine entry. * @param mapSourceRange Map sources to ranges. * @returns AST statements. */ disassembleInstruction(osi: OSI, instruction: Instruction, subroutineEntry: ISubroutineTableEntry, mapSourceRange: MapSourceRange): ASTNodeStatement[]; /** * Arguments AST from instruction. * * @param osi OSI instance. * @param instruction Instruction. * @returns AST arguments. */ disassembleInstructionArguments(osi: OSI, instruction: Instruction): ASTNodeArgument[]; /** * Argument AST from instruction and argument. * * @param osi OSI instance. * @param argument Instruction argument. * @param argumentIndex Instruction argument index. * @param instruction Instruction. * @returns AST argument. */ disassembleInstructionArgument(osi: OSI, argument: Primitive, argumentIndex: number, instruction: Instruction): ASTNodeArgument; /** * Subroutine block from OSI. * * @param osi OSI instance. * @param mapSourceRange Map sources to ranges. * @returns AST statements. */ protected _disassembleMapSourceRangeComment(osi: OSI, mapSourceRange: MapSourceRange): ASTNodeStatementLine[]; /** * Map subroutine offsets to incremental IDs. * * @param osi OSI instance. * @returns Map object. */ protected _disassembleMapSubroutineOffsetToId(osi: OSI): MapSubroutineOffsetToId; /** * Map function offsets to function definitions. * * @param osi OSI instance. * @returns Map object. */ protected _disassembleMapFunctionOffsetToDefinitions(osi: OSI): MapFunctionOffsetToDefinitions; /** * Map OSI class structures to names, with some sanity checking. * * @param osi OSI instance. * @returns Map object. */ protected _disassembleMapClassStructuresToNames(osi: OSI): MapClassStructuresToNames; /** * Map class method offsets to class definitions. * * @param osi OSI instance. * @returns Map object. */ protected _disassembleMapClassMethodOffsetToDefinitions(osi: OSI): MapClassMethodOffsetToDefinitions; /** * Map class method offsets to class definitions of implementation. * * @param osi OSI instance. * @param parents Parent mappings. * @returns Map object. */ protected _disassembleMapclassMethodImplementsByOffset(osi: OSI, parents?: MapClassDefinitionTableEntryExtends | null): MapClassMethodOffsetToDefinitions; /** * Create argument number from primitive int. * * @param value Primitive int. * @param base Integer base. * @returns AST argument. */ protected _disassembleCreateArgumentFromInt(value: PrimitiveInt, base?: number): ASTNodeArgumentNumber; /** * Create argument number from primitive float. * * @param value Primitive float. * @returns AST argument. */ protected _disassembleCreateArgumentFromFloat(value: PrimitiveFloat): ASTNodeArgumentNumber; /** * Create argument number from regular number primitive. * * @param value Number primitive. * @returns AST argument. */ protected _disassembleCreateArgumentFromNumber(value: number): ASTNodeArgumentNumber; /** * Create argument string from primitive string. * * @param value Primitive string. * @returns AST argument. */ protected _disassembleCreateArgumentFromString(value: PrimitiveString): ASTNodeArgumentString; /** * Set comment from text. * * @param comment Comment node. * @param str Comment body. */ protected _disassembleSetComment(comment: ASTNodeComment, str: string): void; /** * Create AST statement line. * * @returns New instance. */ protected _disassembleCreateStatementLine(): ASTNodeStatementLine; /** * Create AST statement block. * * @param id Identifier string. * @returns New instance. */ protected _disassembleCreateStatementBlock(id: string): ASTNodeStatementBlock; /** * Create AST statement instruction. * * @param id Identifier string. * @returns New instance. */ protected _disassembleCreateStatementInstruction(id: string): ASTNodeStatementInstruction; /** * Convert symbol to argument and comment. * * @param symbols Symbols list. * @param symbol Symbol ID. * @returns Arg an comment values. */ protected _disassembleConvertSymbolToArgumentComment(symbols: PrimitiveStringP8N[], symbol: PrimitiveInt16U): { arg: ASTNodeArgumentNumber; comment: string | null; }; }