Clean up
This commit is contained in:
parent
c7bba88875
commit
02ee7d126c
@ -1,7 +1,6 @@
|
|||||||
use std::fmt::{self, Debug, Display};
|
use std::fmt::{self, Debug, Display};
|
||||||
|
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use rayon::{iter::ParallelIterator, str::ParallelString};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{AnnotatedError, Formatter, Identifier, Instruction, Operation, Span, Type, Value};
|
use crate::{AnnotatedError, Formatter, Identifier, Instruction, Operation, Span, Type, Value};
|
||||||
@ -84,14 +83,11 @@ impl Chunk {
|
|||||||
Ok((instruction, position))
|
Ok((instruction, position))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_last_n_instructions<const N: usize>(&self) -> [Option<&(Instruction, Span)>; N] {
|
pub fn get_last_n_instructions<const N: usize>(&self) -> [Option<(&Instruction, &Span)>; N] {
|
||||||
let mut instructions = [None; N];
|
let mut instructions = [None; N];
|
||||||
|
|
||||||
for i in 0..N {
|
for (index, (instruction, position)) in self.instructions.iter().rev().enumerate().take(N) {
|
||||||
let index = self.instructions.len().saturating_sub(i + 1);
|
instructions[index] = Some((instruction, position));
|
||||||
let instruction = self.instructions.get(index);
|
|
||||||
|
|
||||||
instructions[i] = instruction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
instructions
|
instructions
|
||||||
@ -119,15 +115,8 @@ impl Chunk {
|
|||||||
pub fn get_last_n_operations<const N: usize>(&self) -> [Option<Operation>; N] {
|
pub fn get_last_n_operations<const N: usize>(&self) -> [Option<Operation>; N] {
|
||||||
let mut operations = [None; N];
|
let mut operations = [None; N];
|
||||||
|
|
||||||
for i in 0..N {
|
for (index, (instruction, _)) in self.instructions.iter().rev().enumerate().take(N) {
|
||||||
let index = self.instructions.len().saturating_sub(i + 1);
|
operations[index] = Some(instruction.operation());
|
||||||
|
|
||||||
let operation = self
|
|
||||||
.instructions
|
|
||||||
.get(index)
|
|
||||||
.map(|(instruction, _)| instruction.operation());
|
|
||||||
|
|
||||||
operations[i] = operation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operations
|
operations
|
||||||
|
Loading…
Reference in New Issue
Block a user