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:
74
src/obj/reserved.rs
Normal file
74
src/obj/reserved.rs
Normal file
@@ -0,0 +1,74 @@
|
||||
//! Reserved names for object members.
|
||||
|
||||
use crate::obj::sym::{Sym, SymRef, global_sym, global_sym_ref};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
macro_rules! name {
|
||||
($name:ident, $text:expr $(,)?) => {
|
||||
pub static $name: Lazy<NameInfo> = Lazy::new(|| {
|
||||
let name = $text;
|
||||
let sym = global_sym(name.to_string());
|
||||
NameInfo { name, sym, }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NameInfo {
|
||||
pub name: &'static str,
|
||||
pub sym: Sym,
|
||||
}
|
||||
|
||||
impl NameInfo {
|
||||
pub fn sym_ref(&self) -> SymRef {
|
||||
global_sym_ref(self.sym)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Types
|
||||
//
|
||||
name!(INT_NAME, "Int");
|
||||
name!(TY_NAME, "Type");
|
||||
name!(SYM_NAME, "Sym");
|
||||
|
||||
//
|
||||
// Members
|
||||
//
|
||||
name!(TY_MEMBER_NAME, "__type__");
|
||||
name!(CALL_MEMBER_NAME, "__call__");
|
||||
name!(NAME_MEMBER_NAME, "__name__");
|
||||
name!(GET_ATTR_MEMBER_NAME, "__get_attr__");
|
||||
name!(SET_ATTR_MEMBER_NAME, "__set_attr__");
|
||||
name!(SELF_MEMBER_NAME, "__self__");
|
||||
name!(FUNC_MEMBER_NAME, "__func__");
|
||||
|
||||
//
|
||||
// Predefined VM-aware symbols
|
||||
//
|
||||
name!(SCOPE_NAME, "__scope__");
|
||||
|
||||
//
|
||||
// Builtin functions
|
||||
//
|
||||
//name!(REPR_FUN_NAME, REPR_FUN_SYM, "repr");
|
||||
//name!(GET_LOCAL_FUN_NAME, GET_LOCAL_FUN_SYM, "get_local");
|
||||
//name!(SET_LOCAL_FUN_NAME, SET_LOCAL_FUN_SYM, "set_local");
|
||||
|
||||
//
|
||||
// Builtin constants
|
||||
//
|
||||
name!(TRUE_NAME, "true");
|
||||
name!(FALSE_NAME, "false");
|
||||
name!(NIL_NAME, "nil");
|
||||
|
||||
// Operator function names
|
||||
name!(EQ_EQ_OP_NAME, "__eq__");
|
||||
name!(LT_OP_NAME, "__lt__");
|
||||
name!(GT_OP_NAME, "__gt__");
|
||||
name!(LT_EQ_OP_NAME, "__le__");
|
||||
name!(GT_EQ_OP_NAME, "__ge__");
|
||||
name!(PLUS_OP_NAME, "__add__");
|
||||
name!(MINUS_OP_NAME, "__sub__");
|
||||
name!(TIMES_OP_NAME, "__mul__");
|
||||
name!(DIV_OP_NAME, "__div__");
|
||||
|
||||
Reference in New Issue
Block a user