import type { Bufferable } from '@aztec/foundation/serialize'; import type { AvmContext } from '../avm_context.js'; import { type Gas } from '../avm_gas.js'; import type { BufferCursor } from '../serialization/buffer_cursor.js'; import { Opcode, type OperandType } from '../serialization/instruction_serialization.js'; type InstructionConstructor = { new (...args: any[]): Instruction; }; /** * Parent class for all AVM instructions. * It's most important aspects are execute and (de)serialize. */ export declare abstract class Instruction { /** * Consumes gas and executes the instruction. * This is the main entry point for the instruction. * @param context - The AvmContext in which the instruction executes. */ abstract execute(context: AvmContext): Promise; /** * Whether the instruction will modify the PC itself. */ handlesPC(): boolean; /** * Generate a string representation of the instruction including * the instruction sub-class name all of its flags and operands. * @returns Thee string representation. */ toString(): string; static fromBuffer(this: InstructionConstructor & { wireFormat: OperandType[]; as: any; }, buf: BufferCursor | Buffer): Instruction; toBuffer(): Buffer; /** * Returns a new instruction instance that can be serialized with the given opcode and wire format. * @param opcode The opcode of the instruction. * @param wireFormat The wire format of the instruction. * @returns The new instruction instance. */ as(opcode: Opcode, wireFormat: OperandType[]): Instruction & Bufferable; /** * Returns a new instruction class that can be deserialized with the given opcode and wire format. * @param opcode The opcode of the instruction. * @param wireFormat The wire format of the instruction. * @returns The new instruction class. */ static as(this: InstructionConstructor, wireFormat: OperandType[]): InstructionConstructor & { fromBuffer: (buf: Buffer | BufferCursor) => Instruction; }; /** * Returns the base gas cost for the instruction. * @returns The base gas cost. */ protected baseGasCost(indirectOperandsCount: number, relativeOperandsCount: number): Gas; /** * Computes the dynamic gas cost for the instruction * @param dynMultiplier - The multiplier for the dynamic gas cost. * @returns The dynamic gas cost. */ protected dynamicGasCost(dynMultiplier?: number): Gas; /** * Returns the stringified type of the instruction. * Instruction sub-classes should have a static `type` property. */ get type(): string; /** * Returns the opcode of the instruction. * Instruction sub-classes should have a static `opcode` property. */ get opcode(): Opcode; } export {}; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zdHJ1Y3Rpb24uZC50cyIsInNvdXJjZV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