Skip to main content

luaur_analysis/records/
scope.rs

1//! Node: `cxx:Record:Luau.Analysis:Analysis/include/Luau/Scope.h:33:scope`
2//! Source: `Analysis/include/Luau/Scope.h` (Scope.h:33-118, hand-ported; fields only,
3//! methods are separate schedule items)
4
5use crate::records::binding::Binding;
6use crate::records::def::Def;
7use crate::records::symbol::Symbol;
8use crate::records::type_fun::TypeFun;
9use crate::records::type_level::TypeLevel;
10use crate::type_aliases::module_name_type::ModuleName;
11use crate::type_aliases::name_type::Name;
12use crate::type_aliases::refinement_map::RefinementMap;
13use crate::type_aliases::scope_ptr_type::ScopePtr;
14use crate::type_aliases::type_id::TypeId;
15use crate::type_aliases::type_pack_id::TypePackId;
16use alloc::string::String;
17use alloc::vec::Vec;
18use luaur_ast::records::location::Location;
19use luaur_common::records::dense_hash_map::DenseHashMap;
20use luaur_common::records::dense_hash_set::DenseHashSet;
21use std::collections::HashMap;
22
23#[derive(Debug)]
24pub struct Scope {
25    pub parent: Option<ScopePtr>, // null for the root
26
27    pub children: Vec<*mut Scope>, // NotNull<Scope>
28    pub bindings: HashMap<Symbol, Binding>,
29    pub return_type: TypePackId,
30    pub vararg_pack: Option<TypePackId>,
31
32    pub level: TypeLevel,
33
34    /// the spanning location associated with this scope
35    pub location: Location,
36
37    pub exported_type_bindings: HashMap<Name, TypeFun>,
38    pub private_type_bindings: HashMap<Name, TypeFun>,
39    pub type_alias_locations: HashMap<Name, Location>,
40    pub type_alias_name_locations: HashMap<Name, Location>,
41    /// Mapping from the name in the require statement to the internal moduleName.
42    pub imported_modules: HashMap<Name, ModuleName>,
43    pub imported_type_bindings: HashMap<Name, HashMap<Name, TypeFun>>,
44    pub builtin_type_names: DenseHashSet<Name>,
45
46    pub private_type_pack_bindings: HashMap<Name, TypePackId>,
47
48    pub refinements: RefinementMap,
49    pub lvalue_types: DenseHashMap<*const Def, TypeId>,
50    pub rvalue_refinements: DenseHashMap<*const Def, TypeId>,
51
52    pub globals_to_warn: DenseHashSet<String>,
53
54    pub type_alias_type_parameters: HashMap<Name, TypeId>,
55    pub type_alias_type_pack_parameters: HashMap<Name, TypePackId>,
56
57    pub interior_free_types: Option<Vec<TypeId>>,
58    pub interior_free_type_packs: Option<Vec<TypePackId>>,
59
60    pub invalid_type_aliases: DenseHashMap<String, Location>,
61}