Rename "Local" to "Name" when referring to variables during compilation

* Variables were previously named "Local"s because they described a
  local variable - however, this is kind of a misnomer because it
  handles globals as well. This has been changed pretty much everywhere
  when appropriate (hopefully).
* Renamed obj/names.rs to obj/reserved.rs, freeing up the "names" module
  for the new Names handle
* Renamed obj/locals.rs to obj/names.rs, see above

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-09-18 13:57:51 -07:00
parent 7228732128
commit 0d6f68216b
14 changed files with 114 additions and 111 deletions

View File

@@ -26,20 +26,20 @@ unsafe impl GcSafe for FrameKind {}
#[derive(Scan, Debug, Clone)]
pub struct Frame {
locals: Locals,
locals: Names,
kind: FrameKind,
}
impl Frame {
pub fn new(locals: Locals, kind: FrameKind) -> Self {
pub fn new(locals: Names, kind: FrameKind) -> Self {
Self { locals, kind, }
}
pub fn locals(&self) -> &Locals {
pub fn locals(&self) -> &Names {
&self.locals
}
pub fn locals_mut(&mut self) -> &mut Locals {
pub fn locals_mut(&mut self) -> &mut Names {
&mut self.locals
}

View File

@@ -10,10 +10,10 @@ pub enum Inst {
PushConst(ConstHandle),
/// Looks up and pushes a local value.
PushLocal(Local),
LoadName(Name),
/// Pop a value from the stack, possibly into a local symbol.
Pop(Option<Local>),
Pop(Option<Name>),
/// Pops a symbol value and an object reference.
///
@@ -119,7 +119,7 @@ impl Inst {
match self {
Inst::PushSym(_) => "PUSH_SYM",
Inst::PushConst(_) => "PUSH_CONST",
Inst::PushLocal(_) => "PUSH_LOCAL",
Inst::LoadName(_) => "LOAD_NAME",
Inst::Pop(_) => "POP",
Inst::GetAttr(_) => "GET_ATTR",
Inst::SetAttr(_) => "SET_ATTR",
@@ -189,7 +189,7 @@ impl Display for InstFormatter<'_, '_> {
format!("{:?}", obj)
},
),
Inst::PushLocal(local) => (
Inst::LoadName(local) => (
local.index().to_string(),
"TODO: local name".to_string(),
),

View File

@@ -4,7 +4,7 @@ pub mod frame;
pub mod inst;
use crate::{
obj::{names::*, prelude::*},
obj::{reserved::*, prelude::*},
vm::{consts::*, error::*, frame::*, inst::*},
};
use shredder::{GcSafe, Scanner, Scan};
@@ -129,7 +129,7 @@ impl<'c> Vm<'c> {
let obj_ref = self.const_pool.get(hdl).clone();
self.push(obj_ref);
}
Inst::PushLocal(_sym) => todo!(),
Inst::LoadName(_sym) => todo!(),
Inst::Pop(Some(_sym)) => todo!(),
Inst::Pop(None) => todo!(),
Inst::GetAttr(sym) => {