MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / get_global

Method get_global

aiscript-vm/src/vm/state.rs:226–249  ·  view source on GitHub ↗
(&self, name: InternedString<'gc>)

Source from the content-addressed store, hash-verified

224 }
225
226 pub fn get_global(&self, name: InternedString<'gc>) -> Option<Value<'gc>> {
227 // First check if it's a module name
228 if let Some(module) = self.module_manager.get_module(name) {
229 return Some(Value::Module(module.name()));
230 }
231
232 // Then check current globals scope
233 if let Some(value) = self.globals.get(&name).copied() {
234 return Some(value);
235 }
236
237 // Finally check current module's globals if we're in a module
238 if let Some(current_module) = self.current_module {
239 if let Some(ModuleKind::Script { globals, .. }) =
240 self.module_manager.modules.get(&current_module)
241 {
242 if let Some(value) = globals.get(&name).copied() {
243 return Some(value);
244 }
245 }
246 }
247
248 None
249 }
250
251 pub fn gc_ref<T: Collect>(&mut self, value: T) -> GcRefLock<'gc, T> {
252 Gc::new(self.mc, RefLock::new(value))

Callers 2

handle_tool_callMethod · 0.45
dispatch_nextMethod · 0.45

Calls 3

get_moduleMethod · 0.80
nameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected