Rename Register to Registers

"Register" suggests this type stores a single register and not a
collection of registers, which is confusing.
parent b241834e
Pipeline #164529864 passed with stages
in 63 minutes and 53 seconds
......@@ -8,11 +8,11 @@ use crate::compiled_code::CompiledCodePointer;
use crate::global_scope::GlobalScopePointer;
use crate::object_pointer::{ObjectPointer, ObjectPointerPointer};
use crate::process::RcProcess;
use crate::register::Register;
use crate::registers::Registers;
pub struct ExecutionContext {
/// The registers for this context.
pub register: Register,
pub registers: Registers,
/// The binding to evaluate this context in.
pub binding: RcBinding,
......@@ -59,7 +59,7 @@ impl ExecutionContext {
return_register: Option<u16>,
) -> ExecutionContext {
ExecutionContext {
register: Register::new(block.code.registers as usize),
registers: Registers::new(block.code.registers as usize),
binding: Binding::from_block(block),
deferred_blocks: Vec::new(),
code: block.code,
......@@ -73,7 +73,7 @@ impl ExecutionContext {
pub fn from_isolated_block(block: &Block) -> ExecutionContext {
ExecutionContext {
register: Register::new(block.code.registers as usize),
registers: Registers::new(block.code.registers as usize),
binding: Binding::with_rc(block.locals(), block.receiver),
code: block.code,
deferred_blocks: Vec::new(),
......@@ -121,11 +121,11 @@ impl ExecutionContext {
}
pub fn get_register(&self, register: usize) -> ObjectPointer {
self.register.get(register)
self.registers.get(register)
}
pub fn set_register(&mut self, register: usize, value: ObjectPointer) {
self.register.set(register, value);
self.registers.set(register, value);
}
pub fn get_local(&self, index: usize) -> ObjectPointer {
......@@ -180,7 +180,7 @@ impl ExecutionContext {
F: FnMut(ObjectPointerPointer),
{
self.binding.each_pointer(|ptr| callback(ptr));
self.register.each_pointer(|ptr| callback(ptr));
self.registers.each_pointer(|ptr| callback(ptr));
for pointer in &self.deferred_blocks {
callback(pointer.pointer());
......@@ -381,7 +381,7 @@ mod tests {
let pointer = ObjectPointer::new(0x1 as RawObjectPointer);
let deferred = ObjectPointer::integer(5);
context.register.set(0, pointer);
context.registers.set(0, pointer);
context.binding.set_local(0, pointer);
context.add_defer(deferred);
......
......@@ -40,7 +40,7 @@ pub mod object_value;
pub mod platform;
pub mod process;
pub mod process_status;
pub mod register;
pub mod registers;
pub mod runtime_error;
pub mod runtime_panic;
pub mod scheduler;
......
......@@ -6,14 +6,14 @@ use crate::chunk::Chunk;
use crate::object_pointer::{ObjectPointer, ObjectPointerPointer};
/// Structure used for storing temporary values of a scope.
pub struct Register {
pub struct Registers {
pub values: Chunk<ObjectPointer>,
}
impl Register {
/// Creates a new Register.
pub fn new(amount: usize) -> Register {
Register {
impl Registers {
/// Creates a new Registers.
pub fn new(amount: usize) -> Registers {
Registers {
values: Chunk::new(amount),
}
}
......@@ -49,7 +49,7 @@ mod tests {
#[test]
fn test_set_get() {
let mut register = Register::new(6);
let mut register = Registers::new(6);
let pointer = ObjectPointer::new(0x4 as RawObjectPointer);
register.set(0, pointer);
......@@ -61,7 +61,7 @@ mod tests {
#[test]
fn test_each_pointer() {
let mut register = Register::new(2);
let mut register = Registers::new(2);
let pointer1 = ObjectPointer::new(0x1 as RawObjectPointer);
let pointer2 = ObjectPointer::new(0x2 as RawObjectPointer);
......
......@@ -1148,7 +1148,7 @@ impl Machine {
2,
)?;
context.register.values.reset();
context.registers.values.reset();
context.instruction_index = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment