Skip to main content

luaur_analysis/methods/
scope_scope_scope.rs

1//! C++ `Scope::Scope(TypePackId returnType)` (`Analysis/src/Scope.cpp:10`):
2//! a root scope with no parent, the given return type, and a default
3//! `TypeLevel{}`. Every other member uses its in-class initializer (the
4//! `DenseHash*` empty-key sentinels from `Analysis/include/Luau/Scope.h`).
5use crate::records::def::Def;
6use crate::records::scope::Scope;
7use crate::records::type_level::TypeLevel;
8use crate::type_aliases::type_pack_id::TypePackId;
9use alloc::string::String;
10use alloc::vec::Vec;
11use luaur_ast::records::location::Location;
12use luaur_common::records::dense_hash_map::DenseHashMap;
13use luaur_common::records::dense_hash_set::DenseHashSet;
14use std::collections::HashMap;
15
16impl Scope {
17    pub fn scope_type_pack_id(return_type: TypePackId) -> Self {
18        Scope {
19            parent: None,
20            children: Vec::new(),
21            bindings: HashMap::new(),
22            return_type,
23            vararg_pack: None,
24            level: TypeLevel::default(),
25            location: Location::default(),
26            exported_type_bindings: HashMap::new(),
27            private_type_bindings: HashMap::new(),
28            type_alias_locations: HashMap::new(),
29            type_alias_name_locations: HashMap::new(),
30            imported_modules: HashMap::new(),
31            imported_type_bindings: HashMap::new(),
32            builtin_type_names: DenseHashSet::default(),
33            private_type_pack_bindings: HashMap::new(),
34            refinements: HashMap::new(),
35            lvalue_types: DenseHashMap::new(core::ptr::null::<Def>()),
36            rvalue_refinements: DenseHashMap::new(core::ptr::null::<Def>()),
37            globals_to_warn: DenseHashSet::default(),
38            type_alias_type_parameters: HashMap::new(),
39            type_alias_type_pack_parameters: HashMap::new(),
40            interior_free_types: None,
41            interior_free_type_packs: None,
42            invalid_type_aliases: DenseHashMap::new(String::new()),
43        }
44    }
45}