mod r#abstract;
mod allocated;
mod r#final;
use super::fuel::{
abstract_instruction_set::AbstractInstructionSet,
allocated_abstract_instruction_set::AllocatedAbstractInstructionSet, data_section::DataSection,
register_sequencer::RegisterSequencer,
};
use crate::{
asm_lang::{allocated_ops::AllocatedOp, Label},
decl_engine::DeclRef,
};
type SelectorOpt = Option<[u8; 4]>;
type FnName = String;
type ImmOffset = u64;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ProgramKind {
Contract,
Library,
Predicate,
Script,
}
pub(super) struct AbstractProgram {
kind: ProgramKind,
data_section: DataSection,
entries: Vec<AbstractEntry>,
non_entries: Vec<AbstractInstructionSet>,
reg_seqr: RegisterSequencer,
}
pub(super) struct AbstractEntry {
pub(super) selector: SelectorOpt,
pub(super) label: Label,
pub(super) ops: AbstractInstructionSet,
pub(super) name: FnName,
pub(super) test_decl_ref: Option<DeclRef>,
}
pub(super) struct AllocatedProgram {
kind: ProgramKind,
data_section: DataSection,
prologue: AllocatedAbstractInstructionSet,
functions: Vec<AllocatedAbstractInstructionSet>,
entries: Vec<(SelectorOpt, Label, FnName, Option<DeclRef>)>,
}
pub(super) enum FinalProgram {
Fuel {
kind: ProgramKind,
data_section: DataSection,
ops: Vec<AllocatedOp>,
entries: Vec<(SelectorOpt, ImmOffset, FnName, Option<DeclRef>)>,
},
Evm {
ops: Vec<etk_asm::ops::AbstractOp>,
abi: Vec<ethabi::operation::Operation>,
},
}