use cas_compute::numerical::value::Value;
use cas_parser::parser::{ast::range::RangeKind, token::op::{BinOpKind, UnaryOpKind}};
use crate::{item::Symbol, Label};
use std::ops::Range;
#[derive(Debug, Clone, PartialEq)]
pub enum InstructionKind {
InitFunc(String, String, usize, usize),
CheckExecReady,
NextArg,
ErrorIfMissingArgs,
LoadConst(Value),
CreateList(usize),
CreateListRepeat,
CreateRange(RangeKind),
LoadVar(Symbol),
StoreVar(usize),
AssignVar(usize),
StoreIndexed,
LoadIndexed,
Drop,
Binary(BinOpKind),
Unary(UnaryOpKind),
Call(usize),
CallDerivative(u8, usize),
Return,
Jump(Label),
JumpIfTrue(Label),
JumpIfFalse(Label),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Instruction {
pub kind: InstructionKind,
pub spans: Vec<Range<usize>>,
}
impl From<InstructionKind> for Instruction {
fn from(kind: InstructionKind) -> Self {
Self { kind, spans: Vec::new() }
}
}